From 277006bd7f18924ce9687b7546f7e83c9c74ba9c Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Fri, 13 Feb 2026 04:51:39 -0800 Subject: [PATCH] test: add Windows path heuristic and checkbox case sensitivity tests Round 46: verify getSessionStats recognises C:/ and D:\ as file paths but not bare C: without slash; verify parseSessionMetadata only matches lowercase [x] checkboxes (not uppercase [X]). --- tests/lib/session-manager.test.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/lib/session-manager.test.js b/tests/lib/session-manager.test.js index 34d4b54d..d14e36cf 100644 --- a/tests/lib/session-manager.test.js +++ b/tests/lib/session-manager.test.js @@ -1088,6 +1088,35 @@ src/main.ts } try { fs.rmSync(r33Home, { recursive: true, force: true }); } catch {} + // ── Round 46: path heuristic and checklist edge cases ── + console.log('\ngetSessionStats Windows path heuristic (Round 46):'); + + if (test('recognises Windows drive-letter path as a file path', () => { + // The looksLikePath regex includes /^[A-Za-z]:[/\\]/ for Windows + // A non-existent Windows path should still be treated as a path + // (getSessionContent returns null → parseSessionMetadata(null) → defaults) + const stats1 = sessionManager.getSessionStats('C:/Users/test/session.tmp'); + assert.strictEqual(stats1.lineCount, 0, 'C:/ path treated as path, not content'); + const stats2 = sessionManager.getSessionStats('D:\\Sessions\\2026-01-01.tmp'); + assert.strictEqual(stats2.lineCount, 0, 'D:\\ path treated as path, not content'); + })) passed++; else failed++; + + if (test('does not treat bare drive letter without slash as path', () => { + // "C:session.tmp" has no slash after colon → regex fails → treated as content + const stats = sessionManager.getSessionStats('C:session.tmp'); + assert.strictEqual(stats.lineCount, 1, 'Bare C: without slash treated as content'); + })) passed++; else failed++; + + console.log('\nparseSessionMetadata checkbox case sensitivity (Round 46):'); + + if (test('uppercase [X] does not match completed items regex', () => { + const content = '# Test\n\n### Completed\n- [X] Uppercase task\n- [x] Lowercase task\n'; + const meta = sessionManager.parseSessionMetadata(content); + // Regex is /- \[x\]\s*(.+)/g — only matches lowercase [x] + assert.strictEqual(meta.completed.length, 1, 'Only lowercase [x] should match'); + assert.strictEqual(meta.completed[0], 'Lowercase task'); + })) passed++; else failed++; + // Summary console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`); process.exit(failed > 0 ? 1 : 0);