@@ -55,6 +55,7 @@ void main() {
55
55
bool foundOldest = true ,
56
56
int ? messageCount,
57
57
List <Message >? messages,
58
+ GetMessagesResult ? fetchResult,
58
59
List <ZulipStream >? streams,
59
60
List <User >? users,
60
61
List <Subscription >? subscriptions,
@@ -79,12 +80,17 @@ void main() {
79
80
// prepare message list data
80
81
await store.addUser (eg.selfUser);
81
82
await store.addUsers (users ?? []);
82
- assert ((messageCount == null ) != (messages == null ));
83
- messages ?? = List .generate (messageCount! , (index) {
84
- return eg.streamMessage (sender: eg.selfUser);
85
- });
86
- connection.prepare (json:
87
- eg.newestGetMessagesResult (foundOldest: foundOldest, messages: messages).toJson ());
83
+ if (fetchResult != null ) {
84
+ assert (foundOldest && messageCount == null && messages == null );
85
+ } else {
86
+ assert ((messageCount == null ) != (messages == null ));
87
+ messages ?? = List .generate (messageCount! , (index) {
88
+ return eg.streamMessage (sender: eg.selfUser);
89
+ });
90
+ fetchResult = eg.newestGetMessagesResult (
91
+ foundOldest: foundOldest, messages: messages);
92
+ }
93
+ connection.prepare (json: fetchResult.toJson ());
88
94
89
95
await tester.pumpWidget (TestZulipApp (accountId: selfAccount.id,
90
96
skipAssertAccountExists: skipAssertAccountExists,
@@ -620,6 +626,55 @@ void main() {
620
626
});
621
627
});
622
628
629
+ group ('markers at end of list' , () {
630
+ final findLoadingIndicator = find.byType (CircularProgressIndicator );
631
+
632
+ testWidgets ('spacer when have newest' , (tester) async {
633
+ final messages = List .generate (10 ,
634
+ (i) => eg.streamMessage (content: '<p>message $i </p>' ));
635
+ await setupMessageListPage (tester, narrow: CombinedFeedNarrow (),
636
+ fetchResult: eg.nearGetMessagesResult (anchor: messages.last.id,
637
+ foundOldest: true , foundNewest: true , messages: messages));
638
+ check (findMessageListScrollController (tester)! .position)
639
+ .extentAfter.equals (0 );
640
+
641
+ // There's no loading indicator.
642
+ check (findLoadingIndicator).findsNothing ();
643
+ // The last message is spaced above the bottom of the viewport.
644
+ check (tester.getRect (find.text ('message 9' )))
645
+ .bottom..isGreaterThan (400 )..isLessThan (570 );
646
+ });
647
+
648
+ testWidgets ('loading indicator displaces spacer etc.' , (tester) async {
649
+ await setupMessageListPage (tester, narrow: CombinedFeedNarrow (),
650
+ skipPumpAndSettle: true ,
651
+ fetchResult: eg.nearGetMessagesResult (anchor: 1000 ,
652
+ foundOldest: true , foundNewest: false ,
653
+ messages: List .generate (10 ,
654
+ (i) => eg.streamMessage (id: 100 + i, content: '<p>message $i </p>' ))));
655
+ await tester.pump ();
656
+
657
+ // The message list will immediately start fetching newer messages.
658
+ connection.prepare (json: eg.newerGetMessagesResult (
659
+ anchor: 109 , foundNewest: true , messages: List .generate (100 ,
660
+ (i) => eg.streamMessage (id: 110 + i))).toJson ());
661
+ await tester.pump (Duration (milliseconds: 10 ));
662
+ await tester.pump ();
663
+
664
+ // There's a loading indicator.
665
+ check (findLoadingIndicator).findsOne ();
666
+ // It's at the bottom.
667
+ check (findMessageListScrollController (tester)! .position)
668
+ .extentAfter.equals (0 );
669
+ final loadingIndicatorRect = tester.getRect (findLoadingIndicator);
670
+ check (loadingIndicatorRect).bottom.isGreaterThan (575 );
671
+ // The last message is shortly above it; no spacer or anything else.
672
+ check (tester.getRect (find.text ('message 9' )))
673
+ .bottom.isGreaterThan (loadingIndicatorRect.top - 36 ); // TODO where's this space going?
674
+ await tester.pumpAndSettle ();
675
+ });
676
+ });
677
+
623
678
group ('TypingStatusWidget' , () {
624
679
final users = [eg.selfUser, eg.otherUser, eg.thirdUser, eg.fourthUser];
625
680
final finder = find.descendant (
0 commit comments