import test from 'node:test' import assert from 'node:assert/strict' import { buildIdempotencyKey, parseArgs, validateOptions } from './kaifa-progress-sync.mjs' test('解析同步参数并生成稳定幂等键', () => { const options = parseArgs(['--module', '权限与私密素材', '--feature', '权限组保存', '--status', 'testing', '--summary', '完成验证', '--apply']) assert.equal(options.get('module'), '权限与私密素材') assert.equal(options.get('apply'), true) assert.equal(buildIdempotencyKey('abc123', 'testing'), 'gongxiangp2-abc123-testing') }) test('done 必须有通过测试和完成证据', () => { const base = ['--module', '模块', '--feature', '功能', '--status', 'done', '--summary', '完成'] assert.throws(() => validateOptions(parseArgs(base)), /test-status passed/) assert.throws(() => validateOptions(parseArgs([...base, '--test-status', 'passed'])), /completion-evidence/) assert.doesNotThrow(() => validateOptions(parseArgs([...base, '--test-status', 'passed', '--completion-evidence', '已上线'])) ) }) test('help 是独立布尔参数', () => { assert.equal(parseArgs(['--help']).get('help'), true) })