Files
ttstd-infinite-canvas/web/test/canvas-node-drag-overlays.test.ts
wurendao007 8ebceecbb6 perf(canvas): 画布媒体 - 优化媒体加载、播放器与节点交互 (#357)
Merge origin/main at fb089b2 and retain canvas media performance, player layout, and interaction updates.

Co-authored-by: ddCat <2695092045@qq.com>
2026-08-31 09:00:37 +08:00

22 lines
1.4 KiB
TypeScript

import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { describe, expect, test } from "bun:test";
const projectSource = readFileSync(resolve(import.meta.dir, "../src/pages/canvas/project.tsx"), "utf8");
const selectionControllerSource = readFileSync(resolve(import.meta.dir, "../src/pages/canvas/use-canvas-selection-controller.ts"), "utf8");
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);");
expect(projectSource).toContain("dialogNode.type !== CanvasNodeType.Drawing && !selectionBox && !isCanvasNodeMoving");
expect(projectSource).toContain("angleNode?.metadata?.content && !isCanvasNodeMoving");
expect(projectSource).toContain("emotionNode?.metadata?.content && !isCanvasNodeMoving");
expect(projectSource).toContain("selectedNodeBounds && !selectionBox && !isCanvasNodeMoving");
expect(projectSource).toContain("node={isCanvasNodeMoving || nodeImageSettingsOpen || emotionNodeId ? null : toolbarNode}");
expect(projectSource).toContain("onNodeDragEnd: handleNodeDragEnd");
expect(projectSource).toContain("setDialogNodeId(node.id);");
expect(selectionControllerSource).toContain("if (clickedNodeId) onNodeDragEnd?.(clickedNodeId);");
});
});