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