import { readFileSync } from "node:fs"; import { resolve } from "node:path"; import { describe, expect, test } from "bun:test"; import { moduleGroupSource } from "./helpers/module-group-source"; const projectSource = moduleGroupSource("pages/canvas/project.tsx"); const selectionControllerSource = readFileSync(resolve(import.meta.dir, "../src/pages/canvas/use-canvas-selection-controller.ts"), "utf8"); const flat = (text: string) => text.replace(/\s+/g, " "); describe("canvas node drag overlays", () => { test("hides floating editors and selection controls for the whole drag preview", () => { expect(projectSource).toContain("const isCanvasNodeMoving = isNodeDragging || Boolean(dragPreview?.nodeIds.size);"); // 面板浮层的守卫必须同时成立:类型排除、框选、拖拽预览。断言整段条件而不是某一行的 // 字面量,避免上游拆行或新增类型排除(Panorama 等)后把排版变化报成契约失效。 const flatSource = flat(projectSource); const overlayStart = flatSource.indexOf("{dialogNode &&"); const overlayCondition = flatSource.slice(overlayStart, flatSource.indexOf("