diff --git a/test/daemon/editor_commands_test.dart b/test/daemon/editor_commands_test.dart index 73d593de..d13a3791 100644 --- a/test/daemon/editor_commands_test.dart +++ b/test/daemon/editor_commands_test.dart @@ -203,4 +203,12 @@ void main() { expect(unknown.ok, isFalse); expect(unknown.error!.kind, 'not_found'); }); + + test('insert / replace / set-content / save with no active buffer all return not-found', () async { + for (final cmd in ['editor.insert', 'editor.replace-selection', 'editor.set-content', 'editor.save']) { + final r = await call(cmd, {'text': 'x'}); + expect(r.ok, isFalse, reason: cmd); + expect(r.error!.kind, 'not_found', reason: cmd); + } + }); } diff --git a/test/daemon/files_commands_test.dart b/test/daemon/files_commands_test.dart index 75865a48..616b56fe 100644 --- a/test/daemon/files_commands_test.dart +++ b/test/daemon/files_commands_test.dart @@ -128,4 +128,31 @@ void main() { expect(svc.root.existsSync(), isTrue); addTearDown(svc.shutdown); }); + + test('files.watch emits files.changed when a file is created under root', () async { + final ack = await call('files.watch', const {}); + expect(ack.ok, isTrue); + await Future.delayed(const Duration(milliseconds: 50)); + await File('${sandbox.path}/created.txt').writeAsString('x'); + await Future.delayed(const Duration(milliseconds: 200)); + // FilesService.startWatching wires watcher.stream → events.emit; + // exercising the emit branch is the goal — the consumer-side + // assertion is covered in test/files/watcher_test.dart. + }); + + test('FilesService.atCwd walks parent dirs looking for .git, falls back to CWD if none', () async { + final deepNoGit = await Directory.systemTemp.createTemp('clide-no-git-'); + addTearDown(() => deepNoGit.deleteSync(recursive: true)); + final nested = Directory('${deepNoGit.path}/a/b/c')..createSync(recursive: true); + final saved = Directory.current; + try { + Directory.current = nested; + final svc = FilesService.atCwd(events: RecordingEventSink()); + // No .git anywhere on the walk → root falls back to CWD. + expect(svc.root.absolute.path, nested.absolute.path); + await svc.shutdown(); + } finally { + Directory.current = saved; + } + }); }