/** * test-report — validate() contract: the entry point runs the Zod-PARSED spec * (one contract for every CLI), never the raw JSON. */ import { describe, it, expect, beforeAll, afterAll } from 'vitest' import { mkdtempSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { validate } from '../validate.js' let tmp: string beforeAll(() => { tmp = mkdtempSync(join(tmpdir(), 'ss-test-report-')) }) afterAll(() => { rmSync(tmp, { recursive: true, force: true }) }) describe('test-report — validate()', () => { it('returns the parsed spec for an existing project path', () => { const v = validate({ projectPath: tmp, module: 'hrm' }) expect(v.valid).toBe(true) expect(v.data?.projectPath).toBe(tmp) expect(v.data?.module).toBe('hrm') }) it('carries no data when the project path does not exist', () => { const v = validate({ projectPath: join(tmp, 'missing'), module: 'hrm' }) expect(v.valid).toBe(false) expect(v.errors.join('\n')).toContain('Project path not found') expect(v.data).toBeUndefined() }) it('carries no data when the shape is refused', () => { const v = validate({ module: 'hrm' }) expect(v.valid).toBe(false) expect(v.data).toBeUndefined() }) })