@@ -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' ;
@@ -36,6 +38,7 @@ import 'test_app.dart';
36
38
/// before the end of the test.
37
39
Future <Finder > setupToComposeInput (WidgetTester tester, {
38
40
List <User > users = const [],
41
+ List <(int userId, UserStatusChange change)>? userStatuses,
39
42
Narrow ? narrow,
40
43
}) async {
41
44
assert (narrow is ChannelNarrow ? || narrow is SendableNarrow ? );
@@ -47,6 +50,7 @@ Future<Finder> setupToComposeInput(WidgetTester tester, {
47
50
final store = await testBinding.globalStore.perAccount (eg.selfAccount.id);
48
51
await store.addUsers ([eg.selfUser, eg.otherUser]);
49
52
await store.addUsers (users);
53
+ await store.changeUserStatuses (userStatuses ?? []);
50
54
final connection = store.connection as FakeApiConnection ;
51
55
52
56
narrow ?? = DmNarrow (
@@ -152,9 +156,22 @@ void main() {
152
156
Finder findAvatarImage (int userId) =>
153
157
find.byWidgetPredicate ((widget) => widget is AvatarImage && widget.userId == userId);
154
158
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 );
159
+ void checkUserShown (User user, {required bool expected, bool withStatusEmoji = false }) {
160
+ assert (expected || ! withStatusEmoji);
161
+
162
+ final nameFinder = find.text (user.fullName);
163
+ check (nameFinder).findsExactly (expected ? 1 : 0 );
164
+
165
+ final avatarFinder = findAvatarImage (user.userId);
166
+ check (avatarFinder).findsExactly (expected ? 1 : 0 );
167
+
168
+ final statusEmojiFinder = find.ancestor (of: find.byType (UnicodeEmojiWidget ),
169
+ matching: find.byType (UserStatusEmoji ));
170
+ final rowFinder = find.ancestor (of: nameFinder,
171
+ matching: find.ancestor (of: avatarFinder,
172
+ matching: find.ancestor (of: statusEmojiFinder,
173
+ matching: find.byType (Row ))));
174
+ check (rowFinder).findsExactly (expected && withStatusEmoji ? 1 : 0 );
158
175
}
159
176
160
177
testWidgets ('user options appear, disappear, and change correctly' , (tester) async {
@@ -202,6 +219,32 @@ void main() {
202
219
debugNetworkImageHttpClientProvider = null ;
203
220
});
204
221
222
+ testWidgets ('status emoji is set -> emoji is displayed' , (tester) async {
223
+ final user1 = eg.user (userId: 1 , fullName: 'User One' , avatarUrl: 'user1.png' );
224
+ final user2 = eg.user (userId: 2 , fullName: 'User Two' , avatarUrl: 'user2.png' );
225
+ final composeInputFinder = await setupToComposeInput (tester,
226
+ users: [user1, user2], userStatuses: [
227
+ (
228
+ user1.userId,
229
+ UserStatusChange (
230
+ text: OptionSome ('Busy' ),
231
+ emoji: OptionSome (StatusEmoji (emojiName: 'working_on_it' ,
232
+ emojiCode: '1f6e0' , reactionType: ReactionType .unicodeEmoji)))
233
+ ),
234
+ ]);
235
+
236
+ // Options are filtered correctly for query
237
+ // // TODO(#226): Remove this extra edit when this bug is fixed.
238
+ await tester.enterText (composeInputFinder, 'hello @u' );
239
+ await tester.enterText (composeInputFinder, 'hello @' );
240
+ await tester.pumpAndSettle (); // async computation; options appear
241
+
242
+ checkUserShown (user1, expected: true , withStatusEmoji: true );
243
+ checkUserShown (user2, expected: true , withStatusEmoji: false );
244
+
245
+ debugNetworkImageHttpClientProvider = null ;
246
+ });
247
+
205
248
void checkWildcardShown (WildcardMentionOption wildcard, {required bool expected}) {
206
249
check (find.text (wildcard.canonicalString)).findsExactly (expected ? 1 : 0 );
207
250
}
0 commit comments