test: consolidate redundant assertions into boundary workflows

Remove getter, enum, cloned-projection, cache-identity, and obsolete profile assertions along with the shadow JSON Schema engine and dead test-only APIs. Retain producer, filesystem, SDK, lifecycle, integrity, and malformed-format coverage.

Document the priority of real end-to-end workflows, boundary integration, and producer goldens.
This commit is contained in:
morluto
2026-10-09 20:26:46 +08:00
parent 2f02eff988
commit b71a591a60
35 changed files with 199 additions and 2192 deletions
@@ -254,17 +254,8 @@ it("distinguishes an unreported Java version from an unsupported old version", a
it("cancels an in-flight Java readiness probe", async () => {
const root = await createTestTempDirectory("rea-jadx-cancel-");
const jar = join(root, "jadx-headless-mcp.jar");
const javaHome = join(root, "fake-jdk");
const bin = join(javaHome, "bin");
const java = join(bin, "java");
const marker = join(root, "java-probe-started");
await mkdir(bin, { recursive: true });
const { javaHome, marker } = await createHangingJdk(root);
await writeJadxJarInventory(jar);
await writeFile(
java,
`#!/bin/sh\nexec ${process.execPath} -e 'require("node:fs").writeFileSync(process.argv[1], "ready"); setTimeout(() => {}, 30_000)' '${marker}'\n`,
);
await chmod(java, 0o700);
const controller = new AbortController();
const pending = inspectJadxAvailability(
{ REA_JADX_MCP_JAR: jar, JAVA_HOME: javaHome },
@@ -272,11 +263,13 @@ it("cancels an in-flight Java readiness probe", async () => {
);
try {
await expect
.poll(() =>
readFile(marker, "utf8").then(
() => true,
() => false,
),
.poll(
() =>
readFile(marker, "utf8").then(
() => true,
() => false,
),
{ timeout: 10_000 },
)
.toBe(true);
controller.abort();
@@ -290,17 +283,8 @@ it("cancels an in-flight Java readiness probe", async () => {
it("reports a killed Java probe as unresolved instead of missing runtime", async () => {
const root = await createTestTempDirectory("rea-jadx-timeout-");
const jar = join(root, "jadx-headless-mcp.jar");
const javaHome = join(root, "fake-jdk");
const bin = join(javaHome, "bin");
const java = join(bin, "java");
const marker = join(root, "java-probe-started");
await mkdir(bin, { recursive: true });
const { javaHome, java } = await createHangingJdk(root);
await writeJadxJarInventory(jar);
await writeFile(
java,
`#!/bin/sh\nexec ${process.execPath} -e 'require("node:fs").writeFileSync(process.argv[1], "ready"); setTimeout(() => {}, 30_000)' '${marker}'\n`,
);
await chmod(java, 0o700);
const availability = await inspectJadxAvailability({
REA_JADX_MCP_JAR: jar,
@@ -320,6 +304,20 @@ it("reports a killed Java probe as unresolved instead of missing runtime", async
expect(availability.reason).not.toContain("Select a full JDK");
});
const createHangingJdk = async (root: string) => {
const javaHome = join(root, "fake-jdk");
const bin = join(javaHome, "bin");
const java = join(bin, "java");
const marker = join(root, "java-probe-started");
await mkdir(bin, { recursive: true });
await writeFile(
java,
`#!/bin/sh\nexec ${process.execPath} -e 'require("node:fs").writeFileSync(process.argv[1], "ready"); setTimeout(() => {}, 30_000)' '${marker}'\n`,
);
await chmod(java, 0o700);
return { javaHome, java, marker };
};
const createFakeJdk = async (
root: string,
compiler = true,
-56
View File
@@ -1,56 +0,0 @@
import { execFile } from "node:child_process";
import { promisify } from "node:util";
import { expect, it } from "vitest";
const execute = promisify(execFile);
const runCli = async (arguments_: readonly string[]) => {
try {
const result = await execute(
process.execPath,
["scripts/rea.mjs", ...arguments_],
{
cwd: process.cwd(),
env: { ...process.env, REA_LOG_LEVEL: "silent" },
timeout: 15_000,
},
);
return { exitCode: 0, ...result };
} catch (cause: unknown) {
if (
typeof cause === "object" &&
cause !== null &&
"code" in cause &&
typeof cause.code === "number" &&
"stdout" in cause &&
typeof cause.stdout === "string" &&
"stderr" in cause &&
typeof cause.stderr === "string"
)
return {
exitCode: cause.code,
stdout: cause.stdout,
stderr: cause.stderr,
};
throw cause;
}
};
it("shows MCP doctor help without starting a server and keeps option errors actionable", async () => {
const parentHelp = await runCli(["mcp", "--help"]);
expect(parentHelp.exitCode).toBe(0);
expect(parentHelp.stdout).toContain("doctor");
const help = await runCli(["mcp", "doctor", "--help"]);
expect(help.exitCode).toBe(0);
expect(help.stdout).toContain("Usage: rea mcp doctor [options]");
expect(help.stdout).toContain("--format <toon|json|yaml|md|jsonl>");
expect(help.stdout).toContain("--full-output");
const invalid = await runCli(["mcp", "doctor", "--not-an-option"]);
expect(invalid.exitCode).toBe(1);
expect(invalid.stdout).toContain(
"Unknown mcp doctor option: --not-an-option",
);
});
@@ -17,7 +17,6 @@ import {
import { nativeUiResultSchema } from "../../../src/domain/native/nativeUiObservation.js";
import { processCaptureSchema } from "../../../src/domain/process/processCapture.js";
import { toolRegistrationOptions } from "../../../src/server/toolRegistrationOptions.js";
import { inlineLocalJsonSchemaReferences } from "../../fixtures/localJsonSchemaReferences.js";
const record = (value: unknown): Record<string, unknown> => {
if (typeof value !== "object" || value === null || Array.isArray(value))
@@ -25,6 +24,25 @@ const record = (value: unknown): Record<string, unknown> => {
return value as Record<string, unknown>;
};
const schemaNode = (
root: Record<string, unknown>,
value: unknown,
): Record<string, unknown> => {
const schema = record(value);
if (typeof schema.$ref !== "string") return schema;
if (!schema.$ref.startsWith("#/"))
throw new Error("Expected a local advertised schema reference");
const referenced = schema.$ref
.slice(2)
.split("/")
.reduce<unknown>(
(parent, key) =>
record(parent)[key.replaceAll("~1", "/").replaceAll("~0", "~")],
root,
);
return { ...record(referenced), ...schema };
};
it("advertises semantic output invariants and keeps producers aligned with Zod", async () => {
const contracts = [
toolContract("capture_native_ui_scenario"),
@@ -56,7 +74,7 @@ it("advertises semantic output invariants and keeps producers aligned with Zod",
if (tool?.outputSchema === undefined)
throw new Error(`${name} output schema missing`);
const outputSchema = record(tool.outputSchema);
const result = record(record(outputSchema.properties).result);
const result = record(record(outputSchema.properties).normalized_result);
const standaloneResultSchema = z.record(z.string(), z.unknown()).parse({
...result,
...(typeof outputSchema.$schema === "string"
@@ -66,8 +84,11 @@ it("advertises semantic output invariants and keeps producers aligned with Zod",
? {}
: { $defs: outputSchema.$defs }),
});
const node = (value: unknown) =>
schemaNode(standaloneResultSchema, value);
return {
result: record(inlineLocalJsonSchemaReferences(standaloneResultSchema)),
result: node(result),
node,
validate: new Ajv2020({
strict: false,
validateFormats: false,
@@ -76,18 +97,18 @@ it("advertises semantic output invariants and keeps producers aligned with Zod",
};
const native = outputResultSchema("capture_native_ui_scenario");
const initial = record(record(native.result.properties).initial);
const screenshotUnion = record(record(initial.properties).screenshot);
const initial = native.node(record(native.result.properties).initial);
const screenshotUnion = native.node(record(initial.properties).screenshot);
const screenshotVariants = screenshotUnion.anyOf;
if (!Array.isArray(screenshotVariants))
throw new Error("Expected nullable screenshot schema");
const screenshotProperties = record(
record(screenshotVariants[0]).properties,
native.node(screenshotVariants[0]).properties,
);
expect(record(screenshotProperties.base64).description).toContain(
expect(native.node(screenshotProperties.base64).description).toContain(
"PNG signature",
);
expect(record(screenshotProperties.sha256).description).toContain(
expect(native.node(screenshotProperties.sha256).description).toContain(
"decoded PNG bytes",
);
const pngBytes = Buffer.from("not a PNG");
@@ -124,7 +145,7 @@ it("advertises semantic output invariants and keeps producers aligned with Zod",
const process = outputResultSchema("capture_process_scenario");
expect(process.result.description).toContain("canonical scenario");
expect(process.result.description).toContain(
"older input without an event journal",
"The event journal is required",
);
const validCapture = processCaptureSchema.parse(
EMPTY_PROCESS_CAPTURE_EXAMPLE,