fix: typecheck hook false positives, add 11 session-manager tests

- Fix post-edit-typecheck.js error filtering: use relative/absolute path
  matching instead of basename, preventing false positives when multiple
  files share the same name (e.g., src/utils.ts vs tests/utils.ts)
- Add writeSessionContent tests (create, overwrite, invalid path)
- Add appendSessionContent test (append to existing file)
- Add deleteSession tests (delete existing, non-existent)
- Add sessionExists tests (file, non-existent, directory)
- Add getSessionStats empty content edge case
- Add post-edit-typecheck stdout passthrough test
- Total: 391 → 402 tests, all passing
This commit is contained in:
Affaan Mustafa
2026-02-13 01:28:59 -08:00
parent e9343c844b
commit 3f651b7c3c
3 changed files with 136 additions and 5 deletions

View File

@@ -639,6 +639,18 @@ async function runTests() {
cleanupTestDir(testDir);
})) passed++; else failed++;
if (await asyncTest('passes through stdin data on stdout (post-edit-typecheck)', async () => {
const testDir = createTestDir();
const testFile = path.join(testDir, 'test.ts');
fs.writeFileSync(testFile, 'const x: number = 1;');
const stdinJson = JSON.stringify({ tool_input: { file_path: testFile } });
const result = await runScript(path.join(scriptsDir, 'post-edit-typecheck.js'), stdinJson);
assert.strictEqual(result.code, 0);
assert.ok(result.stdout.includes('tool_input'), 'Should pass through stdin data on stdout');
cleanupTestDir(testDir);
})) passed++; else failed++;
// session-end.js extractSessionSummary tests
console.log('\nsession-end.js (extractSessionSummary):');