| 123456789101112131415161718192021222324252627282930313233 |
- import { describe, expect, it } from "vitest";
- import { centeredOverviewViewport } from "@/components/workbench/FlowCanvas";
- import { initialBuildId } from "@/hooks/useExecutionView";
- import { moduleAuditUrl } from "@/lib/api";
- const builds = [
- { id: "444", status: "success" },
- { id: "443", status: "success" },
- ] as const;
- describe("run selection persistence and initial canvas placement", () => {
- it("prefers the run in the URL, including an older run outside the recent list", () => {
- expect(initialBuildId([...builds], "?run=439", "443")).toBe("439");
- });
- it("uses a valid remembered run and ignores a stale remembered run", () => {
- expect(initialBuildId([...builds], "", "443")).toBe("443");
- expect(initialBuildId([...builds], "", "100")).toBe("444");
- });
- it("centers the graph bounds horizontally at overview zoom", () => {
- const viewport = centeredOverviewViewport({ x: 60, width: 3200 }, 1440);
- const renderedCenter = viewport.x + (60 + 1600) * viewport.zoom;
- expect(viewport.zoom).toBe(.2);
- expect(renderedCenter).toBe(720);
- expect(viewport.y).toBe(94);
- });
- it("builds the audit page URL from the currently selected run", () => {
- expect(moduleAuditUrl("439")).toBe("http://127.0.0.1:8788/audit/439");
- });
- });
|