From 7d2c32f699e74c93bded995681346d008cda9779 Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Thu, 19 Nov 2026 03:23:33 -0500 Subject: [PATCH] test(#1157): wait for the contact update frame, not a fixed delay Epic #1155. The save-path test from 31eed712 waited a fixed 50 ms of real time and failed once in a full parallel suite run. It now waits for the update frame itself, advancing the fake 3 s re-read timeout as it goes, bounded, and fails with a reason if the frame never comes. Since the change: 41 of 42 runs pass (20 sequential, 12 sequential, 4 in parallel, 5 sequential, 1 full suite). The one failure was the first run straight after editing and its cause is not established. Agent: BrightForge (session 440fbe94) Co-Authored-By: Claude Opus 5.5 --- .../contact_settings_remote_cli_test.dart | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test/widgets/contact_settings_remote_cli_test.dart b/test/widgets/contact_settings_remote_cli_test.dart index 728a43ae..e1998a50 100644 --- a/test/widgets/contact_settings_remote_cli_test.dart +++ b/test/widgets/contact_settings_remote_cli_test.dart @@ -81,24 +81,31 @@ void main() { contact = makeContact(); }); + bool isUpdateFrame(Uint8List f) => + f.isNotEmpty && f[0] == updateFrame(contact, 0)[0]; + /// Tap Close, then let the connector's 3 s contact re-read time out so it /// falls back to [contact] and writes the update frame. Future closeAndSave(WidgetTester tester) async { sent.clear(); await tester.tap(find.text('Close')); await tester.pump(); - // sendFrame completes on real async work the fake clock does not run, so - // let real time pass on both sides of advancing the fake 3 s timeout. - for (var i = 0; i < 2; i++) { + // The save chain finishes on real async work the fake clock does not run, + // and how long that takes depends on load. Wait for the update frame + // itself, advancing the fake 3 s re-read timeout as we go, and fail loudly + // if it never comes rather than asserting on a half-finished save. + for (var i = 0; i < 200 && !sent.any(isUpdateFrame); i++) { await tester.runAsync( - () => Future.delayed(const Duration(milliseconds: 50)), + () => Future.delayed(const Duration(milliseconds: 20)), ); await tester.pump(const Duration(seconds: 4)); } - await tester.runAsync( - () => Future.delayed(const Duration(milliseconds: 50)), - ); await tester.pumpAndSettle(); + expect( + sent.any(isUpdateFrame), + isTrue, + reason: 'Close never wrote a contact update frame', + ); } bool wrote(Uint8List frame) => sent.any(