perf(tests): reuse CLI worker for Evidence bundle data cases

This commit is contained in:
morluto committed 2026-11-09 14:58:24 +08:00
1 parent 99d00d1041
commit 84f3401dcf
1 file changed
+12 -10
@@ -22,7 +22,7 @@ import {
updateResidualUnknown,
} from "../../../src/domain/residualUnknown.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { cliTest } from "../../support/cli/cliFixture.js";
import { cliTest, runFileCli } from "../../support/cli/cliFixture.js";
const revisionBundle = () => {
const records = ["open", "investigate"].map((operation) =>
@@ -78,7 +78,7 @@ cliTest(
[["compare", "bundle.json", ""], "right"],
[["evidence-export", "missing.json", ""], "output"],
] as const) {
const result = await cli.run({
const result = await runFileCli(cli, {
arguments: [...args, "--json"],
cwd: root,
});
@@ -138,7 +138,7 @@ cliTest(
["evidence-export", { source: " bundle.json", output: " exported.json" }],
["compare", { left: " bundle.json", right: " other.json" }],
] as const) {
const result = await cli.run({
const result = await runFileCli(cli, {
arguments: [command, "--schema", "--json"],
});
expect(result.exitCode, result.stderr).toBe(0);
@@ -246,7 +246,7 @@ cliTest.for([
: operation === "compare-left"
? ["compare", path, canonical]
: ["compare", canonical, path];
const result = await cli.run({
const result = await runFileCli(cli, {
arguments: [...arguments_, "--json"],
environment: { REA_LOG_LEVEL: "silent" },
});
@@ -325,7 +325,7 @@ cliTest(
await writeFile(source, JSON.stringify(bundle));
for (const full of [false, true]) {
const output = join(root, `${label}-${String(full)}.json`);
const result = await cli.run({
const result = await runFileCli(cli, {
arguments: [
"evidence-export",
source,
@@ -387,7 +387,7 @@ cliTest(
{ ...bundle, unknowns: bundle.unknowns.slice(1) },
]) {
await writeFile(path, JSON.stringify(invalid));
const result = await cli.run({
const result = await runFileCli(cli, {
arguments: ["evidence-import", path, "--json"],
});
expect(result.exitCode).toBe(1);
@@ -414,7 +414,7 @@ cliTest(
);
await writeFile(path, JSON.stringify(createEvidenceBundle([record])));
const output = await cli.run({
const output = await runFileCli(cli, {
arguments: [
"inspect-evidence-bundle",
JSON.stringify({ path, detail: "complete" }),
@@ -466,12 +466,14 @@ cliTest(
"--filter-output",
"records.0.normalized_result",
];
const json = await cli.run({ arguments: [...base, "--json"] });
const json = await runFileCli(cli, { arguments: [...base, "--json"] });
expect(json.exitCode, json.stderr).toBe(0);
expect(json.stdout).toContain(JSON.stringify(result.text));
expect(json.stdout).toContain(JSON.stringify(result.type));
expect(json.stdout).toContain(JSON.stringify(result.literal));
const markdown = await cli.run({ arguments: [...base, "--format", "md"] });
const markdown = await runFileCli(cli, {
arguments: [...base, "--format", "md"],
});
expect(markdown.exitCode, markdown.stderr).toBe(0);
expect(markdown.stdout).toContain("left\\|right\\\\tail<br>next");
expect(markdown.stdout).toContain("List&lt;string&gt;");
@@ -495,7 +497,7 @@ cliTest(
records: [record],
};
await writeFile(path, JSON.stringify(bundle));
const imported = await cli.run({
const imported = await runFileCli(cli, {
arguments: ["evidence-import", path, "--json"],
});
expect(imported.exitCode).toBe(1);