add e2e testing (#167)

Reviewed-on: #167
This commit is contained in:
Henry Hiles 2026-11-10 18:29:02 -05:00 • committed by Henry Hiles
commit af99de75da

View file

@ -0,0 +1,34 @@
import "package:flutter_test/flutter_test.dart";
import "package:material_ui/material_ui.dart";
import "pump_until.dart";
extension MessageFinders on CommonFinders {
Finder message(String body) => textContaining(body, findRichText: true);
}
extension RelativeFinders on Finder {
Finder inside(Type type) =>
find.descendant(of: find.byType(type), matching: this);
/// The [InkWell] ancestor around what this finds
Finder get inkWell => find.ancestor(of: this, matching: find.byType(InkWell));
}
extension ReplyCounts on WidgetTester {
/// Waits for a reply count in widgets of [type], then checks it, so a wrong
/// count fails straight away with what was shown.
Future<void> expectReplyCount(Type type, int expected) async {
final repliesLabel = RegExp(r"^(\d+) repl(?:y|ies)$");
final labels = find.textContaining(repliesLabel).inside(type);
await pumpUntil(labels);
final shown = widgetList<Text>(labels)
.map((label) => label.data)
.nonNulls
.map(repliesLabel.firstMatch)
.nonNulls
.map((match) => int.parse(match[1]!));
expect(shown, everyElement(expected), reason: "Reply count in $type");
}
}