Files
IdeA/frontend/src/features/web/webWorkspaceSession.test.ts

49 lines
1.4 KiB
TypeScript

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({});
});
});