fix(cli): emit empty structured filter projections (#914)
This commit is contained in:
@@ -8,6 +8,7 @@ import { workspaceCliTest } from "../../support/cli/workspaceCliFixture.js";
|
||||
|
||||
import {
|
||||
renderCliOutputArgumentError,
|
||||
renderEmptyFilteredCliOutput,
|
||||
sanitizeCliOutput,
|
||||
validateCliOutputArguments,
|
||||
} from "../../../src/cliOutput.js";
|
||||
@@ -140,9 +141,85 @@ describe("CLI output argument and sanitization boundary", () => {
|
||||
meta: { command: "analyze" },
|
||||
});
|
||||
});
|
||||
|
||||
it("renders an explicit empty projection for structured filtered output", () => {
|
||||
for (const format of ["json", "jsonl", "yaml"])
|
||||
expect(
|
||||
renderEmptyFilteredCliOutput([
|
||||
"providers",
|
||||
"--format",
|
||||
format,
|
||||
"--filter-output",
|
||||
"missing",
|
||||
]),
|
||||
).toBe("{}\n");
|
||||
expect(
|
||||
renderEmptyFilteredCliOutput(["providers", "--filter-output", "missing"]),
|
||||
).toBeUndefined();
|
||||
expect(
|
||||
renderEmptyFilteredCliOutput(["providers", "--format", "json"]),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("compiled CLI output boundary", () => {
|
||||
workspaceCliTest(
|
||||
"emits valid JSON when an output filter misses the top-level result",
|
||||
async ({ cli }) => {
|
||||
const result = await cli.run({
|
||||
arguments: [
|
||||
"analyze-javascript-application",
|
||||
"tests/conformance/readiness/javascript-cli",
|
||||
"--format",
|
||||
"json",
|
||||
"--filter-output",
|
||||
"summary",
|
||||
],
|
||||
});
|
||||
expect(result).toMatchObject({
|
||||
exitCode: 0,
|
||||
stdout: "{}\n",
|
||||
stderr: "",
|
||||
json: {},
|
||||
});
|
||||
const nested = await cli.run({
|
||||
arguments: [
|
||||
"analyze-javascript-application",
|
||||
"tests/conformance/readiness/javascript-cli",
|
||||
"--format",
|
||||
"json",
|
||||
"--filter-output",
|
||||
"normalized_result.not_a_field",
|
||||
],
|
||||
});
|
||||
expect(nested).toMatchObject({
|
||||
exitCode: 0,
|
||||
stderr: "",
|
||||
json: { normalized_result: {} },
|
||||
});
|
||||
const selected = await cli.run({
|
||||
arguments: [
|
||||
"analyze-javascript-application",
|
||||
"tests/conformance/readiness/javascript-cli",
|
||||
"--format",
|
||||
"json",
|
||||
"--filter-output",
|
||||
"normalized_result.summary",
|
||||
],
|
||||
});
|
||||
expect(selected).toMatchObject({
|
||||
exitCode: 0,
|
||||
stderr: "",
|
||||
json: {
|
||||
normalized_result: {
|
||||
summary: expect.objectContaining({ browser_windows: 0 }),
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
CLI_INTEGRATION_TIMEOUT_MS,
|
||||
);
|
||||
|
||||
workspaceCliTest(
|
||||
"sanitizes a real missing-argument dispatcher failure",
|
||||
async ({ cli }) => {
|
||||
|
||||
Reference in New Issue
Block a user