From 3bc0929c6e4c0bd85e90ee8866b8cd6f1bd6bc9e Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Fri, 13 Feb 2026 05:43:29 -0800 Subject: [PATCH] test: add search scope, path utility, and zero-value analysis tests (Round 54) - getAllSessions search matches only shortId, not title/content - getSessionPath returns absolute path with correct directory structure - analysisResults handles zero values for all data fields without crash --- tests/lib/session-manager.test.js | 22 ++++++++++++++++++++++ tests/scripts/skill-create-output.test.js | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/tests/lib/session-manager.test.js b/tests/lib/session-manager.test.js index d14e36cf..9439208d 100644 --- a/tests/lib/session-manager.test.js +++ b/tests/lib/session-manager.test.js @@ -956,6 +956,28 @@ src/main.ts assert.ok(result.modifiedTime, 'modifiedTime should be present'); })) passed++; else failed++; + // ── Round 54: search filter scope and getSessionPath utility ── + console.log('\nRound 54: search filter scope and path utility:'); + + if (test('getAllSessions search filter matches only short ID, not title or content', () => { + // "Session" appears in file CONTENT (e.g. "# Session 1") but not in any shortId + const result = sessionManager.getAllSessions({ search: 'Session', limit: 100 }); + assert.strictEqual(result.total, 0, 'Search should not match title/content, only shortId'); + // Verify that searching by actual shortId substring still works + const result2 = sessionManager.getAllSessions({ search: 'abcd', limit: 100 }); + assert.strictEqual(result2.total, 1, 'Search by shortId should still work'); + })) passed++; else failed++; + + if (test('getSessionPath returns absolute path for session filename', () => { + const filename = '2026-02-01-testpath-session.tmp'; + const result = sessionManager.getSessionPath(filename); + assert.ok(path.isAbsolute(result), 'Should return an absolute path'); + assert.ok(result.endsWith(filename), `Path should end with filename, got: ${result}`); + // Since HOME is overridden, sessions dir should be under tmpHome + assert.ok(result.includes('.claude'), 'Path should include .claude directory'); + assert.ok(result.includes('sessions'), 'Path should include sessions directory'); + })) passed++; else failed++; + // Cleanup — restore both HOME and USERPROFILE (Windows) process.env.HOME = origHome; if (origUserProfile !== undefined) { diff --git a/tests/scripts/skill-create-output.test.js b/tests/scripts/skill-create-output.test.js index 703991bc..2f2ff42f 100644 --- a/tests/scripts/skill-create-output.test.js +++ b/tests/scripts/skill-create-output.test.js @@ -451,6 +451,25 @@ function runTests() { }); })) passed++; else failed++; + // ── Round 54: analysisResults with zero values ── + console.log('\nanalysisResults zero values (Round 54):'); + + if (test('analysisResults handles zero values for all data fields', () => { + const output = new SkillCreateOutput('repo'); + const logs = captureLog(() => output.analysisResults({ + commits: 0, timeRange: '', contributors: 0, files: 0, + })); + const combined = logs.join('\n'); + assert.ok(combined.includes('0'), 'Should display zero values'); + assert.ok(logs.length > 0, 'Should produce output without crash'); + // Box lines should still be 60 chars wide + const boxLines = combined.split('\n').filter(l => { + const s = stripAnsi(l).trim(); + return s.startsWith('\u256D') || s.startsWith('\u2502') || s.startsWith('\u2570'); + }); + assert.ok(boxLines.length >= 3, 'Should render a complete box'); + })) passed++; else failed++; + // Summary console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`); process.exit(failed > 0 ? 1 : 0);