fix(qa): reject duplicate telegram proof controls

This commit is contained in:
Vincent Koc
2026-06-23 16:54:31 +02:00
parent e9b017d9dc
commit 2cbb4e70cc
2 changed files with 20 additions and 2 deletions

View File

@@ -326,13 +326,20 @@ export function parseArgs(argvInput: string[]): Options {
argv = argv.slice(0, commandSeparator);
}
let expectWasPassed = false;
const seenSingleValueOptions = new Set<string>();
for (let index = 0; index < argv.length; index += 1) {
const arg = argv[index];
const readValue = () => {
const readValue = (options: { repeatable?: boolean } = {}) => {
const value = argv[index + 1];
if (isMissingOptionValue(value)) {
usage();
}
if (!options.repeatable) {
if (seenSingleValueOptions.has(arg)) {
throw new Error(`${arg} was provided more than once`);
}
seenSingleValueOptions.add(arg);
}
index += 1;
return value;
};
@@ -351,7 +358,7 @@ export function parseArgs(argvInput: string[]): Options {
opts.expect = [];
expectWasPassed = true;
}
opts.expect.push(readValue());
opts.expect.push(readValue({ repeatable: true }));
} else if (arg === "--gateway-port") {
opts.gatewayPort = parseTcpPort(readValue(), "--gateway-port");
} else if (arg === "--id") {

View File

@@ -157,6 +157,17 @@ describe("telegram user Crabbox proof log polling", () => {
expect(parseArgs(["--text", "-ping"]).text).toBe("-ping");
});
it("rejects duplicate single-value proof controls while keeping repeated expectations", () => {
expect(() =>
parseArgs(["--output-dir", ".artifacts/one", "--output-dir", ".artifacts/two"]),
).toThrow("--output-dir was provided more than once");
expect(parseArgs(["--expect", "OpenClaw", "--expect", "ready"]).expect).toEqual([
"OpenClaw",
"ready",
]);
});
it("uses unique default output dirs", () => {
const firstOutputDir = parseArgs([]).outputDir;
const secondOutputDir = parseArgs([]).outputDir;