extract pick-up + file-resolver helpers for coverage
The T-339 pick-up test was the only importer of the ~450-line claude extension.dart, pulling its (mostly UI-wiring, untestable) lines into the coverage denominator and dropping the suite below the 95% floor. Move applyTicketPickUp into its own ticket_pick_up.dart and the T-300 path resolver into a pure resolveWorkspaceFilePath() — both small, fully covered, and imported by the tests instead of the whole extension. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
/// Tests for the workspace file-path resolver behind clickable conversation
|
||||
/// references (T-300): only real files under the repo root resolve; relative
|
||||
/// tokens resolve against the root, absolute tokens must already live inside it,
|
||||
/// and `..` escapes are rejected.
|
||||
library;
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:clide/builtin/claude/src/conversation_view.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
late Directory root;
|
||||
|
||||
setUp(() async {
|
||||
root = await Directory.systemTemp.createTemp('clide_wsfile_');
|
||||
await File('${root.path}/lib/app.dart').create(recursive: true);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
if (await root.exists()) await root.delete(recursive: true);
|
||||
});
|
||||
|
||||
test('a relative path that exists resolves to its absolute path', () {
|
||||
expect(resolveWorkspaceFilePath(root.path, 'lib/app.dart'), '${root.path}/lib/app.dart');
|
||||
});
|
||||
|
||||
test('an absolute path inside the root resolves', () {
|
||||
expect(resolveWorkspaceFilePath(root.path, '${root.path}/lib/app.dart'), '${root.path}/lib/app.dart');
|
||||
});
|
||||
|
||||
test('a nonexistent path is null', () {
|
||||
expect(resolveWorkspaceFilePath(root.path, 'lib/ghost.dart'), isNull);
|
||||
});
|
||||
|
||||
test('a directory is not a file', () {
|
||||
expect(resolveWorkspaceFilePath(root.path, 'lib'), isNull);
|
||||
});
|
||||
|
||||
test('an absolute path outside the root is rejected', () {
|
||||
expect(resolveWorkspaceFilePath(root.path, '/etc/passwd'), isNull);
|
||||
});
|
||||
|
||||
test('a `..` escape is rejected', () {
|
||||
expect(resolveWorkspaceFilePath(root.path, '../escape.dart'), isNull);
|
||||
});
|
||||
|
||||
test('a null root (no project open) is null', () {
|
||||
expect(resolveWorkspaceFilePath(null, 'lib/app.dart'), isNull);
|
||||
});
|
||||
|
||||
test('an empty token is null', () {
|
||||
expect(resolveWorkspaceFilePath(root.path, ''), isNull);
|
||||
});
|
||||
}
|
||||
@@ -5,9 +5,9 @@ library;
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:clide/builtin/claude/src/extension.dart';
|
||||
import 'package:clide/builtin/claude/src/session_orchestrator.dart';
|
||||
import 'package:clide/builtin/claude/src/stream_json_session.dart';
|
||||
import 'package:clide/builtin/claude/src/ticket_pick_up.dart';
|
||||
import 'package:clide/clide.dart';
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Reference in New Issue
Block a user