Spaces:
Paused
Paused
File size: 1,145 Bytes
4e7644b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import { describe, expect, it } from "vitest";
import type { CheckpointNode } from "@/api/types/checkpoints";
import { buildGraphRows } from "./graphLayout";
const node = (
commit: string,
parent_commit: string | null,
): CheckpointNode => ({
ref: `refs/auto/s/${commit}`,
kind: "auto",
session_key: "s",
name: commit,
commit,
sha: commit,
timestamp_ms: 0,
subject: commit,
query: null,
channel: "console",
restore_index: null,
parent_commit,
is_head: false,
user_id: "u",
session_id: "s",
session_title: "Session title",
});
describe("buildGraphRows", () => {
it("keeps a linear history in one lane", () => {
const rows = buildGraphRows([
node("c3", "c2"),
node("c2", "c1"),
node("c1", null),
]);
expect(rows.map((row) => row.lane)).toEqual([0, 0, 0]);
});
it("joins a restored branch back to an existing ancestor lane", () => {
const rows = buildGraphRows([
node("new", "base"),
node("old", "base"),
node("base", null),
]);
expect(rows[0].lane).toBe(0);
expect(rows[1].lane).toBe(1);
expect(rows[1].parentLane).toBe(0);
});
});
|