test sweep: cover src/editor/ tail paths (T-91)
test / unit + widget + golden + a11y (push) Failing after 33s
test / integration_test (xvfb) (push) Has been skipped
test / bundle smoke (xvfb 5s) (push) Has been skipped
test / daemon subprocess + web WASM smoke (push) Has been skipped
test / dart doc (lib API) (push) Failing after 1m2s
test / unit + widget + golden + a11y (push) Failing after 33s
test / integration_test (xvfb) (push) Has been skipped
test / bundle smoke (xvfb 5s) (push) Has been skipped
test / daemon subprocess + web WASM smoke (push) Has been skipped
test / dart doc (lib API) (push) Failing after 1m2s
Adds 6 tests in test/editor/registry_test.dart closing out the EditorRegistry methods the existing suite didn't reach: - activate(id): unknown id is a no-op (no event emitted); known id flips the active buffer and emits editor.active-changed. - setContent(id, content, selection?): explicit selection clamped to new content length, missing selection falls back to clamping the existing one, missing id is a silent no-op. Each emits the editor.edited replace event. - contentFromArgs(args): the content_b64 fallback when text is absent, plus the empty-args default. - Selection.hashCode + .toString. Coverage: src/editor/buffer.dart 20/24 -> 24/24; src/editor/registry .dart 87/105 -> 105/105. Both at 100%. Total coverage 74.79% -> 75.11%; floor bumped to 75. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@ repository: https://github.com/postmeridiem/clide
|
||||
|
||||
# Pre-push line-coverage floor. Ratchets up only — see D-66.
|
||||
# Reading: `awk -F: '/^coverage_floor:/ {gsub(/ /,"",$2); print $2}' pubspec.yaml`.
|
||||
coverage_floor: 74
|
||||
coverage_floor: 75
|
||||
|
||||
# Project metadata (was project.yaml, folded in per D-056).
|
||||
# version: above is the single source of truth. The Makefile reads
|
||||
|
||||
@@ -93,4 +93,62 @@ void main() {
|
||||
expect(buf.content, isEmpty);
|
||||
expect(buf.dirty, isFalse);
|
||||
});
|
||||
|
||||
test('activate(unknown id) is a no-op; activate(known) flips the active buffer', () async {
|
||||
final a = await reg.open('README.md');
|
||||
final b = await reg.open('NEW.md');
|
||||
// b is currently active.
|
||||
expect(reg.active, same(b));
|
||||
sink.events.clear();
|
||||
reg.activate('does-not-exist'); // no-op, no emit
|
||||
expect(sink.ofKind('editor.active-changed'), isEmpty);
|
||||
reg.activate(a.id);
|
||||
expect(reg.active, same(a));
|
||||
expect(sink.ofKind('editor.active-changed'), hasLength(1));
|
||||
});
|
||||
|
||||
test('setContent with explicit selection clamps + emits editor.edited replace', () async {
|
||||
final buf = await reg.open('README.md');
|
||||
sink.events.clear();
|
||||
reg.setContent(buf.id, 'short', selection: const Selection(start: 1, end: 99));
|
||||
expect(buf.content, 'short');
|
||||
// 99 clamped to content.length (5).
|
||||
expect(buf.selection.end, 5);
|
||||
expect(buf.dirty, isTrue);
|
||||
final emitted = sink.ofKind('editor.edited').single;
|
||||
expect(emitted.data['kind'], 'replace');
|
||||
expect(emitted.data['length'], 5);
|
||||
});
|
||||
|
||||
test('setContent without selection clamps the existing selection to the new content', () async {
|
||||
final buf = await reg.open('README.md');
|
||||
reg.setSelection(buf.id, const Selection(start: 6, end: 8));
|
||||
expect(buf.selection.start, 6);
|
||||
reg.setContent(buf.id, 'XY'); // shorter than the selection's offsets
|
||||
expect(buf.content, 'XY');
|
||||
expect(buf.selection.start, 2);
|
||||
expect(buf.selection.end, 2);
|
||||
});
|
||||
|
||||
test('setContent on a missing id is a silent no-op', () {
|
||||
sink.events.clear();
|
||||
reg.setContent('no-such-id', 'whatever');
|
||||
expect(sink.events, isEmpty);
|
||||
});
|
||||
|
||||
test('contentFromArgs decodes content_b64 when text is absent', () {
|
||||
expect(EditorRegistry.contentFromArgs({'text': 'plain'}), 'plain');
|
||||
expect(
|
||||
EditorRegistry.contentFromArgs({'content_b64': 'aGVsbG8='}),
|
||||
'hello',
|
||||
);
|
||||
expect(EditorRegistry.contentFromArgs(const {}), '');
|
||||
});
|
||||
|
||||
test('Selection hashCode + toString round-trip and serialise', () {
|
||||
const s = Selection(start: 3, end: 7);
|
||||
expect(s.hashCode, const Selection(start: 3, end: 7).hashCode);
|
||||
expect(s.hashCode, isNot(equals(const Selection(start: 3, end: 8).hashCode)));
|
||||
expect(s.toString(), 'Selection(3-7)');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user