feat(canvas): finalize mixer reconnect swap and related updates

This commit is contained in:
2026-04-11 07:42:42 +02:00
parent f3dcaf89f2
commit 028fce35c2
52 changed files with 3859 additions and 272 deletions

View File

@@ -1,9 +1,10 @@
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";
import type { Edge as RFEdge, Node as RFNode } from "@xyflow/react";
import {
computeEdgeInsertLayout,
computeEdgeInsertReflowPlan,
getSingleCharacterHotkey,
withResolvedCompareData,
} from "../canvas-helpers";
import {
@@ -315,6 +316,24 @@ describe("canvas preview graph helpers", () => {
});
});
describe("getSingleCharacterHotkey", () => {
it("returns a lowercase printable hotkey for single-character keys", () => {
expect(getSingleCharacterHotkey({ key: "K", type: "keydown" })).toBe("k");
expect(getSingleCharacterHotkey({ key: "v", type: "keydown" })).toBe("v");
expect(getSingleCharacterHotkey({ key: "Escape", type: "keydown" })).toBe("");
});
it("returns an empty string and logs when the event has no string key", () => {
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => undefined);
expect(getSingleCharacterHotkey({ type: "keydown" } as { key?: string; type: string })).toBe("");
expect(warnSpy).toHaveBeenCalledWith("[Canvas] keyboard event missing string key", {
eventType: "keydown",
key: undefined,
});
});
});
describe("computeEdgeInsertLayout", () => {
it("shifts source and target along a horizontal axis when spacing is too tight", () => {
const source = createNode({