refactor: navigate presentation by scene and beat

This commit is contained in:
lda
2026-07-04 16:42:23 +07:00 Verified
parent c6018c4a86
commit 5947ee625c
13 changed files with 446 additions and 219 deletions
@@ -0,0 +1,46 @@
import { describe, expect, it } from "vitest";
import {
hashForLocation,
locationFromHash,
nextMainLocation,
previousMainLocation,
} from "./storyboard-navigation.js";
import { defaultMainLocation, type MainLocation } from "./storyboard.js";
describe("storyboard navigation", () => {
it("round-trips main and discussion hashes", () => {
const main: MainLocation = { kind: "main", sceneId: "lifecycle", beatId: "deployment" };
expect(locationFromHash(hashForLocation(main))).toEqual(main);
expect(locationFromHash("#discuss/hosted-automation")).toEqual({
kind: "discussion",
branchId: "hosted-automation",
});
});
it("falls back for unknown scene, beat, and branch hashes", () => {
expect(locationFromHash("#scene/missing/nope")).toEqual(defaultMainLocation);
expect(locationFromHash("#scene/lifecycle/nope")).toEqual(defaultMainLocation);
expect(locationFromHash("#discuss/nope")).toEqual(defaultMainLocation);
});
it("advances within a scene before advancing to the next scene", () => {
expect(nextMainLocation({ kind: "main", sceneId: "thesis", beatId: "title" })).toEqual({
kind: "main",
sceneId: "thesis",
beatId: "substrate",
});
expect(nextMainLocation({ kind: "main", sceneId: "thesis", beatId: "substrate" })).toEqual({
kind: "main",
sceneId: "problem",
beatId: "direct-actions",
});
});
it("rewinds across scene boundaries", () => {
expect(previousMainLocation({ kind: "main", sceneId: "problem", beatId: "direct-actions" })).toEqual({
kind: "main",
sceneId: "thesis",
beatId: "substrate",
});
});
});