@@ -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,55 @@ 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.widget <UserStatusEmoji >(statusEmojiFinder)
215
+ .neverAnimate).isTrue ();
216
+ check (find.ancestor (of: statusEmojiFinder,
217
+ matching: find.byType (MentionAutocompleteItem ))).findsOne ();
218
+ }
219
+
220
+ testWidgets ('status 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.text ('Busy' )).findsNothing ();
236
+
237
+ debugNetworkImageHttpClientProvider = null ;
238
+ });
239
+
240
+ testWidgets ('status 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.text ('Busy' )).findsNothing ();
253
+
254
+ debugNetworkImageHttpClientProvider = null ;
255
+ });
256
+ });
257
+
205
258
void checkWildcardShown (WildcardMentionOption wildcard, {required bool expected}) {
206
259
check (find.text (wildcard.canonicalString)).findsExactly (expected ? 1 : 0 );
207
260
}
0 commit comments