inspector/clients/web/src/test/integration/mcp/remote/server-config.test.ts
Cliff Hall 8bb389c8e3
test: switch integration project to folder-based manifest (#1314) (#1318)
* test: switch integration project to folder-based manifest (#1314)

Replace the `integrationTests` enumeration in vite.config.ts with a
folder glob (`src/test/integration/**/*.test.ts`). Files under that
folder run in the integration vitest project (node env, 30s timeouts);
everything else runs in the unit project (happy-dom).

This removes the silent misclassification trap from #1307: a new
integration-style test no longer falls into the unit project (and
happy-dom) just because someone forgot to add it to the array.

The 13 ported v1.5 tests + their helpers move under src/test/integration/
in a strict mirror of core/ source layout (mcp/, auth/, auth/node/,
storage/). Renames use git mv so history is preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test: address PR review on #1318 (glob extensions + AGENTS doc)

- vite.config.ts: widen integrationGlob from `*.test.ts` to
  `*.test.{ts,tsx}` so the integration folder fully owns its contents.
  Without this, a `.test.tsx` placed under src/test/integration/ would
  match the unit project's `{ts,tsx}` include, fail the unit `.ts`-only
  exclude, and silently land under happy-dom — the exact misclassification
  trap this PR set out to close.
- AGENTS.md: update the line describing where integration tests live;
  it still pointed at the old `src/test/core/` location and the removed
  `integrationTests` enumeration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 11:54:49 -04:00

58 lines
2.2 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { createRemoteApp } from "@inspector/core/mcp/remote/node/server.js";
describe("createRemoteApp GET /api/config", () => {
it("includes sandboxUrl in response when option is set", async () => {
const sandboxUrl = "http://localhost:9123/sandbox";
const { app } = createRemoteApp({
dangerouslyOmitAuth: true,
allowedOrigins: ["http://127.0.0.1:6274"],
sandboxUrl,
initialConfig: { defaultEnvironment: {} },
});
const res = await app.request(new Request("http://test/api/config"));
expect(res.status).toBe(200);
const data = (await res.json()) as { sandboxUrl?: string };
expect(data.sandboxUrl).toBe(sandboxUrl);
});
it("omits sandboxUrl when option is not set", async () => {
const { app } = createRemoteApp({
dangerouslyOmitAuth: true,
allowedOrigins: ["http://127.0.0.1:6274"],
initialConfig: { defaultEnvironment: {} },
});
const res = await app.request(new Request("http://test/api/config"));
expect(res.status).toBe(200);
const data = (await res.json()) as { sandboxUrl?: string };
expect(data).not.toHaveProperty("sandboxUrl");
});
it("uses initialConfig when provided instead of env", async () => {
const { app } = createRemoteApp({
dangerouslyOmitAuth: true,
allowedOrigins: ["http://127.0.0.1:6274"],
initialConfig: {
defaultCommand: "my-server",
defaultArgs: ["--foo"],
defaultTransport: "stdio",
defaultCwd: "/tmp",
defaultEnvironment: { PATH: "/usr/bin" },
},
});
const res = await app.request(new Request("http://test/api/config"));
expect(res.status).toBe(200);
const data = (await res.json()) as {
defaultCommand?: string;
defaultArgs?: string[];
defaultTransport?: string;
defaultCwd?: string;
defaultEnvironment?: Record<string, string>;
};
expect(data.defaultCommand).toBe("my-server");
expect(data.defaultArgs).toEqual(["--foo"]);
expect(data.defaultTransport).toBe("stdio");
expect(data.defaultCwd).toBe("/tmp");
expect(data.defaultEnvironment).toEqual({ PATH: "/usr/bin" });
});
});