test: deflake the suite — pumpEventQueue instead of Future.delayed(Duration.zero)

~173 `await Future<void>.delayed(Duration.zero)` async-settle waits across 25
test files yield the microtask queue exactly once; when an event→handler chain
needs more than one hop they lose the race under CI's parallel load, so the
failing set varied run to run. Replace with `await pumpEventQueue()` (the
deterministic drain already used elsewhere in the suite); rewired the shared
settle()/tick() helpers in one shot. menu_bar's toggle-close test gets a bounded
extra pump. Verified green under CI=true.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-14 23:13:13 +02:00
co-authored by Claude Opus 4.8
parent 3dce5c614d
commit e55b4a9173
26 changed files with 175 additions and 174 deletions
@@ -287,7 +287,7 @@ void main() {
// Emit files.changed for a file at root level — parent is ''.
f.services.events.emit(DaemonEvent(subsystem: 'files', kind: 'files.changed', data: {'path': 'README.md'}, ts: DateTime.now().toUtc()));
// Give the async refresh a tick.
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
expect(lsCallCount, greaterThan(countAfterLoad));
});
@@ -305,7 +305,7 @@ void main() {
// 'lib' is not in _entries yet, so its parent 'lib/src' won't be there.
f.services.events.emit(DaemonEvent(subsystem: 'files', kind: 'files.changed', data: {'path': 'lib/src/foo.dart'}, ts: DateTime.now().toUtc()));
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
expect(lsCallCount, countAfterLoad);
});
@@ -322,7 +322,7 @@ void main() {
final countAfterLoad = lsCallCount;
f.services.events.emit(DaemonEvent(subsystem: 'editor', kind: 'files.changed', data: {'path': 'README.md'}, ts: DateTime.now().toUtc()));
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
expect(lsCallCount, countAfterLoad);
});
@@ -339,7 +339,7 @@ void main() {
final countAfterLoad = lsCallCount;
f.services.events.emit(DaemonEvent(subsystem: 'files', kind: 'files.opened', data: {'path': 'README.md'}, ts: DateTime.now().toUtc()));
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
expect(lsCallCount, countAfterLoad);
});
@@ -352,7 +352,7 @@ void main() {
final countAfterLoad = 1;
f.services.events.emit(DaemonEvent(subsystem: 'files', kind: 'files.changed', data: {'path': 'pubspec.yaml'}, ts: DateTime.now().toUtc()));
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
// Root '' is in _entries, so reload fires.
expect(countAfterLoad, 1); // just confirming test ran
@@ -364,7 +364,7 @@ void main() {
await c.load();
f.services.events.emit(DaemonEvent(subsystem: 'files', kind: 'files.changed', data: {'path': null}, ts: DateTime.now().toUtc()));
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
// No crash — just checking the null-path guard.
});
});
@@ -488,7 +488,7 @@ void main() {
c.dispose();
ctrl = null; // prevent tearDown from double-disposing
f.services.events.emit(DaemonEvent(subsystem: 'files', kind: 'files.changed', data: {'path': 'README.md'}, ts: DateTime.now().toUtc()));
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
// Test passes if no exception.
});
});