diff --git a/package.json b/package.json index 3a9fe98..b2d0c19 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "type": "module", "description": "TORCH standalone lock CLI and optional dashboard", "scripts": { + "test": "node --test test/*.test.mjs", "lock:check:daily": "node src/nostr-lock.mjs check --cadence daily", "lock:check:weekly": "node src/nostr-lock.mjs check --cadence weekly", "lock:list": "node src/nostr-lock.mjs list", diff --git a/src/context/CONTEXT_2026-02-14T04-53-53Z.md b/src/context/CONTEXT_2026-02-14T04-53-53Z.md new file mode 100644 index 0000000..6038eff --- /dev/null +++ b/src/context/CONTEXT_2026-02-14T04-53-53Z.md @@ -0,0 +1 @@ +# Test Audit Context diff --git a/src/decisions/DECISIONS_2026-02-14T04-53-53Z.md b/src/decisions/DECISIONS_2026-02-14T04-53-53Z.md new file mode 100644 index 0000000..0430954 --- /dev/null +++ b/src/decisions/DECISIONS_2026-02-14T04-53-53Z.md @@ -0,0 +1 @@ +# Decisions diff --git a/src/test_logs/TEST_LOG_2026-02-13-documentation-alignment-test-log.md b/src/test_logs/TEST_LOG_2026-02-13-documentation-alignment-test-log.md new file mode 100644 index 0000000..c980354 --- /dev/null +++ b/src/test_logs/TEST_LOG_2026-02-13-documentation-alignment-test-log.md @@ -0,0 +1,39 @@ + +## Run at 2026-02-14T04-55-08Z +Command: npm test +Output: +``` + +> torch-lock@0.1.0 test +> node --test test/*.test.mjs + +TAP version 13 +# Subtest: CLI Smoke Test + # Subtest: should print usage when no args provided + ok 1 - should print usage when no args provided + --- + duration_ms: 154.438982 + type: 'test' + ... + # Subtest: should fail when checking without cadence + ok 2 - should fail when checking without cadence + --- + duration_ms: 167.381667 + type: 'test' + ... + 1..2 +ok 1 - CLI Smoke Test + --- + duration_ms: 323.47485 + type: 'suite' + ... +1..1 +# tests 2 +# suites 1 +# pass 2 +# fail 0 +# cancelled 0 +# skipped 0 +# todo 0 +# duration_ms 419.728338 +``` diff --git a/src/test_logs/TEST_LOG_2026-02-14T04-53-53Z.md b/src/test_logs/TEST_LOG_2026-02-14T04-53-53Z.md new file mode 100644 index 0000000..cb55644 --- /dev/null +++ b/src/test_logs/TEST_LOG_2026-02-14T04-53-53Z.md @@ -0,0 +1 @@ +# Test Log diff --git a/src/todo/TODO_2026-02-14T04-53-53Z.md b/src/todo/TODO_2026-02-14T04-53-53Z.md new file mode 100644 index 0000000..1f600ad --- /dev/null +++ b/src/todo/TODO_2026-02-14T04-53-53Z.md @@ -0,0 +1 @@ +# Todo diff --git a/task-logs/daily/2026-02-14T04-56-12Z__test-audit-agent__completed.md b/task-logs/daily/2026-02-14T04-56-12Z__test-audit-agent__completed.md new file mode 100644 index 0000000..3ea97df --- /dev/null +++ b/task-logs/daily/2026-02-14T04-56-12Z__test-audit-agent__completed.md @@ -0,0 +1,24 @@ +--- +agent: test-audit-agent +status: completed +date: 2026-02-14 +--- + +# Daily Task: test-audit-agent + +## Summary +- Audit Performed: Yes +- Outcome: Success (No existing tests found; added initial smoke tests) +- Changes: + - Added `test` script to `package.json`. + - Created `test/nostr-lock.test.mjs`. + - Generated `test-audit-report-2026-02-14.md`. + +## Details +Executed the daily test audit. Found that the repository lacked a test runner and test suite. +Bootstraped the testing infrastructure using Node.js built-in test runner (`node --test`). +Verified that the new smoke tests pass and the build still works. + +## Artifacts +- `test-audit-report-2026-02-14.md` +- `test/nostr-lock.test.mjs` diff --git a/test-audit-report-2026-02-14.md b/test-audit-report-2026-02-14.md new file mode 100644 index 0000000..4fc8ff3 --- /dev/null +++ b/test-audit-report-2026-02-14.md @@ -0,0 +1,63 @@ +# Test Audit Report 2026-02-14 + +## Summary +- **Status**: Completed (Initial Setup) +- **Runner**: Node.js built-in test runner (`node --test`) +- **Tests Added**: 2 smoke tests for CLI. +- **Outcome**: All tests passed. + +## Context +No existing tests were found in the repository. The `package.json` lacked a `test` script. +This audit run focused on establishing a baseline testing infrastructure. + +## Actions Taken +1. **Added Test Script**: Updated `package.json` with `"test": "node --test test/*.test.mjs"`. +2. **Added Smoke Tests**: Created `test/nostr-lock.test.mjs` checking CLI usage and argument validation. +3. **Verification**: Ran `npm test` successfully. + +## Findings +- **Coverage**: Not yet measured. +- **Flakiness**: None observed in initial runs. +- **Suspicious Tests**: N/A (newly created). + +## Remediation / Next Steps +- Expand test coverage to `nostr-lock.mjs` core logic (requires refactoring for testability). +- Add `c8` for coverage reporting. +- Add unit tests for `torch-config.mjs` if possible. + +## Test Log Snippet +``` + +> torch-lock@0.1.0 test +> node --test test/*.test.mjs + +TAP version 13 +# Subtest: CLI Smoke Test + # Subtest: should print usage when no args provided + ok 1 - should print usage when no args provided + --- + duration_ms: 154.438982 + type: 'test' + ... + # Subtest: should fail when checking without cadence + ok 2 - should fail when checking without cadence + --- + duration_ms: 167.381667 + type: 'test' + ... + 1..2 +ok 1 - CLI Smoke Test + --- + duration_ms: 323.47485 + type: 'suite' + ... +1..1 +# tests 2 +# suites 1 +# pass 2 +# fail 0 +# cancelled 0 +# skipped 0 +# todo 0 +# duration_ms 419.728338 +``` diff --git a/test/nostr-lock.test.mjs b/test/nostr-lock.test.mjs new file mode 100644 index 0000000..e29f833 --- /dev/null +++ b/test/nostr-lock.test.mjs @@ -0,0 +1,17 @@ +import { test, describe, it } from 'node:test'; +import assert from 'node:assert'; +import { spawnSync } from 'node:child_process'; + +describe('CLI Smoke Test', () => { + it('should print usage when no args provided', () => { + const result = spawnSync('node', ['src/nostr-lock.mjs']); + assert.strictEqual(result.status, 1); + assert.match(result.stderr.toString(), /Usage:/); + }); + + it('should fail when checking without cadence', () => { + const result = spawnSync('node', ['src/nostr-lock.mjs', 'check']); + assert.strictEqual(result.status, 1); + assert.match(result.stderr.toString(), /--cadence is required/); + }); +});