@@ -7,12 +7,14 @@ import 'package:zulip/api/model/model.dart';
77import 'package:zulip/api/route/messages.dart' ;
88import 'package:zulip/api/route/channels.dart' ;
99import 'package:zulip/api/route/realm.dart' ;
10+ import 'package:zulip/basic.dart' ;
1011import 'package:zulip/model/compose.dart' ;
1112import 'package:zulip/model/emoji.dart' ;
1213import 'package:zulip/model/localizations.dart' ;
1314import 'package:zulip/model/narrow.dart' ;
1415import 'package:zulip/model/store.dart' ;
1516import 'package:zulip/model/typing_status.dart' ;
17+ import 'package:zulip/widgets/autocomplete.dart' ;
1618import 'package:zulip/widgets/compose_box.dart' ;
1719import 'package:zulip/widgets/content.dart' ;
1820import 'package:zulip/widgets/message_list.dart' ;
@@ -25,6 +27,8 @@ import '../model/test_store.dart';
2527import '../test_images.dart' ;
2628import 'test_app.dart' ;
2729
30+ late PerAccountStore store;
31+
2832/// Simulates loading a [MessageListPage] and tapping to focus the compose input.
2933///
3034/// Also adds [users] to the [PerAccountStore] ,
@@ -44,7 +48,7 @@ Future<Finder> setupToComposeInput(WidgetTester tester, {
4448
4549 addTearDown (testBinding.reset);
4650 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);
4852 await store.addUsers ([eg.selfUser, eg.otherUser]);
4953 await store.addUsers (users);
5054 final connection = store.connection as FakeApiConnection ;
@@ -202,6 +206,59 @@ void main() {
202206 debugNetworkImageHttpClientProvider = null ;
203207 });
204208
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+
205262 void checkWildcardShown (WildcardMentionOption wildcard, {required bool expected}) {
206263 check (find.text (wildcard.canonicalString)).findsExactly (expected ? 1 : 0 );
207264 }
0 commit comments