@@ -58,6 +58,7 @@ void main() {
58
58
bool foundOldest = true ,
59
59
int ? messageCount,
60
60
List <Message >? messages,
61
+ GetMessagesResult ? fetchResult,
61
62
List <ZulipStream >? streams,
62
63
List <User >? users,
63
64
List <Subscription >? subscriptions,
@@ -82,12 +83,17 @@ void main() {
82
83
// prepare message list data
83
84
await store.addUser (eg.selfUser);
84
85
await store.addUsers (users ?? []);
85
- assert ((messageCount == null ) != (messages == null ));
86
- messages ?? = List .generate (messageCount! , (index) {
87
- return eg.streamMessage (sender: eg.selfUser);
88
- });
89
- connection.prepare (json:
90
- eg.newestGetMessagesResult (foundOldest: foundOldest, messages: messages).toJson ());
86
+ if (fetchResult != null ) {
87
+ assert (foundOldest && messageCount == null && messages == null );
88
+ } else {
89
+ assert ((messageCount == null ) != (messages == null ));
90
+ messages ?? = List .generate (messageCount! , (index) {
91
+ return eg.streamMessage (sender: eg.selfUser);
92
+ });
93
+ fetchResult = eg.newestGetMessagesResult (
94
+ foundOldest: foundOldest, messages: messages);
95
+ }
96
+ connection.prepare (json: fetchResult.toJson ());
91
97
92
98
await tester.pumpWidget (TestZulipApp (accountId: selfAccount.id,
93
99
skipAssertAccountExists: skipAssertAccountExists,
@@ -661,6 +667,55 @@ void main() {
661
667
});
662
668
});
663
669
670
+ group ('markers at end of list' , () {
671
+ final findLoadingIndicator = find.byType (CircularProgressIndicator );
672
+
673
+ testWidgets ('spacer when have newest' , (tester) async {
674
+ final messages = List .generate (10 ,
675
+ (i) => eg.streamMessage (content: '<p>message $i </p>' ));
676
+ await setupMessageListPage (tester, narrow: CombinedFeedNarrow (),
677
+ fetchResult: eg.nearGetMessagesResult (anchor: messages.last.id,
678
+ foundOldest: true , foundNewest: true , messages: messages));
679
+ check (findMessageListScrollController (tester)! .position)
680
+ .extentAfter.equals (0 );
681
+
682
+ // There's no loading indicator.
683
+ check (findLoadingIndicator).findsNothing ();
684
+ // The last message is spaced above the bottom of the viewport.
685
+ check (tester.getRect (find.text ('message 9' )))
686
+ .bottom..isGreaterThan (400 )..isLessThan (570 );
687
+ });
688
+
689
+ testWidgets ('loading indicator displaces spacer etc.' , (tester) async {
690
+ await setupMessageListPage (tester, narrow: CombinedFeedNarrow (),
691
+ skipPumpAndSettle: true ,
692
+ fetchResult: eg.nearGetMessagesResult (anchor: 1000 ,
693
+ foundOldest: true , foundNewest: false ,
694
+ messages: List .generate (10 ,
695
+ (i) => eg.streamMessage (id: 100 + i, content: '<p>message $i </p>' ))));
696
+ await tester.pump ();
697
+
698
+ // The message list will immediately start fetching newer messages.
699
+ connection.prepare (json: eg.newerGetMessagesResult (
700
+ anchor: 109 , foundNewest: true , messages: List .generate (100 ,
701
+ (i) => eg.streamMessage (id: 110 + i))).toJson ());
702
+ await tester.pump (Duration (milliseconds: 10 ));
703
+ await tester.pump ();
704
+
705
+ // There's a loading indicator.
706
+ check (findLoadingIndicator).findsOne ();
707
+ // It's at the bottom.
708
+ check (findMessageListScrollController (tester)! .position)
709
+ .extentAfter.equals (0 );
710
+ final loadingIndicatorRect = tester.getRect (findLoadingIndicator);
711
+ check (loadingIndicatorRect).bottom.isGreaterThan (575 );
712
+ // The last message is shortly above it; no spacer or anything else.
713
+ check (tester.getRect (find.text ('message 9' )))
714
+ .bottom.isGreaterThan (loadingIndicatorRect.top - 36 ); // TODO where's this space going?
715
+ await tester.pumpAndSettle ();
716
+ });
717
+ });
718
+
664
719
group ('TypingStatusWidget' , () {
665
720
final users = [eg.selfUser, eg.otherUser, eg.thirdUser, eg.fourthUser];
666
721
final finder = find.descendant (
0 commit comments