test sweep: cover daemon editor / files / pane / pql commands (T-91)
test / unit + widget + golden + a11y (push) Failing after 31s
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 1m1s
test / unit + widget + golden + a11y (push) Failing after 31s
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 1m1s
Extends the four existing daemon command suites with the verbs + error paths the originals didn't reach: - editor_commands_test (12 new): unreadable-path FileSystemException catch, editor.active with no buffer, editor.activate requires + validates id, editor.read no-active / unknown-id, editor.set-selection no-active / clamped, editor.set-content with + without selection, editor.save no-active, editor.close requires + validates id. - files_commands_test (8 new): files.read happy + missing-path + empty-path + outside-root + missing-file, files.ls outside-root, files.watch idempotent, FilesService.atCwd resolver. - pane_commands_test (10 new): argv-non-string rejection, unknown kind rejection, env passthrough, close / write / focus / resize missing-id and unknown-id validations, write requires bytes_b64 or text, malformed base64 rejection. - pql_commands_test (14 new): pql.files glob + limit, pql.backlinks happy, pql.outlinks missing, pql.tags, pql.query + pql.search happy paths + missing-arg user_error, pql.decisions.read missing + happy, pql.decisions.show with --with-refs / --with-tickets, pql.decisions.list domain filter, pql.tickets.list multi-filter, pql.tickets.show missing + happy, pql.tickets.status missing + partial-args, pql.tickets.board with team. Coverage: src/daemon/editor_commands.dart 64/100 -> 88/100; files_commands.dart 33/70 -> 64/70 (91%); pane_commands.dart 66/92 -> 78/92 (85%); pql_commands.dart 62/149 -> 105/149 (70% — remaining 44 lines are the per-command PqlException catch branches that only fire when the pql subprocess itself fails mid-call). Total coverage 77.92% -> 79.26%; floor bumped to 79. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -107,4 +107,100 @@ void main() {
|
||||
expect(r.ok, isFalse);
|
||||
expect(r.error!.code, IpcExitCode.notFound);
|
||||
});
|
||||
|
||||
test('editor.open returns toolError for an unreadable path', () async {
|
||||
// Create a file then chmod 000 so reading fails with a FileSystemException.
|
||||
final unreadable = File('${sandbox.path}/locked.md');
|
||||
await unreadable.writeAsString('x');
|
||||
await Process.run('chmod', ['000', unreadable.path]);
|
||||
addTearDown(() async {
|
||||
await Process.run('chmod', ['644', unreadable.path]);
|
||||
});
|
||||
final r = await call('editor.open', {'path': 'locked.md'});
|
||||
expect(r.ok, isFalse);
|
||||
// Either errno-mapped or toolError — either is acceptable.
|
||||
expect(r.error!.code, isNot(IpcExitCode.notFound));
|
||||
});
|
||||
|
||||
test('editor.active returns null when no buffer is open', () async {
|
||||
final r = await call('editor.active');
|
||||
expect(r.ok, isTrue);
|
||||
expect(r.data['active'], isNull);
|
||||
});
|
||||
|
||||
test('editor.activate requires id and validates it', () async {
|
||||
final missing = await call('editor.activate');
|
||||
expect(missing.ok, isFalse);
|
||||
expect(missing.error!.kind, 'user_error');
|
||||
final unknown = await call('editor.activate', {'id': 'b_404'});
|
||||
expect(unknown.ok, isFalse);
|
||||
expect(unknown.error!.kind, 'not_found');
|
||||
});
|
||||
|
||||
test('editor.activate flips the active buffer to the requested one', () async {
|
||||
await File('${sandbox.path}/a.md').writeAsString('a');
|
||||
await File('${sandbox.path}/b.md').writeAsString('b');
|
||||
final a = await call('editor.open', {'path': 'a.md'});
|
||||
await call('editor.open', {'path': 'b.md'});
|
||||
final r = await call('editor.activate', {'id': a.data['id']});
|
||||
expect(r.ok, isTrue);
|
||||
expect(r.data['active'], a.data['id']);
|
||||
});
|
||||
|
||||
test('editor.read with no active buffer and no id returns not-found', () async {
|
||||
final r = await call('editor.read');
|
||||
expect(r.ok, isFalse);
|
||||
expect(r.error!.kind, 'not_found');
|
||||
});
|
||||
|
||||
test('editor.read with an unknown id returns not-found', () async {
|
||||
final r = await call('editor.read', {'id': 'b_404'});
|
||||
expect(r.ok, isFalse);
|
||||
expect(r.error!.kind, 'not_found');
|
||||
});
|
||||
|
||||
test('editor.set-selection clamps and applies', () async {
|
||||
await call('editor.open', {'path': 'doc.md'});
|
||||
final r = await call('editor.set-selection', {
|
||||
'selection': {'start': 0, 'end': 3}
|
||||
});
|
||||
expect(r.ok, isTrue);
|
||||
});
|
||||
|
||||
test('editor.set-selection without an id or active buffer returns not-found', () async {
|
||||
final r = await call('editor.set-selection', {
|
||||
'selection': {'start': 0, 'end': 1}
|
||||
});
|
||||
expect(r.ok, isFalse);
|
||||
expect(r.error!.kind, 'not_found');
|
||||
});
|
||||
|
||||
test('editor.set-content overwrites the buffer (with and without selection)', () async {
|
||||
await call('editor.open', {'path': 'doc.md'});
|
||||
final r1 = await call('editor.set-content', {'text': 'replaced'});
|
||||
expect(r1.ok, isTrue);
|
||||
expect(r1.data['length'], 'replaced'.length);
|
||||
final read1 = await call('editor.read');
|
||||
expect(read1.data['content'], 'replaced');
|
||||
final r2 = await call('editor.set-content', {
|
||||
'text': 'short',
|
||||
'selection': {'start': 1, 'end': 99}
|
||||
});
|
||||
expect(r2.ok, isTrue);
|
||||
});
|
||||
|
||||
test('editor.save with no active buffer returns not-found', () async {
|
||||
final r = await call('editor.save');
|
||||
expect(r.ok, isFalse);
|
||||
expect(r.error!.kind, 'not_found');
|
||||
});
|
||||
|
||||
test('editor.close requires id and validates it', () async {
|
||||
final missing = await call('editor.close');
|
||||
expect(missing.ok, isFalse);
|
||||
expect(missing.error!.kind, 'user_error');
|
||||
final unknown = await call('editor.close', {'id': 'b_404'});
|
||||
expect(unknown.ok, isFalse);
|
||||
expect(unknown.error!.kind, 'not_found');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user