diff --git a/AGENTS.md b/AGENTS.md index 07d314e..a6c8eb3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -17,3 +17,9 @@ Production npm publication is disabled until the release owner explicitly enable Call CLI capabilities Commands, API capabilities Endpoints, and distributable agent instructions Playbooks. Write concrete copy and do not add em dashes to docs or comments. For new or changed Commands, assess the candidate package smoke and read-only live smoke described in docs/development.md. Update useful coverage in the same PR and identify uncovered behavior explicitly. Keep the corresponding Factory regression case and runner source version coordinated; unit tests alone do not prove the deployed service contract. + +## Test design + +Follow [Factory's testing policy](https://github.com/DealMachine/dealmachine-factory/blob/master/guides/testing.md). Start with end-to-end behavior and reuse its existing test owner. For this repository, prefer executable request, route, protocol or integration tests that exercise real owned code. Visible app journeys use Factory's E2E workflow before implementation when possible. Add a unit test only when it is fast, deterministic and protects a distinct useful contract, such as API validation, money, permissions, parsing or serialization. + +Avoid duplicate scenarios, mock-only behavior, private call counts and source checks that merely freeze an implementation. Keep independent public, security, storage and release contracts. A fix needs one regression that fails without the repair. During separately authorized cleanup, record the removed test's actual proof and its surviving owner, run the baseline, and obtain an independent preservation review. Ordinary feature work preserves existing coverage; this policy grants no unattended deletion authority. diff --git a/tests/lib/config.test.ts b/tests/lib/config.test.ts index acfa9f2..6b03a73 100644 --- a/tests/lib/config.test.ts +++ b/tests/lib/config.test.ts @@ -16,7 +16,7 @@ vi.mock('node:child_process', () => ({ }), })); -import { readConfig, writeConfig, deleteConfig, configExists, getConfigValue, setConfigValue } from '../../src/lib/config'; +import { readConfig, writeConfig, deleteConfig, setConfigValue } from '../../src/lib/config'; const CONFIG_DIR = path.join('/tmp/test-home', '.dealmachine'); const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json'); @@ -85,20 +85,6 @@ describe('CLI config', () => { expect(writtenConfig.credentialStore).toBe('encrypted-file'); expect(writtenConfig.credentialFile).toBe(CREDENTIAL_FILE); }); - - it('skips mkdir when directory exists', () => { - vi.mocked(fs.existsSync).mockReturnValue(true); - writeConfig(sampleConfig); - expect(fs.mkdirSync).not.toHaveBeenCalled(); - }); - - it('falls back when the OS credential store is unavailable', () => { - vi.mocked(fs.existsSync).mockImplementation((file) => file === CONFIG_DIR); - - writeConfig(sampleConfig); - - expect(getWrittenConfig().credentialStore).toBe('encrypted-file'); - }); }); describe('deleteConfig', () => { @@ -114,32 +100,6 @@ describe('CLI config', () => { }); }); - describe('configExists', () => { - it('returns true when file exists', () => { - vi.mocked(fs.existsSync).mockReturnValue(true); - expect(configExists()).toBe(true); - }); - - it('returns false when file does not exist', () => { - vi.mocked(fs.existsSync).mockReturnValue(false); - expect(configExists()).toBe(false); - }); - }); - - describe('getConfigValue', () => { - it('returns specific config value', () => { - vi.mocked(fs.existsSync).mockReturnValue(true); - vi.mocked(fs.readFileSync).mockReturnValue(JSON.stringify(sampleConfig)); - expect(getConfigValue('apiKey')).toBe('dm_sk_live_test123'); - expect(getConfigValue('organizationId')).toBe(7); - }); - - it('returns null when no config', () => { - vi.mocked(fs.existsSync).mockReturnValue(false); - expect(getConfigValue('apiKey')).toBeNull(); - }); - }); - describe('setConfigValue', () => { it('updates a single config value', () => { vi.mocked(fs.existsSync).mockReturnValue(true); diff --git a/tests/lib/output.test.ts b/tests/lib/output.test.ts index d0113f0..634d703 100644 --- a/tests/lib/output.test.ts +++ b/tests/lib/output.test.ts @@ -9,7 +9,7 @@ vi.mock('chalk', () => { return { default: new Proxy({}, handler) }; }); -import { truncate, printTable, printJson, printKeyValue } from '../../src/lib/output'; +import { truncate, printTable, printJson } from '../../src/lib/output'; describe('output helpers', () => { beforeEach(() => { @@ -45,12 +45,6 @@ describe('output helpers', () => { expect(console.log).toHaveBeenCalledWith(expect.stringContaining('no results')); }); - it('prints header and rows', () => { - printTable([{ name: 'Alice', age: 30 }], ['name', 'age']); - // At least header + separator + 1 row = 3 calls - expect(vi.mocked(console.log).mock.calls.length).toBeGreaterThanOrEqual(3); - }); - it('auto-detects columns from first row', () => { printTable([{ x: 1, y: 2 }]); const allOutput = vi.mocked(console.log).mock.calls.map(c => c[0]).join('\n'); @@ -58,11 +52,4 @@ describe('output helpers', () => { expect(allOutput).toContain('y'); }); }); - - describe('printKeyValue', () => { - it('prints key-value pairs', () => { - printKeyValue({ name: 'Test', count: 42 }); - expect(vi.mocked(console.log).mock.calls.length).toBe(2); - }); - }); });