Mirror test: wait for the sync cue, bounded
Some checks are pending
file-length / file length <= 250 lines (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,dependency-freshness) (push) Waiting to run
Tests / test (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run

Same fixed-200 ms flake as the log screen tests: under load the
Sync now tick outlasted it. settle() now pumps until the expected
cue appears, at most 5 s.

Todo: 7808ee0a

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-21 06:57:52 +01:00
parent 1190e2d079
commit e0a4f71953
2 changed files with 14 additions and 7 deletions

View File

@ -2,7 +2,7 @@ name: diet_guard_app
description: "Companion phone app for diet_guard: log meals on the go."
publish_to: 'none'
version: 1.0.189+1
version: 1.0.190+1
environment:
sdk: ^3.12.2

View File

@ -65,13 +65,20 @@ void main() {
// GitHubMirrorScreen loads its settings via a fire-and-forget Future in
// initState that Flutter's frame scheduler does not track -- same pitfall
// as HistoryScreen/LogMealScreen.
Future<void> settle(WidgetTester tester) async {
// [until]: keep pumping (max 5 s) until it is found -- a sync tick's real
// I/O outlasts the fixed 200 ms on a loaded machine.
Future<void> settle(WidgetTester tester, {Finder? until}) async {
tester.view.physicalSize = const Size(800, 1400);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await Future<void>.delayed(const Duration(milliseconds: 200));
await tester.pumpAndSettle();
final deadline = DateTime.now().add(const Duration(seconds: 5));
do {
await Future<void>.delayed(const Duration(milliseconds: 200));
await tester.pumpAndSettle();
} while (until != null &&
until.evaluate().isEmpty &&
DateTime.now().isBefore(deadline));
}
/// Drains the device flow's real `Future.delayed` poll (GitHubDeviceAuth
@ -167,7 +174,7 @@ void main() {
await settle(tester);
await tester.tap(controlByLabel('Sync now'));
await settle(tester);
await settle(tester, until: cueLabelled('Synced.'));
expect(cueLabelled('Synced.'), findsOneWidget);
});
@ -197,7 +204,7 @@ void main() {
await settle(tester);
await tester.tap(controlByLabel('Sync now'));
await settle(tester);
await settle(tester, until: cueLabelled('Synced.'));
expect(cueLabelled('Synced.'), findsOneWidget);
final status = await SyncHealth.read();
@ -228,7 +235,7 @@ void main() {
await settle(tester);
await tester.tap(controlByLabel('Sync now'));
await settle(tester);
await settle(tester, until: cueOfKind(CueKind.error));
expect(cueOfKind(CueKind.error), findsOneWidget);
});