mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
82636e1286
* Add interactive goal setup UI * Refine goal interview skip and question flow * Fix review findings: recommendation combo, option-only recs, single deselect * Persist goal setup working JSON files * Refine goal setup copy and facts controls * Remove generated goal package from PR * Address goal setup review issues * Remove goal setup slash command adapters * Disable fact comment attachments * Fix goal setup fact comment state * Address goal setup review cleanup * Fix goal setup fact submission edge cases
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { afterEach, describe, expect, test } from "bun:test";
|
|
import { normalizeGoalSetupBundle } from "@plannotator/shared/goal-setup";
|
|
import { startGoalSetupServer, type GoalSetupServerResult } from "./goal-setup";
|
|
|
|
let server: GoalSetupServerResult | null = null;
|
|
|
|
afterEach(() => {
|
|
server?.stop();
|
|
server = null;
|
|
});
|
|
|
|
describe("goal setup server", () => {
|
|
test("serves interview bundle and resolves submitted answers", async () => {
|
|
const bundle = normalizeGoalSetupBundle({
|
|
stage: "interview",
|
|
title: "Goal setup",
|
|
questions: [{ id: "scope", prompt: "Scope?" }],
|
|
});
|
|
|
|
server = await startGoalSetupServer({
|
|
bundle,
|
|
htmlContent: "<html></html>",
|
|
origin: "claude-code",
|
|
});
|
|
|
|
const plan = await fetch(`${server.url}/api/goal-setup`).then((res) =>
|
|
res.json()
|
|
);
|
|
expect(plan.mode).toBe("goal-setup");
|
|
expect(plan.goalSetup.questions[0].id).toBe("scope");
|
|
|
|
const decision = server.waitForDecision();
|
|
const submitted = await fetch(`${server.url}/api/goal-setup/submit`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
answers: [
|
|
{
|
|
questionId: "scope",
|
|
selectedOptionIds: [],
|
|
customAnswer: "",
|
|
answer: "UI, server, and skill text.",
|
|
completed: true,
|
|
},
|
|
],
|
|
}),
|
|
}).then((res) => res.json());
|
|
|
|
expect(submitted.ok).toBe(true);
|
|
const result = await decision;
|
|
expect(result.result?.stage).toBe("interview");
|
|
if (result.result?.stage !== "interview") throw new Error("expected interview");
|
|
expect(result.result.answers[0].answer).toBe("UI, server, and skill text.");
|
|
});
|
|
});
|