Keep the template picker in the create flow, make catalog cards real links, and stop showing a fake community when review has no draft.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
adilallo
2026-09-10 15:22:46 -06:00
co-authored by Cursor
parent 3f9a8395be
commit 90db213413
31 changed files with 412 additions and 126 deletions
+16 -32
View File
@@ -54,30 +54,18 @@ describe("Templates page (/templates)", () => {
}
});
test("each template card navigates to review flow for its slug", async () => {
const user = userEvent.setup();
test("each template card is a link to review flow for its slug", () => {
render(
<TemplatesPageClient initialGridEntries={GOVERNANCE_TEMPLATE_CATALOG} />,
);
await user.click(
screen.getByRole("button", { name: /Consensus/i }),
);
await waitFor(() => {
expect(testRouter.push).toHaveBeenCalledWith(
"/create/review-template/consensus",
);
});
testRouter.push.mockClear();
await user.click(
screen.getByRole("button", { name: /Solidarity Network/i }),
);
await waitFor(() => {
expect(testRouter.push).toHaveBeenCalledWith(
"/create/review-template/solidarity-network",
);
});
for (const entry of GOVERNANCE_TEMPLATE_CATALOG) {
expect(
screen.getByRole("link", {
name: `Learn more about ${entry.title} governance pattern`,
}),
).toHaveAttribute("href", `/create/review-template/${entry.slug}`);
}
});
test("direct entry (no ?fromFlow=1): wipes anonymous draft before navigating", async () => {
@@ -88,7 +76,7 @@ describe("Templates page (/templates)", () => {
);
await user.click(
screen.getByRole("button", { name: /Consensus/i }),
screen.getByRole("link", { name: /Consensus/i }),
);
await waitFor(() => {
@@ -96,9 +84,6 @@ describe("Templates page (/templates)", () => {
expect(
window.localStorage.getItem(CORE_VALUE_DETAILS_STORAGE_KEY),
).toBeNull();
expect(testRouter.push).toHaveBeenCalledWith(
"/create/review-template/consensus",
);
});
});
@@ -113,7 +98,7 @@ describe("Templates page (/templates)", () => {
);
await user.click(
screen.getByRole("button", { name: /Consensus/i }),
screen.getByRole("link", { name: /Consensus/i }),
);
expect(window.localStorage.getItem(CREATE_FLOW_ANONYMOUS_KEY)).toBe(
@@ -124,12 +109,11 @@ describe("Templates page (/templates)", () => {
).toBe(
JSON.stringify({ "1": { meaning: "stale", signals: "stale" } }),
);
// In-flow picks also pass `?fromFlow=1` on the template review URL so
// footer Back on `/create/review-template/…` returns to `/create/review`.
await waitFor(() => {
expect(testRouter.push).toHaveBeenCalledWith(
"/create/review-template/consensus?fromFlow=1",
);
});
expect(
screen.getByRole("link", { name: /Consensus/i }),
).toHaveAttribute(
"href",
"/create/review-template/consensus?fromFlow=1",
);
});
});