37 lines
1.6 KiB
TypeScript
37 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { mergeProjectSetupState, sanitizeProjectSetupState } from "../src/repositories/projectSetupState.js";
|
|
|
|
describe("project setup state persistence", () => {
|
|
it("round-trips rich wizard fields while rejecting unsupported top-level state", () => {
|
|
const setup = sanitizeProjectSetupState({
|
|
id: "spoofed-project",
|
|
name: "Spoofed name",
|
|
firstRun: { documentationDepth: "Deep", repoFolders: ["docs/00-project"] },
|
|
constraints: [{ id: "constraint-1", description: "Keep data durable" }],
|
|
workspaceState: { projectId: "wizard-project", primaryObjective: "Ship the first slice" },
|
|
repositoryIntakes: [{ id: "not-part-of-project-setup" }],
|
|
});
|
|
|
|
expect(setup).toMatchObject({
|
|
firstRun: { documentationDepth: "Deep", repoFolders: ["docs/00-project"] },
|
|
constraints: [{ id: "constraint-1", description: "Keep data durable" }],
|
|
workspaceState: { projectId: "wizard-project", primaryObjective: "Ship the first slice" },
|
|
});
|
|
expect(setup).not.toHaveProperty("id");
|
|
expect(setup).not.toHaveProperty("name");
|
|
expect(setup).not.toHaveProperty("repositoryIntakes");
|
|
});
|
|
|
|
it("always lets canonical database fields win over setup state", () => {
|
|
expect(mergeProjectSetupState(
|
|
{ activeContextPackId: "starter-pack", workspaceState: { primaryObjective: "Wizard objective" }, name: "Spoofed" },
|
|
{ id: "canonical", name: "Canonical" },
|
|
)).toEqual({
|
|
activeContextPackId: "starter-pack",
|
|
workspaceState: { primaryObjective: "Wizard objective" },
|
|
id: "canonical",
|
|
name: "Canonical",
|
|
});
|
|
});
|
|
});
|