Step 2 av v4.1-execute (Wave 1, Session 1). Legg --profile i valued-arrayen for alle 6 voyage-kommandoer (trekbrief, trekresearch, trekplan, trekexecute, trekreview, trekcontinue). Mønster identisk med eksisterende --project/--brief valued-handling. Ingen endring til parseArgs-logikk — utvider kun schema. Tester (11 nye, baseline 361 → 372): - 6 happy-path-tests (én per kommando) - ARG_MISSING_VALUE for --profile uten verdi - --profile + --quick kombo - --profile + --gates edge-case (--gates parses inline, ikke i FLAG_SCHEMA) - --profile + --project kombo - trekcontinue --profile (validerer at tomt valued[] nå er utvidet) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
53 lines
2.6 KiB
JavaScript
53 lines
2.6 KiB
JavaScript
// tests/parsers/arg-parser-profile.test.mjs
|
|
// SC #4: --profile valued flag MUST be recognized on all 6 voyage commands.
|
|
|
|
import { test } from 'node:test';
|
|
import { strict as assert } from 'node:assert';
|
|
import { parseArgs } from '../../lib/parsers/arg-parser.mjs';
|
|
|
|
const COMMANDS = ['trekbrief', 'trekresearch', 'trekplan', 'trekexecute', 'trekreview', 'trekcontinue'];
|
|
|
|
for (const cmd of COMMANDS) {
|
|
test(`${cmd} — --profile economy parses as valued`, () => {
|
|
const r = parseArgs('--profile economy', cmd);
|
|
assert.equal(r.flags['--profile'], 'economy', `${cmd} should accept --profile economy`);
|
|
assert.equal(r.errors.length, 0, `${cmd} should have no errors`);
|
|
assert.equal(r.unknown.length, 0, `${cmd} should not mark --profile as unknown`);
|
|
});
|
|
}
|
|
|
|
test('trekplan — --profile without value emits ARG_MISSING_VALUE', () => {
|
|
const r = parseArgs('--profile', 'trekplan');
|
|
const missing = r.errors.find((e) => e.code === 'ARG_MISSING_VALUE');
|
|
assert.ok(missing, 'must surface ARG_MISSING_VALUE');
|
|
assert.match(missing.message, /--profile/);
|
|
});
|
|
|
|
test('trekplan — --profile economy --quick combines correctly', () => {
|
|
const r = parseArgs('--profile economy --quick', 'trekplan');
|
|
assert.equal(r.flags['--profile'], 'economy');
|
|
assert.equal(r.flags['--quick'], true);
|
|
});
|
|
|
|
test('trekplan — --profile economy --gates open: --gates is unknown (parsed inline by command prose, not in FLAG_SCHEMA)', () => {
|
|
// Edge case from plan.md Step 2 (per plan-critic minor): --gates is intentionally
|
|
// NOT in FLAG_SCHEMA; commands parse it inline. Verify --profile still parses cleanly
|
|
// and --gates ends up in unknown[] / positional[] rather than colliding with --profile.
|
|
const r = parseArgs('--profile economy --gates open', 'trekplan');
|
|
assert.equal(r.flags['--profile'], 'economy');
|
|
// --gates is unknown to FLAG_SCHEMA; it lands in unknown[] and 'open' becomes positional
|
|
assert.ok(r.unknown.includes('--gates'), `expected --gates in unknown, got: ${JSON.stringify(r.unknown)}`);
|
|
assert.ok(r.positional.includes('open'), `expected 'open' as positional, got: ${JSON.stringify(r.positional)}`);
|
|
});
|
|
|
|
test('trekexecute — --profile balanced --project /tmp/p combines correctly', () => {
|
|
const r = parseArgs('--profile balanced --project /tmp/p', 'trekexecute');
|
|
assert.equal(r.flags['--profile'], 'balanced');
|
|
assert.equal(r.flags['--project'], '/tmp/p');
|
|
});
|
|
|
|
test('trekcontinue — --profile premium parses without --project', () => {
|
|
// trekcontinue had empty valued[] before v4.1 — sanity check the array is now extended
|
|
const r = parseArgs('--profile premium', 'trekcontinue');
|
|
assert.equal(r.flags['--profile'], 'premium');
|
|
});
|