mirror of
https://github.com/morluto/rea
synced 2026-10-25 22:08:11 -04:00
test(cli): align fixtures with current owning contracts
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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" }),
|
||||
],
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 }),
|
||||
],
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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" },
|
||||
|
||||
@@ -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",
|
||||
|
||||
+3
-3
@@ -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" },
|
||||
Reference in New Issue
Block a user