mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-06 02:48:25 +00:00
Replace React Router loader/action state paths with SWR query and mutation hooks. Add targeted run and board EventSource managers that invalidate SWR keys, and refresh embedded SPA assets.
26 lines
1,017 B
TypeScript
26 lines
1,017 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
|
|
import { queryKeys } from "./query-keys";
|
|
import { queryKeysForRunEvent } from "./run-events";
|
|
|
|
describe("queryKeys", () => {
|
|
test("uses API path strings as stable SWR keys", () => {
|
|
expect(queryKeys.auth.me()).toBe("/api/v1/auth/me");
|
|
expect(queryKeys.runs.files("run 1")).toBe("/api/v1/runs/run%201/files");
|
|
expect(queryKeys.runs.graph("run-1", "TB")).toBe("/api/v1/runs/run-1/graph?direction=TB");
|
|
});
|
|
|
|
test("event-mapped keys match query hook resources", () => {
|
|
expect(queryKeysForRunEvent("run-1", "checkpoint.completed")).toEqual([
|
|
queryKeys.runs.files("run-1"),
|
|
]);
|
|
expect(queryKeysForRunEvent("run-1", "stage.completed", "stage-1")).toEqual([
|
|
queryKeys.runs.stages("run-1"),
|
|
queryKeys.runs.events("run-1", 1000),
|
|
queryKeys.runs.graph("run-1", "LR"),
|
|
queryKeys.runs.graph("run-1", "TB"),
|
|
queryKeys.runs.detail("run-1"),
|
|
queryKeys.runs.stageTurns("run-1", "stage-1"),
|
|
]);
|
|
});
|
|
});
|