-
Notifications
You must be signed in to change notification settings - Fork 309
msglist: Distinguish isBot: true
message senders with a bot marker
#605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:checks/checks.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
@@ -44,6 +43,7 @@ void main() { | |
int? messageCount, | ||
List<Message>? messages, | ||
List<ZulipStream>? streams, | ||
List<User>? users, | ||
List<Subscription>? subscriptions, | ||
UnreadMessagesSnapshot? unreadMsgs, | ||
}) async { | ||
|
@@ -56,6 +56,7 @@ void main() { | |
|
||
// prepare message list data | ||
store.addUser(eg.selfUser); | ||
store.addUsers(users ?? []); | ||
assert((messageCount == null) != (messages == null)); | ||
messages ??= List.generate(messageCount!, (index) { | ||
return eg.streamMessage(sender: eg.selfUser); | ||
|
@@ -467,11 +468,7 @@ void main() { | |
await tester.pump(); | ||
} | ||
|
||
final httpClient = FakeImageHttpClient(); | ||
debugNetworkImageHttpClientProvider = () => httpClient; | ||
httpClient.request.response | ||
..statusCode = HttpStatus.ok | ||
..content = kSolidBlueAvatar; | ||
prepareBoringImageHttpClient(); | ||
|
||
await setupMessageListPage(tester, messageCount: 10); | ||
checkResultForSender(eg.selfUser.avatarUrl); | ||
|
@@ -484,6 +481,49 @@ void main() { | |
|
||
debugNetworkImageHttpClientProvider = null; | ||
}); | ||
|
||
testWidgets('Bot user is distinguished by showing an icon', (tester) async { | ||
// When using this function, provide only one bot user | ||
// to [PerAccountStore] through [setupMessageListPage] function. | ||
void checkUser(User user, {required bool isBot}) { | ||
final nameFinder = find.text(user.fullName); | ||
final botFinder = find.byIcon(ZulipIcons.bot); | ||
|
||
check(nameFinder.evaluate().singleOrNull).isNotNull(); | ||
check(botFinder.evaluate().singleOrNull).isNotNull(); | ||
|
||
final userFinder = find.ancestor( | ||
of: nameFinder, | ||
matching: find.ancestor( | ||
of: botFinder, | ||
matching: find.byType(Row), | ||
)); | ||
|
||
isBot | ||
? check(userFinder.evaluate()).isNotEmpty() | ||
: check(userFinder.evaluate()).isEmpty(); | ||
} | ||
|
||
prepareBoringImageHttpClient(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the test before this test, I noticed that there was a fake testWidgets('Updates avatar on RealmUserUpdateEvent', (tester) async {
- final httpClient = FakeImageHttpClient();
- debugNetworkImageHttpClientProvider = () => httpClient;
- httpClient.request.response
- ..statusCode = HttpStatus.ok
- ..content = kSolidBlueAvatar;
+ prepareBoringImageHttpClient();
} Is it ok if I add an additional [NFC] commit to this PR with the requested change, or should we just ignore it for now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems reasonable to me! 🙂 |
||
|
||
final users = [ | ||
eg.user(fullName: 'User 1', isBot: true), | ||
eg.user(fullName: 'User 2', isBot: false), | ||
eg.user(fullName: 'User 3', isBot: false), | ||
]; | ||
|
||
await setupMessageListPage( | ||
tester, | ||
messages: users.map((user) => eg.streamMessage(sender: user)).toList(), | ||
users: users, | ||
); | ||
|
||
checkUser(users[0], isBot: true); | ||
checkUser(users[1], isBot: false); | ||
checkUser(users[2], isBot: false); | ||
|
||
debugNetworkImageHttpClientProvider = null; | ||
}); | ||
}); | ||
|
||
group('Starred messages', () { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a bot user, this evaluates to two results, and that's because there are two
Row
s that satisfy this finder; one direct parentRow
and another, the parent of this parentRow
, both are for the same user. To make sure they're for the same user, the following two lines are added just before the finder:This makes sure the
fullName
text for a user is only shown once on the screen. The bot icon is also checked for being shown just once, but that does not guarantee it belongs to the current user. That check is done bycheck(userFinder.evaluate()).isNotEmpty()
.I hope this test is fine for checking if a bot icon is shown next to a user name.