run-selection.test.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. import { describe, expect, it } from "vitest";
  2. import { centeredOverviewViewport } from "@/components/workbench/FlowCanvas";
  3. import { initialBuildId } from "@/hooks/useExecutionView";
  4. import { moduleAuditUrl } from "@/lib/api";
  5. const builds = [
  6. { id: "444", status: "success" },
  7. { id: "443", status: "success" },
  8. ] as const;
  9. describe("run selection persistence and initial canvas placement", () => {
  10. it("prefers the run in the URL, including an older run outside the recent list", () => {
  11. expect(initialBuildId([...builds], "?run=439", "443")).toBe("439");
  12. });
  13. it("uses a valid remembered run and ignores a stale remembered run", () => {
  14. expect(initialBuildId([...builds], "", "443")).toBe("443");
  15. expect(initialBuildId([...builds], "", "100")).toBe("444");
  16. });
  17. it("centers the graph bounds horizontally at overview zoom", () => {
  18. const viewport = centeredOverviewViewport({ x: 60, width: 3200 }, 1440);
  19. const renderedCenter = viewport.x + (60 + 1600) * viewport.zoom;
  20. expect(viewport.zoom).toBe(.2);
  21. expect(renderedCenter).toBe(720);
  22. expect(viewport.y).toBe(94);
  23. });
  24. it("builds the audit page URL from the currently selected run", () => {
  25. expect(moduleAuditUrl("439")).toBe("http://127.0.0.1:8788/audit/439");
  26. });
  27. });