import { readFileSync } from "node:fs" import { join } from "node:path" import { afterEach, beforeEach, describe, expect, it, vi } from "vitest" // The MCP preview page's script, run in this document with a stubbed // server (fetch) and draw.io iframe (its postMessage), so the tab's side of // a recreated session can be driven step by step const dir = join(process.cwd(), "packages/mcp-server/src/preview") const DRAWIO = "https://embed.diagrams.net" const html = readFileSync(join(dir, "index.html"), "utf8") .replace("{{CSS}}", "") .replace("{{SESSION_BADGE}}", "") .replaceAll("{{DISABLED}}", "") .replace("{{DRAWIO_URL}}", "about:blank") .replace("{{SESSION_JSON}}", '"mcp-test"') .replace("{{ORIGIN_JSON}}", JSON.stringify(DRAWIO)) const scripts = [...html.matchAll(/