@@ -59,6 +59,7 @@ void main() {
59
59
bool foundOldest = true ,
60
60
int ? messageCount,
61
61
List <Message >? messages,
62
+ GetMessagesResult ? fetchResult,
62
63
List <ZulipStream >? streams,
63
64
List <User >? users,
64
65
List <Subscription >? subscriptions,
@@ -83,12 +84,17 @@ void main() {
83
84
// prepare message list data
84
85
await store.addUser (eg.selfUser);
85
86
await store.addUsers (users ?? []);
86
- assert ((messageCount == null ) != (messages == null ));
87
- messages ?? = List .generate (messageCount! , (index) {
88
- return eg.streamMessage (sender: eg.selfUser);
89
- });
90
- connection.prepare (json:
91
- eg.newestGetMessagesResult (foundOldest: foundOldest, messages: messages).toJson ());
87
+ if (fetchResult != null ) {
88
+ assert (foundOldest && messageCount == null && messages == null );
89
+ } else {
90
+ assert ((messageCount == null ) != (messages == null ));
91
+ messages ?? = List .generate (messageCount! , (index) {
92
+ return eg.streamMessage (sender: eg.selfUser);
93
+ });
94
+ fetchResult = eg.newestGetMessagesResult (
95
+ foundOldest: foundOldest, messages: messages);
96
+ }
97
+ connection.prepare (json: fetchResult.toJson ());
92
98
93
99
await tester.pumpWidget (TestZulipApp (accountId: selfAccount.id,
94
100
skipAssertAccountExists: skipAssertAccountExists,
@@ -692,6 +698,55 @@ void main() {
692
698
});
693
699
});
694
700
701
+ group ('markers at end of list' , () {
702
+ final findLoadingIndicator = find.byType (CircularProgressIndicator );
703
+
704
+ testWidgets ('spacer when have newest' , (tester) async {
705
+ final messages = List .generate (10 ,
706
+ (i) => eg.streamMessage (content: '<p>message $i </p>' ));
707
+ await setupMessageListPage (tester, narrow: CombinedFeedNarrow (),
708
+ fetchResult: eg.nearGetMessagesResult (anchor: messages.last.id,
709
+ foundOldest: true , foundNewest: true , messages: messages));
710
+ check (findMessageListScrollController (tester)! .position)
711
+ .extentAfter.equals (0 );
712
+
713
+ // There's no loading indicator.
714
+ check (findLoadingIndicator).findsNothing ();
715
+ // The last message is spaced above the bottom of the viewport.
716
+ check (tester.getRect (find.text ('message 9' )))
717
+ .bottom..isGreaterThan (400 )..isLessThan (570 );
718
+ });
719
+
720
+ testWidgets ('loading indicator displaces spacer etc.' , (tester) async {
721
+ await setupMessageListPage (tester, narrow: CombinedFeedNarrow (),
722
+ skipPumpAndSettle: true ,
723
+ fetchResult: eg.nearGetMessagesResult (anchor: 1000 ,
724
+ foundOldest: true , foundNewest: false ,
725
+ messages: List .generate (10 ,
726
+ (i) => eg.streamMessage (id: 100 + i, content: '<p>message $i </p>' ))));
727
+ await tester.pump ();
728
+
729
+ // The message list will immediately start fetching newer messages.
730
+ connection.prepare (json: eg.newerGetMessagesResult (
731
+ anchor: 109 , foundNewest: true , messages: List .generate (100 ,
732
+ (i) => eg.streamMessage (id: 110 + i))).toJson ());
733
+ await tester.pump (Duration (milliseconds: 10 ));
734
+ await tester.pump ();
735
+
736
+ // There's a loading indicator.
737
+ check (findLoadingIndicator).findsOne ();
738
+ // It's at the bottom.
739
+ check (findMessageListScrollController (tester)! .position)
740
+ .extentAfter.equals (0 );
741
+ final loadingIndicatorRect = tester.getRect (findLoadingIndicator);
742
+ check (loadingIndicatorRect).bottom.isGreaterThan (575 );
743
+ // The last message is shortly above it; no spacer or anything else.
744
+ check (tester.getRect (find.text ('message 9' )))
745
+ .bottom.isGreaterThan (loadingIndicatorRect.top - 36 ); // TODO where's this space going?
746
+ await tester.pumpAndSettle ();
747
+ });
748
+ });
749
+
695
750
group ('TypingStatusWidget' , () {
696
751
final users = [eg.selfUser, eg.otherUser, eg.thirdUser, eg.fourthUser];
697
752
final finder = find.descendant (
0 commit comments