mcpAppsHostRunner.test.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. parseMcpAppsHostOptions,
  4. resolveMcpAppsHostLaunch,
  5. } from "../scripts/mcp-apps-host-options.mjs";
  6. describe("MCP App formal regression selection", () => {
  7. it("uses Xvfb and container-only Chromium flags for isolated Linux replay", () => {
  8. expect(
  9. resolveMcpAppsHostLaunch("electron", ["case.cjs"], { ZCODE_E2E_CONTAINER: "1" }),
  10. ).toEqual({
  11. command: "xvfb-run",
  12. args: ["--auto-servernum", "electron", "case.cjs", "--no-sandbox", "--disable-dev-shm-usage"],
  13. });
  14. expect(
  15. resolveMcpAppsHostLaunch("electron", ["case.cjs"], {
  16. ZCODE_E2E_CONTAINER: "1",
  17. DISPLAY: ":99",
  18. }).command,
  19. ).toBe("electron");
  20. });
  21. it("leaves native Electron launches sandboxed", () => {
  22. expect(resolveMcpAppsHostLaunch("electron", ["case.cjs"], {})).toEqual({
  23. command: "electron",
  24. args: ["case.cjs"],
  25. });
  26. });
  27. it("selects only the approved readiness case and preserves its artifact path", () => {
  28. expect(
  29. parseMcpAppsHostOptions(["--session-ready-only", "--output-dir", "path with spaces"]),
  30. ).toEqual({ modes: ["session-ready"], outputDir: "path with spaces", reuseAgentBuild: false });
  31. });
  32. it("keeps the existing managed regression group", () => {
  33. expect(parseMcpAppsHostOptions(["--managed-only", "--reuse-agent-build"])).toEqual({
  34. modes: ["interaction", "managed", "managed-empty"],
  35. outputDir: undefined,
  36. reuseAgentBuild: true,
  37. });
  38. });
  39. it.each([
  40. ["--session-ready-only", "--managed-only"],
  41. ["--session-redy-only"],
  42. ["--session-ready-only", "--output-dir"],
  43. ["--session-ready-only", "--output-dir", ""],
  44. ])("rejects ambiguous or invalid selection instead of running the full suite: %j", (...args) => {
  45. expect(() => parseMcpAppsHostOptions(args)).toThrow();
  46. });
  47. });