import { describe, expect, spyOn, test } from "bun:test" import { NativeImage } from "@opentui/core" import { existsSync } from "node:fs" import { renderDiagram } from "./render" import { rasterDiagram } from "./raster" import { diagramFrame } from "./geometry" import { resolveDiagramSvg } from "./svg" import { DiagramJobs } from "./jobs" import { jsonLines } from "./protocol" import { SOURCE_LIMIT, type DiagramInput } from "./types" const input: DiagramInput = { source: "graph TD\n A[中文:开始处理长标签] --> B{检查数据}\n B -->|通过| C[完成]", width: 800, scale: 2, // macOS must discover its system-managed font location, not use a test override. fonts: process.platform === "darwin" ? undefined : { regular: { path: "C:/Windows/Fonts/msyh.ttc", postscriptName: "MicrosoftYaHei" }, bold: { path: "C:/Windows/Fonts/msyhbd.ttc", postscriptName: "MicrosoftYaHei-Bold" }, mono: { path: "C:/Windows/Fonts/consola.ttf", postscriptName: "Consolas" }, }, colors: { foreground: "#202020", muted: "#666666", surface: "#eeeeee", border: "#888888", accent: "#3366cc" }, } const svg = (body: string) => `${body}` test("SVG image policy rejects external resources and executable elements", () => { for (const body of ['', '