feat(canvas): PR #500 - 合并多角度与切分并保留本地 Agent 改造
This commit is contained in:
@@ -3,16 +3,17 @@ import { describe, expect, test } from "bun:test";
|
||||
|
||||
const source = readFileSync(new URL("../src/pages/canvas/project.tsx", import.meta.url), "utf8");
|
||||
|
||||
describe("image angle editor (#432)", () => {
|
||||
test("uses a centered dismissible modal instead of a node-anchored overlay", () => {
|
||||
const dialog = source.slice(source.indexOf("{angleNode?.metadata?.content"), source.indexOf("{emotionNode?.metadata?.content"));
|
||||
expect(dialog).toContain("<Modal");
|
||||
expect(dialog).toContain("centered");
|
||||
expect(dialog).toContain("onCancel={() => setAngleNodeId(null)}");
|
||||
describe("image angle editor", () => {
|
||||
test("anchors the 3D angle editor to the selected node and follows drag", () => {
|
||||
const dialog = source.slice(source.indexOf("{angleNode?.metadata?.content"), source.indexOf("{lightingNode?.metadata?.content"));
|
||||
expect(dialog).toContain("CanvasNodePanelOverlay");
|
||||
expect(dialog).toContain("CanvasNodeAnglePanel");
|
||||
expect(dialog).toContain("dragOffset={dragPreview");
|
||||
expect(dialog).toContain("isDragging={isNodeDragging");
|
||||
expect(dialog).toContain("onClose={() => setAngleNodeId(null)}");
|
||||
expect(dialog).toContain("destroyOnHidden");
|
||||
expect(dialog).not.toContain("CanvasNodePanelOverlay");
|
||||
expect(dialog).not.toContain("isCanvasNodeMoving");
|
||||
expect(dialog).toContain("generateAngleNode(angleNode, params)");
|
||||
expect(dialog).not.toContain("<Modal");
|
||||
expect(dialog).not.toContain("AppModal");
|
||||
expect(dialog).not.toContain("destroyOnHidden");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
|
||||
import { applyCanvasSelectionStrategy, canvasSelectionHitsBounds, createCanvasSelectionBounds, createCanvasSelectionSpatialIndexCache, resolveCanvasPointerIntent, resolveCanvasSelectionHitMode, resolveCanvasSelectionPreviewDelta, resolveCanvasSelectionStrategy } from "@/lib/canvas/canvas-selection";
|
||||
import { applyCanvasSelectionStrategy, canvasSelectionHitsBounds, createCanvasSelectionBounds, createCanvasSelectionSpatialIndexCache, offsetSelectedNodeBounds, resolveCanvasPointerIntent, resolveCanvasSelectionHitMode, resolveCanvasSelectionPreviewDelta, resolveCanvasSelectionStrategy, selectedNodesWorldBounds } from "@/lib/canvas/canvas-selection";
|
||||
import { CanvasNodeType, type CanvasNodeData } from "@/types/canvas";
|
||||
|
||||
describe("canvas selection semantics", () => {
|
||||
@@ -95,6 +95,19 @@ describe("canvas selection semantics", () => {
|
||||
expect(globalStyles).toContain(".canvas-cursor-select");
|
||||
expect(globalStyles).not.toContain("filter='drop-shadow");
|
||||
});
|
||||
|
||||
test("offsets multi-select bounds with the live drag preview", () => {
|
||||
const bounds = selectedNodesWorldBounds([
|
||||
node("a", 100, 40),
|
||||
node("b", 300, 80),
|
||||
]);
|
||||
expect(bounds).toEqual({ left: 100, top: 40, width: 360, height: 130, count: 2 });
|
||||
expect(offsetSelectedNodeBounds(bounds!, { x: 40, y: -20 })).toEqual({ left: 140, top: 20, width: 360, height: 130, count: 2 });
|
||||
expect(selectedNodesWorldBounds([
|
||||
node("a", 100, 40),
|
||||
node("b", 300, 80),
|
||||
], { x: 40, y: -20, nodeIds: new Set(["a", "b"]) })).toEqual({ left: 140, top: 20, width: 360, height: 130, count: 2 });
|
||||
});
|
||||
});
|
||||
|
||||
function node(id: string, x: number, y: number, metadata: CanvasNodeData["metadata"] = {}): CanvasNodeData {
|
||||
|
||||
Reference in New Issue
Block a user