The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
test: add 3 tests for replaceInFile deletion, parseSessionMetadata null fields, countInFile zero matches (Round 88)
Affaan Mustafae70d4d223755
diff --git a/tests/lib/session-manager.test.js b/tests/lib/session-manager.test.jsindex d96c3dc93..365afe1a6 100644--- a/tests/lib/session-manager.test.js+++ b/tests/lib/session-manager.test.js@@ -1385,6 +1385,22 @@ src/main.ts}})) passed++; else failed++;+ // ── Round 88: parseSessionMetadata null date/started/lastUpdated fields ──+ console.log('\nRound 88: parseSessionMetadata content lacking Date/Started/Updated fields:');+ if (test('parseSessionMetadata returns null for date, started, lastUpdated when fields absent', () => {+ const content = '# Title Only\n\n### Notes for Next Session\nSome notes\n';+ const meta = sessionManager.parseSessionMetadata(content);+ assert.strictEqual(meta.date, null,+ 'date should be null when **Date:** field is absent');+ assert.strictEqual(meta.started, null,+ 'started should be null when **Started:** field is absent');+ assert.strictEqual(meta.lastUpdated, null,+ 'lastUpdated should be null when **Last Updated:** field is absent');+ // Confirm other fields still parse correctly+ assert.strictEqual(meta.title, 'Title Only');+ assert.strictEqual(meta.notes, 'Some notes');+ })) passed++; else failed++;+// Summaryconsole.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);process.exit(failed > 0 ? 1 : 0);diff --git a/tests/lib/utils.test.js b/tests/lib/utils.test.jsindex 6029f2fab..72ece4c7e 100644--- a/tests/lib/utils.test.js+++ b/tests/lib/utils.test.js@@ -1194,6 +1194,43 @@ function runTests() {`At CWD=/ with no session ID, should use the fallback parameter. Got: "${result.stdout}"`);})) passed++; else failed++;+ // ── Round 88: replaceInFile with empty replacement (deletion) ──+ console.log('\nRound 88: replaceInFile with empty replacement string (deletion):');+ if (test('replaceInFile with empty string replacement deletes matched text', () => {+ const tmpDir = path.join(utils.getTempDir(), `ecc-r88-replace-empty-${Date.now()}`);+ fs.mkdirSync(tmpDir, { recursive: true });+ const tmpFile = path.join(tmpDir, 'delete-test.txt');+ try {+ fs.writeFileSync(tmpFile, 'hello REMOVE_ME world');+ const result = utils.replaceInFile(tmpFile, 'REMOVE_ME ', '');+ assert.strictEqual(result, true, 'Should return true on successful replacement');+ const content = fs.readFileSync(tmpFile, 'utf8');+ assert.strictEqual(content, 'hello world',+ 'Empty replacement should delete the matched text');+ } finally {+ fs.rmSync(tmpDir, { recursive: true, force: true });+ }+ })) passed++; else failed++;++ // ── Round 88: countInFile with valid file but zero matches ──+ console.log('\nRound 88: countInFile with existing file but non-matching pattern:');+ if (test('countInFile returns 0 for valid file with no pattern matches', () => {+ const tmpDir = path.join(utils.getTempDir(), `ecc-r88-count-zero-${Date.now()}`);+ fs.mkdirSync(tmpDir, { recursive: true });+ const tmpFile = path.join(tmpDir, 'no-match.txt');+ try {+ fs.writeFileSync(tmpFile, 'apple banana cherry');+ const count = utils.countInFile(tmpFile, 'ZZZZNOTHERE');+ assert.strictEqual(count, 0,+ 'Should return 0 when regex matches nothing in existing file');+ const countRegex = utils.countInFile(tmpFile, /ZZZZNOTHERE/g);+ assert.strictEqual(countRegex, 0,+ 'Should return 0 for RegExp with no matches in existing file');+ } finally {+ fs.rmSync(tmpDir, { recursive: true, force: true });+ }+ })) passed++; else failed++;+// Summaryconsole.log('\n=== Test Results ===');console.log(`Passed: ${passed}`);