@@ -177,6 +177,38 @@ void main() {
177
177
178
178
debugNetworkImageHttpClientProvider = null ;
179
179
});
180
+
181
+ testWidgets ('options are shown in reversed order' , (tester) async {
182
+ final users = List .generate (8 , (i) => eg.user (fullName: 'A$i ' , avatarUrl: 'user$i .png' ));
183
+ final composeInputFinder = await setupToComposeInput (tester, users: users);
184
+ final store = await testBinding.globalStore.perAccount (eg.selfAccount.id);
185
+
186
+ // TODO(#226): Remove this extra edit when this bug is fixed.
187
+ await tester.enterText (composeInputFinder, 'hello @' );
188
+ await tester.enterText (composeInputFinder, 'hello @A' );
189
+ await tester.pump ();
190
+ // Add an extra pump to account for any potential frame delays introduced
191
+ // by the post frame callback in RawAutocomplete's implementation.
192
+ await tester.pump ();
193
+ final initialPosition = tester.getTopLeft (find.text (users.first.fullName)).dy;
194
+ // Initially, all but the last autocomplete options are visible.
195
+ checkUserShown (users.last, store, expected: false );
196
+ users.take (7 ).forEach ((user) => checkUserShown (user, store, expected: true ));
197
+
198
+ // Can't scroll down because the options grow from the bottom.
199
+ await tester.drag (find.byType (ListView ), const Offset (0 , - 50 ));
200
+ await tester.pump ();
201
+ check (tester.getTopLeft (find.text (users.first.fullName)).dy)
202
+ .equals (initialPosition);
203
+
204
+ // The last autocomplete option becomes visible after scrolling up.
205
+ await tester.drag (find.byType (ListView ), const Offset (0 , 200 ));
206
+ await tester.pump ();
207
+ users.skip (1 ).forEach ((user) => checkUserShown (user, store, expected: true ));
208
+ checkUserShown (users.first, store, expected: false );
209
+
210
+ debugNetworkImageHttpClientProvider = null ;
211
+ });
180
212
});
181
213
182
214
group ('emoji' , () {
@@ -250,6 +282,66 @@ void main() {
250
282
debugNetworkImageHttpClientProvider = null ;
251
283
});
252
284
285
+ testWidgets ('emoji options appear in the reverse order and do not scroll down' , (tester) async {
286
+ final composeInputFinder = await setupToComposeInput (tester);
287
+ final store = await testBinding.globalStore.perAccount (eg.selfAccount.id);
288
+
289
+ store.setServerEmojiData (
290
+ ServerEmojiData (
291
+ codeToNames: {
292
+ '1f4a4' : ['zzz' ], // Unicode emoji for "zzz"
293
+ '1f52a' : ['biohazard' ],
294
+ '1f92a' : ['zany_face' ],
295
+ '1f993' : ['zebra' ],
296
+ '0030-fe0f-20e3' : ['zero' ],
297
+ '1f9d0' : ['zombie' ],
298
+ }));
299
+
300
+ await store.handleEvent (
301
+ RealmEmojiUpdateEvent (
302
+ id: 1 ,
303
+ realmEmoji: {
304
+ '1' : eg.realmEmojiItem (emojiCode: '1' , emojiName: 'buzzing' )}));
305
+
306
+ final emojiNames = ['zulip' , 'zany_face' , 'zebra' , '💤' , 'zombie' , 'zero' , 'buzzing' , 'zzz' , 'biohazard' ];
307
+
308
+ // Enter a query; options appear, of all three emoji types.
309
+ // TODO(#226): Remove this extra edit when this bug is fixed.
310
+ await tester.enterText (composeInputFinder, 'hi :' );
311
+ await tester.enterText (composeInputFinder, 'hi :z' );
312
+ await tester.pump ();
313
+ // Add an extra pump to account for any potential frame delays introduced
314
+ // by the post frame callback in RawAutocomplete's implementation.
315
+ await tester.pump ();
316
+
317
+ final firstEmojiInitialPosition = tester.getTopLeft (find.text (emojiNames[0 ])).dy;
318
+ final listViewFinder = find.byType (ListView );
319
+
320
+ emojiNames.take (8 ).forEach ((emojiName) => check (find.text (emojiName)).findsOne ());
321
+ check (find.text (emojiNames.last)).findsNothing ();
322
+
323
+ await tester.drag (listViewFinder, const Offset (0 , - 50 ));
324
+ await tester.pump ();
325
+ final firstEmojiPositionAfterScrollDown = tester.getTopLeft (find.text (emojiNames[0 ])).dy;
326
+ check (
327
+ because: "ListView options should not scroll down further than initial position" ,
328
+ firstEmojiInitialPosition,
329
+ ).equals (firstEmojiPositionAfterScrollDown);
330
+
331
+ check (
332
+ because: "The last emoji should not be visible before scrolling up" ,
333
+ find.text (emojiNames.last),
334
+ ).findsNothing ();
335
+
336
+ await tester.drag (listViewFinder, const Offset (0 , 50 ));
337
+ await tester.pump ();
338
+
339
+ check (because: "The last emoji should be visible after scrolling up" ,
340
+ find.text (emojiNames.last)).findsOne ();
341
+
342
+ debugNetworkImageHttpClientProvider = null ;
343
+ });
344
+
253
345
testWidgets ('text emoji means just show text' , (tester) async {
254
346
final composeInputFinder = await setupToComposeInput (tester);
255
347
final store = await testBinding.globalStore.perAccount (eg.selfAccount.id);
0 commit comments