@@ -51,6 +51,21 @@ void main() {
51
51
await tester.pumpAndSettle ();
52
52
}
53
53
54
+ List <StreamMessage > generateStreamMessages (
55
+ ZulipStream stream,
56
+ int count,
57
+ ) {
58
+ return List .generate (
59
+ count,
60
+ (index) {
61
+ return eg.streamMessage (
62
+ stream: stream,
63
+ topic: '${stream .name } topic $index ' ,
64
+ );
65
+ },
66
+ );
67
+ }
68
+
54
69
/// Set up an inbox view with lots of interesting content.
55
70
Future <void > setupVarious (WidgetTester tester) async {
56
71
final stream1 = eg.stream (streamId: 1 , name: 'stream 1' );
@@ -64,7 +79,9 @@ void main() {
64
79
users: [eg.selfUser, eg.otherUser, eg.thirdUser],
65
80
unreadMessages: [
66
81
eg.streamMessage (stream: stream1, topic: 'specific topic' , flags: []),
82
+ ...generateStreamMessages (stream1, 10 ),
67
83
eg.streamMessage (stream: stream2, flags: []),
84
+ ...generateStreamMessages (stream2, 40 ),
68
85
eg.dmMessage (from: eg.otherUser, to: [eg.selfUser], flags: []),
69
86
eg.dmMessage (from: eg.otherUser, to: [eg.selfUser, eg.thirdUser], flags: []),
70
87
]);
@@ -310,6 +327,30 @@ void main() {
310
327
checkAppearsUncollapsed (tester, findSectionContent);
311
328
});
312
329
330
+ testWidgets ('collapse all-DMs section after scroll' , (tester) async {
331
+ await setupVarious (tester);
332
+
333
+ final listFinder = find.byType (Scrollable );
334
+ // Scroll the [StickyHeaderListView] enough so that
335
+ // the [_AllDmsSection] shows a sticky header
336
+ await tester.drag (listFinder, const Offset (0 , - 50 ));
337
+
338
+ final headerRow = findAllDmsHeaderRow (tester);
339
+ // Check that the sticky header is present
340
+ check (headerRow).isNotNull ();
341
+
342
+ final findSectionContent = find.text (eg.otherUser.fullName);
343
+
344
+ checkAppearsUncollapsed (tester, findSectionContent);
345
+ await tapCollapseIcon (tester);
346
+ // Check that the header is still visible even after
347
+ // collapsing the section
348
+ check (headerRow).isNotNull ();
349
+ checkAppearsCollapsed (tester, findSectionContent);
350
+ await tapCollapseIcon (tester);
351
+ checkAppearsUncollapsed (tester, findSectionContent);
352
+ });
353
+
313
354
// TODO check it remains collapsed even if you scroll far away and back
314
355
315
356
// TODO check that it's always uncollapsed when it appears after being
@@ -385,6 +426,30 @@ void main() {
385
426
checkAppearsUncollapsed (tester, 1 , findSectionContent);
386
427
});
387
428
429
+ testWidgets ('collapse stream section after scroll' , (tester) async {
430
+ await setupVarious (tester);
431
+
432
+ final listFinder = find.byType (Scrollable );
433
+ // Scroll the [StickyHeaderListView] enough so that
434
+ // the [_StreamSection] shows a sticky header
435
+ await tester.drag (listFinder, const Offset (0 , - 200 ));
436
+
437
+ final headerRow = findStreamHeaderRow (tester, 1 );
438
+ // Check that the sticky header is present
439
+ check (headerRow).isNotNull ();
440
+
441
+ final findSectionContent = find.text ('specific topic' );
442
+
443
+ checkAppearsUncollapsed (tester, 1 , findSectionContent);
444
+ await tapCollapseIcon (tester, 1 );
445
+ // Check that the header is still visible even after
446
+ // collapsing the section
447
+ check (headerRow).isNotNull ();
448
+ checkAppearsCollapsed (tester, 1 , findSectionContent);
449
+ await tapCollapseIcon (tester, 1 );
450
+ checkAppearsUncollapsed (tester, 1 , findSectionContent);
451
+ });
452
+
388
453
// TODO check it remains collapsed even if you scroll far away and back
389
454
390
455
// TODO check that it's always uncollapsed when it appears after being
0 commit comments