Skip to content

msglist test: Make double-fetch-glitch test robust to layout changes #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions test/widgets/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,15 @@ void main() {
// ... and we fetch more messages as we go.
connection.prepare(json: olderResult(anchor: 950, foundOldest: false,
messages: List.generate(100, (i) => eg.streamMessage(id: 850 + i, sender: eg.selfUser))).toJson());
await tester.pump(const Duration(milliseconds: 500));
await tester.pump(Duration.zero);
for (int i = 0; i < 30; i++) {
// Find the point in the fling where the fetch starts.
await tester.pump(const Duration(milliseconds: 100));
if (itemCount(tester)! > 100) break; // The loading indicator appeared.
}
await tester.pump(Duration.zero); // Allow a frame for the response to arrive.
check(itemCount(tester)).equals(200);

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