From c010fafe45aad3c8a9a9e96556d35d2965763e2c Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sat, 24 Oct 2026 07:32:54 +0800 Subject: [PATCH] test(cli): align fixtures with current owning contracts --- tests/boundary/cli/analysisViewCli.test.ts | 2 +- .../cli/explicitSensitiveArgumentsCli.test.ts | 3 ++- tests/boundary/cli/filteredArrayOutput.test.ts | 11 +++++++++-- tests/boundary/cli/finishAnalysisCommand.test.ts | 2 +- tests/boundary/cli/jsonOutput.test.ts | 8 +++++++- tests/boundary/cli/nativeUiScenarioInputCli.test.ts | 11 +++++------ tests/boundary/cli/wasmCleanupCli.test.ts | 2 +- tests/boundary/process/runtimeBundle.test.ts | 2 ++ .../javascriptFilesystemErrors.test.ts | 6 +++--- 9 files changed, 31 insertions(+), 16 deletions(-) rename tests/{boundary/mcp => process-global}/javascriptFilesystemErrors.test.ts (94%) diff --git a/tests/boundary/cli/analysisViewCli.test.ts b/tests/boundary/cli/analysisViewCli.test.ts index 32621844a1..6603b9b22c 100644 --- a/tests/boundary/cli/analysisViewCli.test.ts +++ b/tests/boundary/cli/analysisViewCli.test.ts @@ -315,7 +315,7 @@ cliTest( const unsupportedRequest = join(root, "unsupported-view.json"); const unsupportedInput = { source: { kind: "inline", evidence: parent }, - view: { kind: "page", collection: "sections" }, + view: { kind: "page", collection: "sections", offset: 0, limit: 20 }, }; await writeFile(unsupportedRequest, JSON.stringify(unsupportedInput)); const unsupported = await cli.run({ diff --git a/tests/boundary/cli/explicitSensitiveArgumentsCli.test.ts b/tests/boundary/cli/explicitSensitiveArgumentsCli.test.ts index ababf3b6c3..2416368621 100644 --- a/tests/boundary/cli/explicitSensitiveArgumentsCli.test.ts +++ b/tests/boundary/cli/explicitSensitiveArgumentsCli.test.ts @@ -112,7 +112,8 @@ describe("CLI --sensitive-value parser diagnostics", () => { expectExcluded(result, ["mitmproxy"]); expect(JSON.parse(result.stdout)).toMatchObject({ code: "VALIDATION_ERROR", - message: expect.stringContaining('"har"|"[REDACTED]"|"saz"'), + message: + "REA could not read the command arguments. Check the named argument and its expected type, then try again.", fieldErrors: [ expect.objectContaining({ code: "invalid_value", path: "format" }), ], diff --git a/tests/boundary/cli/filteredArrayOutput.test.ts b/tests/boundary/cli/filteredArrayOutput.test.ts index 28900bddf7..cedf2e0789 100644 --- a/tests/boundary/cli/filteredArrayOutput.test.ts +++ b/tests/boundary/cli/filteredArrayOutput.test.ts @@ -300,7 +300,10 @@ it.each(["json", "jsonl", "yaml", "toon", "md"] as const)( .split("\n") .map((line) => JSON.parse(line)), ).toEqual(expected); - else expect(outputs[0]).toBe(`${Formatter.format(expected, format)}\n`); + else if (format === "md") { + expect(outputs[0]).toContain(`| ${JSON.stringify(expected[0]!.rows)} |`); + expect(outputs[0]).not.toContain("[object Object]"); + } else expect(outputs[0]).toBe(`${Formatter.format(expected, format)}\n`); expect(projectionSource[0]?.rows[0]?.retained).toEqual([0, 10]); }, ); @@ -324,6 +327,7 @@ it.each(["json", "jsonl", "yaml", "toon", "md"] as const)( .split("\n") .map((line) => JSON.parse(line)), ).toEqual([1, null, null]); + else if (format === "md") expect(output).toBe("[1,null,null]\n"); else expect(output).toBe(`${Formatter.format(selected, format)}\n`); expect(value).toEqual([{ selected: 1 }, {}, { selected: null }]); }, @@ -356,7 +360,10 @@ it.each(["json", "jsonl", "yaml", "toon", "md"] as const)( .split("\n") .map((line) => JSON.parse(line)), ).toEqual(expected); - else expect(outputs[0]).toBe(`${Formatter.format(expected, format)}\n`); + else if (format === "md") { + expect(outputs[0]).toContain(`| ${JSON.stringify(expected[0]!.rows)} |`); + expect(outputs[0]).not.toContain("[object Object]"); + } else expect(outputs[0]).toBe(`${Formatter.format(expected, format)}\n`); expect(projectionSource).toEqual(before); }, ); diff --git a/tests/boundary/cli/finishAnalysisCommand.test.ts b/tests/boundary/cli/finishAnalysisCommand.test.ts index 0e6c2a6aca..acd81cd23a 100644 --- a/tests/boundary/cli/finishAnalysisCommand.test.ts +++ b/tests/boundary/cli/finishAnalysisCommand.test.ts @@ -95,7 +95,7 @@ it("retains late cancellation and completed Evidence when close also fails", asy ); expect(result).toMatchObject({ code: "cleanup_incomplete", - category: "execution_failure", + category: "cancelled", details: { partial_observation: evidence, diagnostics: { diff --git a/tests/boundary/cli/jsonOutput.test.ts b/tests/boundary/cli/jsonOutput.test.ts index 9604a35f3b..5f6b795585 100644 --- a/tests/boundary/cli/jsonOutput.test.ts +++ b/tests/boundary/cli/jsonOutput.test.ts @@ -586,6 +586,7 @@ describe("full-output token counts", () => { category: "unavailable", message: "Missing target", retryable: false, + remediation: { action: "Select an available target." }, }, { command: "fixture", duration: "0ms", format: "toon" }, ); @@ -728,8 +729,13 @@ describe("CLI result output surface", () => { }, details: { reported_limits: { + // Token counting uses the compact pipe encoding, unlike the + // terminal digest above. Count leaves, separators and framing. formatted_characters: - expectedCharacters + + count * encodedLeaf.length + + (count - 1) + + '{"methods":[]}'.length + + 1 + JSON.stringify({ ok: true, data: null, meta: report.meta }) .length - 4, diff --git a/tests/boundary/cli/nativeUiScenarioInputCli.test.ts b/tests/boundary/cli/nativeUiScenarioInputCli.test.ts index 7bbd2e2bcc..12ce7a2e13 100644 --- a/tests/boundary/cli/nativeUiScenarioInputCli.test.ts +++ b/tests/boundary/cli/nativeUiScenarioInputCli.test.ts @@ -22,17 +22,16 @@ const runCapture = async (cli: TestCli, steps: string | undefined) => { describe("native UI scenario CLI input", () => { cliTest( - "rejects omitted steps under the shared scenario contract", + "rejects omitted steps at CLI argument admission", async ({ cli }) => { const result = await runCapture(cli, undefined); expect(result.exitCode).not.toBe(0); expect(result.json).toMatchObject({ - code: "invalid_request", - details: { - operation: "capture_native_ui_scenario", - issues: [{ path: ["steps"], reason: "missing_argument" }], - }, + code: "VALIDATION_ERROR", + fieldErrors: [ + expect.objectContaining({ path: "steps", missing: true }), + ], }); }, ); diff --git a/tests/boundary/cli/wasmCleanupCli.test.ts b/tests/boundary/cli/wasmCleanupCli.test.ts index ce5718b04f..4486059b36 100644 --- a/tests/boundary/cli/wasmCleanupCli.test.ts +++ b/tests/boundary/cli/wasmCleanupCli.test.ts @@ -108,7 +108,7 @@ it.runIf(canDenyCleanup)( expect(primaryAndCleanupFail).toMatchObject({ code: "cleanup_incomplete", details: { - execution_failure: "execution_failure", + execution_failure: "invalid_request", diagnostics: { primary_error: { code: "cleanup_incomplete" }, cleanup_error: { code: "cleanup_incomplete" }, diff --git a/tests/boundary/process/runtimeBundle.test.ts b/tests/boundary/process/runtimeBundle.test.ts index a10beef125..7a642da892 100644 --- a/tests/boundary/process/runtimeBundle.test.ts +++ b/tests/boundary/process/runtimeBundle.test.ts @@ -49,6 +49,7 @@ export const lazyUrl = import.meta.url;`, "dist/generatedPackageMetadata.js": 'export const generatedPackageMetadata = { version: "1.0.0" };', "dist/cli.js": 'export { facts, run } from "./main.js";', + "dist/cliBuiltinArguments.js": "export {};\n", "dist/cliOutput.js": 'export { facts } from "./provider/probe λ.js";', "dist/cli/cliResultOutput.js": 'export { facts } from "../provider/probe λ.js";', @@ -135,6 +136,7 @@ export const run = async () => { await workspace.mkdir("dist/cli"); await workspace.write("package.json", '{"type":"module"}'); for (const path of [ + "dist/cliBuiltinArguments.js", "dist/cliOutput.js", "dist/cli/cliResultOutput.js", "dist/mcpDoctor.js", diff --git a/tests/boundary/mcp/javascriptFilesystemErrors.test.ts b/tests/process-global/javascriptFilesystemErrors.test.ts similarity index 94% rename from tests/boundary/mcp/javascriptFilesystemErrors.test.ts rename to tests/process-global/javascriptFilesystemErrors.test.ts index 9020fab1cd..d19db6265b 100644 --- a/tests/boundary/mcp/javascriptFilesystemErrors.test.ts +++ b/tests/process-global/javascriptFilesystemErrors.test.ts @@ -1,6 +1,6 @@ import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { expect, it, vi } from "vitest"; -import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; +import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js"; const fault = vi.hoisted(() => ({ method: "", @@ -31,8 +31,8 @@ vi.mock("node:fs/promises", async (importOriginal) => { }, }; }); -import { createServer } from "../../../src/server/createServer.js"; -import { createTestBinarySession } from "../../fixtures/binarySession.js"; +import { createServer } from "../../src/server/createServer.js"; +import { createTestBinarySession } from "../fixtures/binarySession.js"; it.each([ { method: "lstat", code: "EACCES" },