~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>
70 lines
2.5 KiB
Dart
70 lines
2.5 KiB
Dart
/// T-197: EditorExtension opens the workspace editor split when a buffer
|
|
/// opens and collapses it when the last one closes.
|
|
///
|
|
/// The workspace renders its editor split off `arrangement.editorOpen`
|
|
/// (not the active tab), so the extension must flip that flag — otherwise
|
|
/// `editor.open` opens the buffer daemon-side but nothing appears over
|
|
/// the Claude pane.
|
|
library;
|
|
|
|
import 'package:clide/builtin/editor/src/extension.dart';
|
|
import 'package:clide/kernel/kernel.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import '../../helpers/kernel_fixture.dart';
|
|
|
|
void main() {
|
|
late KernelFixture f;
|
|
|
|
setUp(() async {
|
|
f = await KernelFixture.create();
|
|
f.services.extensions.register(EditorExtension());
|
|
await f.services.extensions.activate('builtin.editor');
|
|
});
|
|
tearDown(() => f.dispose());
|
|
|
|
void emitEditor(String kind, {String? id}) {
|
|
f.services.events.emit(DaemonEvent(subsystem: 'editor', kind: kind, data: {'id': id}, ts: DateTime.now().toUtc()));
|
|
}
|
|
|
|
test('contributes the editor.active workspace tab', () {
|
|
expect(f.services.panels.tabsFor(Slots.workspace).any((t) => t.id == 'editor.active'), isTrue);
|
|
});
|
|
|
|
test('editor.opened opens the editor split', () async {
|
|
expect(f.services.arrangement.editorOpen, isFalse);
|
|
emitEditor('editor.opened', id: 'b_1');
|
|
await pumpEventQueue();
|
|
expect(f.services.arrangement.editorOpen, isTrue);
|
|
});
|
|
|
|
test('editor.active-changed with a buffer keeps the split open', () async {
|
|
emitEditor('editor.active-changed', id: 'b_2');
|
|
await pumpEventQueue();
|
|
expect(f.services.arrangement.editorOpen, isTrue);
|
|
});
|
|
|
|
test('editor.active-changed with a null id collapses the split', () async {
|
|
emitEditor('editor.opened', id: 'b_1');
|
|
await pumpEventQueue();
|
|
expect(f.services.arrangement.editorOpen, isTrue);
|
|
|
|
emitEditor('editor.active-changed', id: null);
|
|
await pumpEventQueue();
|
|
expect(f.services.arrangement.editorOpen, isFalse);
|
|
});
|
|
|
|
test('a non-editor event does not open the split', () async {
|
|
f.services.events.emit(DaemonEvent(subsystem: 'git', kind: 'changed', data: const {}, ts: DateTime.now().toUtc()));
|
|
await pumpEventQueue();
|
|
expect(f.services.arrangement.editorOpen, isFalse);
|
|
});
|
|
|
|
test('after deactivate, editor events no longer open the split', () async {
|
|
await f.services.extensions.deactivate('builtin.editor');
|
|
emitEditor('editor.opened', id: 'b_9');
|
|
await pumpEventQueue();
|
|
expect(f.services.arrangement.editorOpen, isFalse);
|
|
});
|
|
}
|