feat(canvas): 交互可读性 - 优化连线、字号与工作条
This commit is contained in:
1 parent
db9e18da1e
commit
ec5abc967e
12 files changed
+210
-57
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
|
||||
import { filterCanvasDisplayConnections } from "@/lib/canvas/canvas-connection-visibility";
|
||||
import { CanvasNodeType, type CanvasDisplayConnection } from "@/types/canvas";
|
||||
|
||||
function connection(id: string, fromNodeId: string, toNodeId: string): CanvasDisplayConnection {
|
||||
const node = (nodeId: string) => ({ id: nodeId, type: CanvasNodeType.Text, title: nodeId, position: { x: 0, y: 0 }, width: 100, height: 80, metadata: {} });
|
||||
return { connection: { id, fromNodeId, toNodeId }, from: node(fromNodeId), to: node(toNodeId) };
|
||||
}
|
||||
|
||||
describe("canvas connection visibility", () => {
|
||||
const connections = [connection("a", "one", "two"), connection("b", "two", "three"), connection("c", "four", "five")];
|
||||
|
||||
test("keeps all connections when disabled", () => {
|
||||
expect(filterCanvasDisplayConnections(connections, { enabled: false })).toEqual(connections);
|
||||
});
|
||||
|
||||
test("shows only direct connections for hovered and selected nodes", () => {
|
||||
expect(filterCanvasDisplayConnections(connections, { enabled: true, hoveredNodeId: "three", selectedNodeIds: new Set(["one"]) }).map((item) => item.connection.id)).toEqual(["a", "b"]);
|
||||
});
|
||||
|
||||
test("keeps an explicitly selected connection visible", () => {
|
||||
expect(filterCanvasDisplayConnections(connections, { enabled: true, selectedConnectionId: "c" }).map((item) => item.connection.id)).toEqual(["c"]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user