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 <noreply@anthropic.com>
pull/1188/head
diffwireauto 1 week ago committed by Strycher
parent 8d11346efd
commit 7d2c32f699

@ -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<void> 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<void>.delayed(const Duration(milliseconds: 50)),
() => Future<void>.delayed(const Duration(milliseconds: 20)),
);
await tester.pump(const Duration(seconds: 4));
}
await tester.runAsync(
() => Future<void>.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(

Loading…
Cancel
Save

Powered by TurnKey Linux.