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
+4 -4
View File
@@ -12,7 +12,7 @@ void main() {
final events = <ClideEventEnvelope>[];
final sub = bus.stream.listen(events.add);
bus.emit(const ThemeChanged(themeName: 'summer-night'));
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
expect(events, hasLength(1));
expect(events.first.event, isA<ThemeChanged>());
await sub.cancel();
@@ -26,7 +26,7 @@ void main() {
bus.emit(const ThemeChanged(themeName: 'a'));
bus.emit(const ExtensionActivated(id: 'builtin.git'));
bus.emit(const ThemeChanged(themeName: 'b'));
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
expect(themes.map((e) => e.themeName), ['a', 'b']);
expect(extensions.map((e) => e.id), ['builtin.git']);
await s1.cancel();
@@ -39,7 +39,7 @@ void main() {
final s1 = bus.stream.listen((e) => a.add(e.event));
final s2 = bus.stream.listen((e) => b.add(e.event));
bus.emit(const ThemeChanged(themeName: 'x'));
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
expect(a, hasLength(1));
expect(b, hasLength(1));
await s1.cancel();
@@ -57,7 +57,7 @@ void main() {
final sub = bus.stream.listen(capture.add);
final before = DateTime.now().toUtc();
bus.emit(const ThemeChanged(themeName: 'n'));
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
final after = DateTime.now().toUtc();
expect(capture, hasLength(1));
final ts = capture.first.timestamp;
+4 -4
View File
@@ -30,7 +30,7 @@ void main() {
final received = <Message>[];
final sub = bus.subscribe().listen(received.add);
bus.publish('git', 'status-changed', {'dirty': true});
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
expect(received, hasLength(1));
expect(received.first.publisher, 'git');
expect(received.first.channel, 'status-changed');
@@ -44,7 +44,7 @@ void main() {
bus.publish('git', 'a', const {});
bus.publish('pty', 'a', const {});
bus.publish('git', 'b', const {});
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
expect(got.map((m) => m.channel), ['a', 'b']);
await sub.cancel();
});
@@ -55,7 +55,7 @@ void main() {
bus.publish('pty', 'output', const {});
bus.publish('pty', 'exit', const {});
bus.publish('git', 'output', const {});
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
expect(got.map((m) => m.publisher), ['pty', 'git']);
await sub.cancel();
});
@@ -66,7 +66,7 @@ void main() {
bus.publish('git', 'status', const {});
bus.publish('git', 'other', const {});
bus.publish('pty', 'status', const {});
await Future<void>.delayed(Duration.zero);
await pumpEventQueue();
expect(got, hasLength(1));
await sub.cancel();
});