Skip to content

Commit 8831c2d

Browse files
gnpricechrisbobbe
authored andcommitted
msglist test: Make double-fetch-glitch test robust to layout changes
Since adding this test, we've repeatedly seen it break upon changes that affect how tall the messages are: https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20double-fetch.20glitch.20gone.3F/near/1631114 In particular, the length of this pump for the fling-scroll has needed adjustments. Automate that by just finding out empirically how far is far enough to trigger the fetch, and proceeding from there.
1 parent 7b08ab3 commit 8831c2d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/widgets/message_list_test.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,15 @@ void main() {
9797
// ... and we fetch more messages as we go.
9898
connection.prepare(json: olderResult(anchor: 950, foundOldest: false,
9999
messages: List.generate(100, (i) => eg.streamMessage(id: 850 + i, sender: eg.selfUser))).toJson());
100-
await tester.pump(const Duration(milliseconds: 500));
101-
await tester.pump(Duration.zero);
100+
for (int i = 0; i < 30; i++) {
101+
// Find the point in the fling where the fetch starts.
102+
await tester.pump(const Duration(milliseconds: 100));
103+
if (itemCount(tester)! > 100) break; // The loading indicator appeared.
104+
}
105+
await tester.pump(Duration.zero); // Allow a frame for the response to arrive.
102106
check(itemCount(tester)).equals(200);
103107

104-
// But on the next frame, we promptly fetch *another* batch.
108+
// On the next frame, we promptly fetch *another* batch.
105109
// This is a glitch and it'd be nicer if we didn't.
106110
connection.prepare(json: olderResult(anchor: 850, foundOldest: false,
107111
messages: List.generate(100, (i) => eg.streamMessage(id: 750 + i, sender: eg.selfUser))).toJson());

0 commit comments

Comments
 (0)