fix(qa): reject duplicate gateway smoke options

This commit is contained in:
Vincent Koc
2026-06-23 14:52:31 +02:00
parent 475252453b
commit 5078ffdeb4
2 changed files with 36 additions and 0 deletions
+9
View File
@@ -49,9 +49,14 @@ function usage(): string {
}
function validateArgs(argv: readonly string[]): void {
const seen = new Set<string>();
for (let index = 0; index < argv.length; index += 1) {
const arg = argv[index] ?? "";
if (BOOLEAN_FLAGS.has(arg)) {
if (seen.has(arg)) {
throw new GatewaySmokeArgError(`${arg} was provided more than once`);
}
seen.add(arg);
continue;
}
if (VALUE_FLAGS.has(arg)) {
@@ -59,6 +64,10 @@ function validateArgs(argv: readonly string[]): void {
if (!value || value.startsWith("-")) {
throw new GatewaySmokeArgError(`${arg} requires a value`);
}
if (seen.has(arg)) {
throw new GatewaySmokeArgError(`${arg} was provided more than once`);
}
seen.add(arg);
index += 1;
continue;
}
@@ -223,6 +223,33 @@ describe("gateway-smoke", () => {
}
});
it("rejects duplicate CLI args before connecting", () => {
for (const [flag, args] of [
[
"--url",
["--url", "ws://127.0.0.1:9", "--url", "ws://127.0.0.1:10", "--token", "token"],
],
[
"--token",
["--url", "ws://127.0.0.1:9", "--token", "one", "--token", "two"],
],
["--help", ["--help", "--help"]],
] as const) {
const result = spawnSync(
process.execPath,
["--import", "tsx", "scripts/dev/gateway-smoke.ts", ...args],
{
cwd: process.cwd(),
encoding: "utf8",
},
);
expect(result.status).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr.trim()).toBe(`${flag} was provided more than once`);
}
});
it("passes against a loopback gateway websocket using the real client", async () => {
const stdout: string[] = [];
const stderr: string[] = [];