79 lines
2.8 KiB
TypeScript
79 lines
2.8 KiB
TypeScript
import Fastify from "fastify";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import { registerProjectRoutes } from "../src/routes/projects.js";
|
|
|
|
describe("project create setup contract", () => {
|
|
const apps: Array<ReturnType<typeof Fastify>> = [];
|
|
|
|
afterEach(async () => {
|
|
await Promise.all(apps.splice(0).map((app) => app.close()));
|
|
});
|
|
|
|
it("returns the rich wizard setup only after the create request succeeds", async () => {
|
|
const app = Fastify();
|
|
apps.push(app);
|
|
await registerProjectRoutes(app, { dataSource: "fixtures" });
|
|
|
|
const response = await app.inject({
|
|
method: "POST",
|
|
url: "/api/projects",
|
|
payload: {
|
|
id: "durable-wizard",
|
|
name: "Durable wizard",
|
|
description: "A project whose complete wizard state survives the create boundary.",
|
|
domain: "webapp",
|
|
primaryGoal: "Persist the complete setup",
|
|
targetAudience: "Project owners",
|
|
dna: {
|
|
vision: "Keep project setup durable",
|
|
goals: ["Persist the complete setup", "Reload it safely"],
|
|
nonGoals: ["Do not navigate before success"],
|
|
targetAudience: "Project owners",
|
|
principles: ["Review before truth"],
|
|
successMetrics: [{ metric: "setup-roundtrip", target: "= true", operator: "=" }],
|
|
maturityStage: "Discovery",
|
|
revision: 1,
|
|
},
|
|
setupState: {
|
|
id: "must-not-override",
|
|
firstRun: {
|
|
documentationDepth: "Full - exhaustive design system",
|
|
repositoryProfile: { preferredStack: "React + Fastify", repository: "Acme/durable-wizard" },
|
|
},
|
|
constraints: [{ id: "constraint-1", description: "No false success" }],
|
|
workspaceState: {
|
|
projectId: "durable-wizard",
|
|
primaryObjective: "Build the first durable slice",
|
|
focusAreas: [],
|
|
openTasksCount: 2,
|
|
openBugCount: 0,
|
|
activeSection: "workspace",
|
|
updatedAt: "2026-08-30T00:00:00.000Z",
|
|
notes: ["Created from the wizard"],
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(response.statusCode).toBe(201);
|
|
expect(response.json().data).toMatchObject({
|
|
id: "durable-wizard",
|
|
name: "Durable wizard",
|
|
dna: {
|
|
goals: ["Persist the complete setup", "Reload it safely"],
|
|
targetAudience: "Project owners",
|
|
},
|
|
constraints: [{ id: "constraint-1", description: "No false success" }],
|
|
firstRun: {
|
|
documentationDepth: "Full - exhaustive design system",
|
|
repositoryProfile: { preferredStack: "React + Fastify", repository: "Acme/durable-wizard" },
|
|
},
|
|
workspaceState: {
|
|
projectId: "durable-wizard",
|
|
primaryObjective: "Build the first durable slice",
|
|
openTasksCount: 2,
|
|
},
|
|
});
|
|
}, 15_000);
|
|
});
|