import { mkdtempSync, readFileSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; import { join, resolve } from "node:path"; import { spawnSync } from "node:child_process"; import { expect } from "vitest"; import { test } from "@openwork/testkit"; const repoRoot = resolve(import.meta.dirname, "../.."); test("MCP agent rejects standalone GET without triggering the Bun SDK retry loop", ({ evidence }) => { const reportDir = mkdtempSync(join(tmpdir(), "openwork-mcp-agent-standalone-get-")); try { const build = spawnSync("pnpm", [ "--filter", "@openwork-ee/den-api", "run", "build:mcp-apps", ], { cwd: repoRoot, encoding: "utf8", maxBuffer: 10 * 1024 * 1024, timeout: 120_000, }); const buildOutput = `${build.stdout}${build.stderr}`; expect(build.error, buildOutput).toBeUndefined(); expect(build.status, buildOutput).toBe(0); const suites = [ { file: "test/agent-mcp-routes.test.ts", tests: 3 }, { file: "test/mcp-membership-revocation.test.ts", tests: 20 }, { file: "test/mcp-agent-standalone-get.test.ts", tests: 2 }, ]; for (const [index, suite] of suites.entries()) { const reportPath = join(reportDir, `bun-junit-${String(index)}.xml`); const result = spawnSync("pnpm", [ "--filter", "@openwork-ee/den-api", "exec", "bun", "test", "--conditions", "development", "--timeout", "15000", suite.file, "--reporter=junit", "--reporter-outfile", reportPath, ], { cwd: repoRoot, encoding: "utf8", maxBuffer: 10 * 1024 * 1024, timeout: 60_000, }); const output = `${result.stdout}${result.stderr}`; expect(result.error, output).toBeUndefined(); expect(result.status, output).toBe(0); const junit = readFileSync(reportPath, "utf8"); const summary = junit.match(/]*>/)?.[0] ?? ""; expect(summary).toContain(`tests="${String(suite.tests)}"`); expect(summary).toContain('failures="0"'); expect(summary).toContain('skipped="0"'); expect(junit).not.toContain("