Skip to content

Commit 66feec4

Browse files
committed
test(batch): pin every advertised step key, and hint the removed-shape refusal
The example-validation test accepted a step whose optional key the reader silently dropped — readInput ignores unknown keys, so a renamed settle or interactiveOnly kept the test green while help advertised a step that does less than it claims. Every printed key must now survive into the parsed input. The removed positionals/flags refusal carries the CLI shape hint like its three sibling refusals.
1 parent b27a2a4 commit 66feec4

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎src/cli-schema/cli-help-examples.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,23 @@ test('every batch step printed by CLI help is accepted by its own command reader
131131
for (const { line, steps } of examples) {
132132
for (const step of steps) {
133133
assert.ok(isCommandName(step.command), `Unknown command in help example: ${line}`);
134+
let parsed: unknown;
134135
try {
135-
findCommandMetadata(step.command).readInput(step.input);
136+
parsed = findCommandMetadata(step.command).readInput(step.input);
136137
} catch (error) {
137138
const message = error instanceof Error ? error.message : String(error);
138139
assert.fail(
139140
`Help advertises a batch step ${step.command} rejects:\n${line}\n ${message}`,
140141
);
141142
}
143+
// readInput IGNORES unknown keys, so acceptance alone cannot pin an optional field: a
144+
// renamed `settle` or `interactiveOnly` would parse to a step that silently does less
145+
// than the help advertises. Every printed key must survive into the parsed input.
146+
assert.deepEqual(
147+
Object.keys(parsed as Record<string, unknown>).sort(),
148+
Object.keys(step.input).sort(),
149+
`Help advertises a batch step ${step.command} key its reader drops:\n${line}`,
150+
);
142151
covered.add(step.command);
143152
}
144153
}

‎src/cli/batch-steps.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function readCliBatchStep(step: unknown, stepNumber: number): BatchStep {
3737
throw new AppError(
3838
'INVALID_ARGS',
3939
`Batch step ${stepNumber} uses removed field(s): ${fields}. Use {"command":"...","input":{...}}. Example: {"command":"open","input":{"app":"settings","platform":"ios"}}.`,
40+
{ hint: CLI_BATCH_STEP_SHAPE_HINT },
4041
);
4142
}
4243
assertAllowedKeys(

0 commit comments

Comments
 (0)