Files
gongxue-base/scripts/launch-persona-smoke-test.js
2026-07-01 08:45:20 +08:00

49 lines
1.7 KiB
JavaScript

import assert from 'node:assert/strict';
import path from 'node:path';
import { parseCliArgs } from './launch-persona-smoke.js';
const repoRoot = process.cwd();
const writeOnly = parseCliArgs(['--write', 'docs/refactor/launch-artifacts/launch-persona-smoke.json']);
assert.equal(
writeOnly.writePath,
path.resolve(repoRoot, 'docs/refactor/launch-artifacts/launch-persona-smoke.json'),
'--write should resolve stable JSON evidence paths from the repo root',
);
assert.equal(writeOnly.writeMdPath, '', '--write should not imply a stable Markdown report path');
const equalsForm = parseCliArgs([
'--output-dir=docs/refactor/launch-artifacts',
'--write=docs/refactor/launch-artifacts/launch-persona-smoke.json',
'--write-md=docs/refactor/launch-artifacts/launch-persona-smoke.md',
'--json',
]);
assert.equal(
equalsForm.outputDir,
path.resolve(repoRoot, 'docs/refactor/launch-artifacts'),
'--output-dir should resolve stable report directories',
);
assert.equal(
equalsForm.writePath,
path.resolve(repoRoot, 'docs/refactor/launch-artifacts/launch-persona-smoke.json'),
'--write= should resolve stable JSON evidence paths',
);
assert.equal(
equalsForm.writeMdPath,
path.resolve(repoRoot, 'docs/refactor/launch-artifacts/launch-persona-smoke.md'),
'--write-md= should resolve stable Markdown evidence paths',
);
assert.throws(
() => parseCliArgs(['--write']),
/requires a file path value/,
'--write without a value should fail fast',
);
assert.throws(
() => parseCliArgs(['--unknown']),
/Unknown launch persona smoke option/,
'unknown options should fail fast instead of silently dropping evidence paths',
);
console.log('[PASS] launch persona smoke cli options');