Skip to content

Commit 4e88ce4

Browse files
committed
test: restore #1036 ordering regression coverage, assert tap dispatches press
Making tap a real alias deleted the only tests covering unknown-command-before-flag-validation ordering (they used tap as the unknown command). Restore them with a genuinely unknown command, and strengthen the alias test to assert the dispatched call records press with positionals preserved instead of merely not-erroring.
1 parent 58dbcbb commit 4e88ce4

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

‎src/__tests__/cli-help.test.ts‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,28 @@ test('help rejects multiple positional commands and skips daemon dispatch', asyn
150150
assert.match(result.stderr, /Error \(INVALID_ARGS\): help accepts at most one command/);
151151
});
152152

153-
test('tap is an alias for press', async () => {
153+
test('tap dispatches as press with positionals and flags preserved', async () => {
154154
const result = await runCliCapture(['tap', '@e3', '--json']);
155-
// The command should normalize to press and execute accordingly
156-
// We check that it doesn't report an unknown command error
157-
assert.doesNotMatch(result.stderr, /Error \(INVALID_ARGS\): Unknown command: tap/);
155+
assert.doesNotMatch(result.stderr, /Unknown command/);
156+
// Canonicalization: the daemon call must record press, never tap.
157+
assert.equal(result.calls.length, 1);
158+
assert.equal(result.calls[0]?.command, 'press');
159+
assert.deepEqual(result.calls[0]?.positionals, ['@e3']);
158160
});
159161

160-
test('tap with selector resolves to press command', async () => {
161-
const result = await runCliCapture(['tap', 'label="Submit"', '--json']);
162-
// The command should normalize to press and execute accordingly
163-
// We check that it doesn't report an unknown command error
164-
assert.doesNotMatch(result.stderr, /Error \(INVALID_ARGS\): Unknown command: tap/);
162+
// Regression coverage for #1036 (moved off `tap` when it became an alias):
163+
// unknown commands must be reported before per-command flag validation.
164+
test('unknown command with flags reports unknown command before flag validation', async () => {
165+
const result = await runCliCapture(['bogus-cmd', 'e3', '--session', 'foo']);
166+
assert.equal(result.code, 1);
167+
assert.equal(result.calls.length, 0);
168+
assert.match(result.stderr, /Error \(INVALID_ARGS\): Unknown command: bogus-cmd/);
169+
assert.doesNotMatch(result.stderr, /not supported for command/);
170+
});
171+
172+
test('unknown command without flags reports unknown command', async () => {
173+
const result = await runCliCapture(['bogus-cmd', 'e3']);
174+
assert.equal(result.code, 1);
175+
assert.equal(result.calls.length, 0);
176+
assert.match(result.stderr, /Error \(INVALID_ARGS\): Unknown command: bogus-cmd/);
165177
});

0 commit comments

Comments
 (0)