mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-04 08:13:30 +08:00
test: add 3 tests for suggest-compact, session-aliases, typecheck (Round 64)
- suggest-compact: 'default' session ID fallback when CLAUDE_SESSION_ID empty - session-aliases: loadAliases backfills missing version and metadata fields - post-edit-typecheck: valid JSON without tool_input passes through unchanged Total: 797 tests, all passing
This commit is contained in:
@@ -2999,6 +2999,19 @@ async function runTests() {
|
||||
'Should pass through data unchanged when tool_input is absent');
|
||||
})) passed++; else failed++;
|
||||
|
||||
// ── Round 64: post-edit-typecheck.js valid JSON without tool_input ──
|
||||
console.log('\nRound 64: post-edit-typecheck.js (valid JSON without tool_input):');
|
||||
|
||||
if (await asyncTest('skips typecheck when JSON has no tool_input field', async () => {
|
||||
const stdinJson = JSON.stringify({ result: 'ok', metadata: { action: 'test' } });
|
||||
const result = await runScript(path.join(scriptsDir, 'post-edit-typecheck.js'), stdinJson);
|
||||
|
||||
assert.strictEqual(result.code, 0, 'Should exit 0 for JSON without tool_input');
|
||||
// input.tool_input?.file_path is undefined → skips TS check → passes through
|
||||
assert.strictEqual(result.stdout, stdinJson,
|
||||
'Should pass through data unchanged when tool_input is absent');
|
||||
})) passed++; else failed++;
|
||||
|
||||
// Summary
|
||||
console.log('\n=== Test Results ===');
|
||||
console.log(`Passed: ${passed}`);
|
||||
|
||||
@@ -318,6 +318,30 @@ function runTests() {
|
||||
cleanupCounter();
|
||||
})) passed++; else failed++;
|
||||
|
||||
// ── Round 64: default session ID fallback ──
|
||||
console.log('\nDefault session ID fallback (Round 64):');
|
||||
|
||||
if (test('uses "default" session ID when CLAUDE_SESSION_ID is empty', () => {
|
||||
const defaultCounterFile = getCounterFilePath('default');
|
||||
try { fs.unlinkSync(defaultCounterFile); } catch {}
|
||||
try {
|
||||
// Pass empty CLAUDE_SESSION_ID — falsy, so script uses 'default'
|
||||
const env = { ...process.env, CLAUDE_SESSION_ID: '' };
|
||||
const result = spawnSync('node', [compactScript], {
|
||||
encoding: 'utf8',
|
||||
input: '{}',
|
||||
timeout: 10000,
|
||||
env,
|
||||
});
|
||||
assert.strictEqual(result.status || 0, 0, 'Should exit 0');
|
||||
assert.ok(fs.existsSync(defaultCounterFile), 'Counter file should use "default" session ID');
|
||||
const count = parseInt(fs.readFileSync(defaultCounterFile, 'utf8').trim(), 10);
|
||||
assert.strictEqual(count, 1, 'Counter should be 1 for first run with default session');
|
||||
} finally {
|
||||
try { fs.unlinkSync(defaultCounterFile); } catch {}
|
||||
}
|
||||
})) passed++; else failed++;
|
||||
|
||||
// Summary
|
||||
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
|
||||
process.exit(failed > 0 ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user