@@ -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,55 @@ 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.widget <UserStatusEmoji >(statusEmojiFinder)
215+ .neverAnimate).isTrue ();
216+ check (find.ancestor (of: statusEmojiFinder,
217+ matching: find.byType (MentionAutocompleteItem ))).findsOne ();
218+ }
219+
220+ testWidgets ('emoji & text are set -> emoji is displayed, text is not' , (tester) async {
221+ final user = eg.user (fullName: 'User' );
222+ final composeInputFinder = await setupToComposeInput (tester, users: [user]);
223+ await store.changeUserStatus (user.userId, UserStatusChange (
224+ text: OptionSome ('Busy' ),
225+ emoji: OptionSome (StatusEmoji (emojiName: 'working_on_it' ,
226+ emojiCode: '1f6e0' , reactionType: ReactionType .unicodeEmoji))));
227+ await tester.pump ();
228+
229+ // // TODO(#226): Remove this extra edit when this bug is fixed.
230+ await tester.enterText (composeInputFinder, 'hello @u' );
231+ await tester.enterText (composeInputFinder, 'hello @' );
232+ await tester.pumpAndSettle (); // async computation; options appear
233+
234+ checkFindsStatusEmoji (tester, find.text ('\u {1f6e0}' ));
235+ check (find.textContaining ('Busy' )).findsNothing ();
236+
237+ debugNetworkImageHttpClientProvider = null ;
238+ });
239+
240+ testWidgets ('emoji is not set, text is set -> text is not displayed' , (tester) async {
241+ final user = eg.user (fullName: 'User' );
242+ final composeInputFinder = await setupToComposeInput (tester, users: [user]);
243+ await store.changeUserStatus (user.userId, UserStatusChange (
244+ text: OptionSome ('Busy' ), emoji: OptionNone ()));
245+ await tester.pump ();
246+
247+ // // TODO(#226): Remove this extra edit when this bug is fixed.
248+ await tester.enterText (composeInputFinder, 'hello @u' );
249+ await tester.enterText (composeInputFinder, 'hello @' );
250+ await tester.pumpAndSettle (); // async computation; options appear
251+
252+ check (find.textContaining ('Busy' )).findsNothing ();
253+
254+ debugNetworkImageHttpClientProvider = null ;
255+ });
256+ });
257+
205258 void checkWildcardShown (WildcardMentionOption wildcard, {required bool expected}) {
206259 check (find.text (wildcard.canonicalString)).findsExactly (expected ? 1 : 0 );
207260 }
0 commit comments