@@ -7,12 +7,14 @@ 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' ;
13
14
import 'package:zulip/model/narrow.dart' ;
14
15
import 'package:zulip/model/store.dart' ;
15
16
import 'package:zulip/model/typing_status.dart' ;
17
+ import 'package:zulip/widgets/autocomplete.dart' ;
16
18
import 'package:zulip/widgets/compose_box.dart' ;
17
19
import 'package:zulip/widgets/content.dart' ;
18
20
import 'package:zulip/widgets/message_list.dart' ;
@@ -25,6 +27,8 @@ import '../model/test_store.dart';
25
27
import '../test_images.dart' ;
26
28
import 'test_app.dart' ;
27
29
30
+ late PerAccountStore store;
31
+
28
32
/// Simulates loading a [MessageListPage] and tapping to focus the compose input.
29
33
///
30
34
/// Also adds [users] to the [PerAccountStore] ,
@@ -44,7 +48,7 @@ Future<Finder> setupToComposeInput(WidgetTester tester, {
44
48
45
49
addTearDown (testBinding.reset);
46
50
await testBinding.globalStore.add (eg.selfAccount, eg.initialSnapshot ());
47
- final store = await testBinding.globalStore.perAccount (eg.selfAccount.id);
51
+ store = await testBinding.globalStore.perAccount (eg.selfAccount.id);
48
52
await store.addUsers ([eg.selfUser, eg.otherUser]);
49
53
await store.addUsers (users);
50
54
final connection = store.connection as FakeApiConnection ;
@@ -202,6 +206,59 @@ void main() {
202
206
debugNetworkImageHttpClientProvider = null ;
203
207
});
204
208
209
+ group ('User status' , () {
210
+ void checkFindsStatusEmoji (WidgetTester tester, Finder emojiFinder) {
211
+ final statusEmojiFinder = find.ancestor (of: emojiFinder,
212
+ matching: find.byType (UserStatusEmoji ));
213
+ check (statusEmojiFinder).findsOne ();
214
+ check (tester.firstWidget <UserStatusEmoji >(statusEmojiFinder)
215
+ .neverAnimate).isTrue ();
216
+
217
+ final itemFinder = find.ancestor (of: statusEmojiFinder,
218
+ matching: find.byType (MentionAutocompleteItem ));
219
+ check (itemFinder).findsOne ();
220
+ }
221
+
222
+ testWidgets ('status emoji & text are set -> emoji is displayed, text is not' , (tester) async {
223
+ final user = eg.user (fullName: 'User' );
224
+ final composeInputFinder = await setupToComposeInput (tester, users: [user]);
225
+ await store.changeUserStatus (user.userId, UserStatusChange (
226
+ text: OptionSome ('Busy' ),
227
+ emoji: OptionSome (StatusEmoji (emojiName: 'working_on_it' ,
228
+ emojiCode: '1f6e0' , reactionType: ReactionType .unicodeEmoji))));
229
+ await tester.pump ();
230
+
231
+ // // TODO(#226): Remove this extra edit when this bug is fixed.
232
+ await tester.enterText (composeInputFinder, 'hello @u' );
233
+ await tester.enterText (composeInputFinder, 'hello @' );
234
+ await tester.pumpAndSettle (); // async computation; options appear
235
+
236
+ checkFindsStatusEmoji (tester, find.text ('\u {1f6e0}' ));
237
+ check (find.descendant (of: find.byType (MentionAutocompleteItem ),
238
+ matching: find.text ('Busy' ))).findsNothing ();
239
+
240
+ debugNetworkImageHttpClientProvider = null ;
241
+ });
242
+
243
+ testWidgets ('status emoji is not set, text is set -> text is not displayed' , (tester) async {
244
+ final user = eg.user (fullName: 'User' );
245
+ final composeInputFinder = await setupToComposeInput (tester, users: [user]);
246
+ await store.changeUserStatus (user.userId, UserStatusChange (
247
+ text: OptionSome ('Busy' ), emoji: OptionNone ()));
248
+ await tester.pump ();
249
+
250
+ // // TODO(#226): Remove this extra edit when this bug is fixed.
251
+ await tester.enterText (composeInputFinder, 'hello @u' );
252
+ await tester.enterText (composeInputFinder, 'hello @' );
253
+ await tester.pumpAndSettle (); // async computation; options appear
254
+
255
+ check (find.descendant (of: find.byType (MentionAutocompleteItem ),
256
+ matching: find.text ('Busy' ))).findsNothing ();
257
+
258
+ debugNetworkImageHttpClientProvider = null ;
259
+ });
260
+ });
261
+
205
262
void checkWildcardShown (WildcardMentionOption wildcard, {required bool expected}) {
206
263
check (find.text (wildcard.canonicalString)).findsExactly (expected ? 1 : 0 );
207
264
}
0 commit comments