feat(web): persist workspace presentation across browser hosts — #205
This commit is contained in:
48
frontend/src/features/web/webWorkspaceSession.test.ts
Normal file
48
frontend/src/features/web/webWorkspaceSession.test.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
DEFAULT_WEB_WORKSPACE_PRESENTATION,
|
||||
parseWebWorkspacePresentationState,
|
||||
withOpenedSurface,
|
||||
} from "./webWorkspaceSession";
|
||||
|
||||
describe("web workspace presentation persistence (#205)", () => {
|
||||
it("parses the persisted presentation state and filters unknown opened surfaces", () => {
|
||||
expect(
|
||||
parseWebWorkspacePresentationState(
|
||||
JSON.stringify({
|
||||
version: 1,
|
||||
activePanel: "tickets",
|
||||
primaryRailOpen: false,
|
||||
secondaryRailOpen: true,
|
||||
openedSurfaces: {
|
||||
tickets: "tab",
|
||||
git: "window",
|
||||
projects: "tab",
|
||||
bogus: "window",
|
||||
agents: "dock",
|
||||
},
|
||||
}),
|
||||
),
|
||||
).toEqual({
|
||||
version: 1,
|
||||
activePanel: "tickets",
|
||||
primaryRailOpen: false,
|
||||
secondaryRailOpen: true,
|
||||
openedSurfaces: {
|
||||
tickets: "tab",
|
||||
git: "window",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to null for invalid or old state", () => {
|
||||
expect(parseWebWorkspacePresentationState("not-json")).toBeNull();
|
||||
expect(parseWebWorkspacePresentationState(JSON.stringify({ version: 0 }))).toBeNull();
|
||||
});
|
||||
|
||||
it("records only openable project surfaces", () => {
|
||||
expect(withOpenedSurface({}, "tickets", "tab")).toEqual({ tickets: "tab" });
|
||||
expect(withOpenedSurface(DEFAULT_WEB_WORKSPACE_PRESENTATION.openedSurfaces, "projects", "tab")).toEqual({});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user