@@ -7,6 +7,7 @@ import 'package:zulip/api/model/model.dart';
7
7
import 'package:zulip/api/route/messages.dart' ;
8
8
import 'package:zulip/api/route/channels.dart' ;
9
9
import 'package:zulip/api/route/realm.dart' ;
10
+ import 'package:zulip/basic.dart' ;
10
11
import 'package:zulip/model/compose.dart' ;
11
12
import 'package:zulip/model/emoji.dart' ;
12
13
import 'package:zulip/model/localizations.dart' ;
@@ -15,6 +16,7 @@ import 'package:zulip/model/store.dart';
15
16
import 'package:zulip/model/typing_status.dart' ;
16
17
import 'package:zulip/widgets/compose_box.dart' ;
17
18
import 'package:zulip/widgets/content.dart' ;
19
+ import 'package:zulip/widgets/emoji.dart' ;
18
20
import 'package:zulip/widgets/message_list.dart' ;
19
21
20
22
import '../api/fake_api.dart' ;
@@ -23,6 +25,7 @@ import '../flutter_checks.dart';
23
25
import '../model/binding.dart' ;
24
26
import '../model/test_store.dart' ;
25
27
import '../test_images.dart' ;
28
+ import 'message_list_test.dart' ;
26
29
import 'test_app.dart' ;
27
30
28
31
/// Simulates loading a [MessageListPage] and tapping to focus the compose input.
@@ -36,6 +39,7 @@ import 'test_app.dart';
36
39
/// before the end of the test.
37
40
Future <Finder > setupToComposeInput (WidgetTester tester, {
38
41
List <User > users = const [],
42
+ List <(int userId, UserStatusChange change)>? userStatuses,
39
43
Narrow ? narrow,
40
44
}) async {
41
45
assert (narrow is ChannelNarrow ? || narrow is SendableNarrow ? );
@@ -47,6 +51,7 @@ Future<Finder> setupToComposeInput(WidgetTester tester, {
47
51
final store = await testBinding.globalStore.perAccount (eg.selfAccount.id);
48
52
await store.addUsers ([eg.selfUser, eg.otherUser]);
49
53
await store.addUsers (users);
54
+ await store.changeUserStatuses (userStatuses ?? []);
50
55
final connection = store.connection as FakeApiConnection ;
51
56
52
57
narrow ?? = DmNarrow (
@@ -152,9 +157,24 @@ void main() {
152
157
Finder findAvatarImage (int userId) =>
153
158
find.byWidgetPredicate ((widget) => widget is AvatarImage && widget.userId == userId);
154
159
155
- void checkUserShown (User user, {required bool expected}) {
156
- check (find.text (user.fullName)).findsExactly (expected ? 1 : 0 );
157
- check (findAvatarImage (user.userId)).findsExactly (expected ? 1 : 0 );
160
+ void checkUserShown (User user, {required bool expected, bool withStatusEmoji = false }) {
161
+ assert (expected || ! withStatusEmoji);
162
+
163
+ final nameFinder = find.text (user.fullName);
164
+ check (nameFinder).findsExactly (expected ? 1 : 0 );
165
+
166
+ final avatarFinder = findAvatarImage (user.userId);
167
+ check (avatarFinder).findsExactly (expected ? 1 : 0 );
168
+
169
+ final statusEmojiFinder = findStatusEmoji (UnicodeEmojiWidget );
170
+ if (withStatusEmoji) {
171
+ checkUserStatusEmoji (statusEmojiFinder, isAnimated: false );
172
+ }
173
+ final rowFinder = find.ancestor (of: nameFinder,
174
+ matching: find.ancestor (of: avatarFinder,
175
+ matching: find.ancestor (of: statusEmojiFinder,
176
+ matching: find.byType (Row ))));
177
+ check (rowFinder).findsExactly (expected && withStatusEmoji ? 1 : 0 );
158
178
}
159
179
160
180
testWidgets ('user options appear, disappear, and change correctly' , (tester) async {
@@ -202,6 +222,31 @@ void main() {
202
222
debugNetworkImageHttpClientProvider = null ;
203
223
});
204
224
225
+ testWidgets ('status emoji is set -> emoji is displayed' , (tester) async {
226
+ final user1 = eg.user (userId: 1 , fullName: 'User One' , avatarUrl: 'user1.png' );
227
+ final user2 = eg.user (userId: 2 , fullName: 'User Two' , avatarUrl: 'user2.png' );
228
+ final composeInputFinder = await setupToComposeInput (tester,
229
+ users: [user1, user2], userStatuses: [
230
+ (
231
+ user1.userId,
232
+ UserStatusChange (
233
+ text: OptionSome ('Busy' ),
234
+ emoji: OptionSome (StatusEmoji (emojiName: 'working_on_it' ,
235
+ emojiCode: '1f6e0' , reactionType: ReactionType .unicodeEmoji)))
236
+ ),
237
+ ]);
238
+
239
+ // // TODO(#226): Remove this extra edit when this bug is fixed.
240
+ await tester.enterText (composeInputFinder, 'hello @u' );
241
+ await tester.enterText (composeInputFinder, 'hello @' );
242
+ await tester.pumpAndSettle (); // async computation; options appear
243
+
244
+ checkUserShown (user1, expected: true , withStatusEmoji: true );
245
+ checkUserShown (user2, expected: true , withStatusEmoji: false );
246
+
247
+ debugNetworkImageHttpClientProvider = null ;
248
+ });
249
+
205
250
void checkWildcardShown (WildcardMentionOption wildcard, {required bool expected}) {
206
251
check (find.text (wildcard.canonicalString)).findsExactly (expected ? 1 : 0 );
207
252
}
0 commit comments