fix: 改进 web-probe screenshot 参数纠错
This commit is contained in:
@@ -53,6 +53,42 @@ describe("CLI input error hierarchy", () => {
|
||||
expect(result.stdout).not.toContain("platform-infra-gitea.ts:");
|
||||
});
|
||||
|
||||
test("web-probe screenshot returns a typed non-mutating correction for --url with --path", () => {
|
||||
const result = runCli(
|
||||
"web-probe",
|
||||
"screenshot",
|
||||
"--node",
|
||||
"NC01",
|
||||
"--lane",
|
||||
"v03",
|
||||
"--url",
|
||||
"https://custom.example/workbench",
|
||||
"--path",
|
||||
"/workbench",
|
||||
"--json",
|
||||
);
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stderr).toBe("");
|
||||
const payload = JSON.parse(result.stdout) as {
|
||||
ok: boolean;
|
||||
error: {
|
||||
kind: string;
|
||||
code: string;
|
||||
reason: string;
|
||||
mutation: boolean;
|
||||
correctionCommands: string[];
|
||||
};
|
||||
};
|
||||
expect(payload.ok).toBe(false);
|
||||
expect(payload.error.kind).toBe("cli-input");
|
||||
expect(payload.error.code).toBe("web-probe-screenshot-url-path-mutually-exclusive");
|
||||
expect(payload.error.reason).toBe("custom-url-already-includes-full-path-remove-path");
|
||||
expect(payload.error.mutation).toBe(false);
|
||||
expect(payload.error.correctionCommands).toEqual([
|
||||
"bun scripts/cli.ts web-probe 'screenshot' '--node' 'NC01' '--lane' 'v03' '--url' 'https://custom.example/workbench'",
|
||||
]);
|
||||
});
|
||||
|
||||
test("Gitea full and raw input errors preserve machine JSON without a stack", () => {
|
||||
for (const outputFlag of ["--full", "--raw"]) {
|
||||
const result = runCli("platform-infra", "gitea", "status", "--target", "NC01", outputFlag, "--definitely-unsupported");
|
||||
|
||||
Reference in New Issue
Block a user