Skip setup questions on the template path and collect name, photo, and description without recommendations.

Customize opens a dialog then walks the template decks; Use without changes lands on final review with Has Name Field. Template cards stay first, the engine is not called, and the catalog no longer shows a recommended tag.
This commit is contained in:
adilallo committed 2026-11-09 17:34:33 -07:00
1 parent 53d236d0d5
commit 6498d52541
37 files changed
+1450 -733

No files matched your search

+93
View File
@@ -0,0 +1,93 @@
import { describe, expect, it } from "vitest";
import { deckData, templateDeck } from "../../lib/create/deckRecommend";
import {
isTemplateCreatePath,
orderIdsFirst,
templateCardIdsForDeck,
templateChipCounts,
templatePathFromState,
templateValueIdsForSlug,
} from "../../lib/create/templatePath";
describe("templatePathFromState", () => {
it("reads a customize or use-without-changes pin", () => {
expect(templatePathFromState({})).toBeNull();
expect(
templatePathFromState({
pendingTemplateAction: { slug: "consensus", mode: "customize" },
}),
).toEqual({ slug: "consensus", mode: "customize" });
expect(
isTemplateCreatePath({
pendingTemplateAction: {
slug: "consensus",
mode: "useWithoutChanges",
},
}),
).toBe(true);
});
it("ignores a pin with no slug or an unknown mode", () => {
expect(
templatePathFromState({
pendingTemplateAction: { slug: " ", mode: "customize" },
}),
).toBeNull();
expect(
templatePathFromState({
pendingTemplateAction: {
slug: "consensus",
mode: "other" as "customize",
},
}),
).toBeNull();
});
});
describe("template chips", () => {
it("returns the consensus template's values and communication cards", () => {
expect(templateValueIdsForSlug("consensus")).toEqual([
"consensus",
"community-care",
"horizontalism",
]);
expect(templateCardIdsForDeck("consensus", "communication")).toEqual([
"how-we-run-meetings",
"in-person-meetings",
"loomio",
]);
expect(templateChipCounts("consensus")).toEqual({
values: 3,
cards: 10,
});
});
it("returns null counts for an unknown slug", () => {
expect(templateChipCounts("not-a-template")).toBeNull();
});
});
describe("orderIdsFirst", () => {
it("puts named ids first and keeps the rest in their original order", () => {
const items = [{ id: "a" }, { id: "b" }, { id: "c" }, { id: "d" }];
expect(orderIdsFirst(items, ["c", "a", "missing"])).toEqual([
{ id: "c" },
{ id: "a" },
{ id: "b" },
{ id: "d" },
]);
});
});
describe("templateDeck", () => {
it("puts the template's cards first, then the rest of the deck, with no cut", () => {
const data = deckData("communication");
const firstIds = templateCardIdsForDeck("consensus", "communication");
const ordered = templateDeck(data, firstIds);
expect(ordered.first).toEqual(firstIds);
expect(ordered.rest.some((id) => firstIds.includes(id))).toBe(false);
const all = [...ordered.first, ...ordered.rest];
expect(new Set(all).size).toBe(all.length);
expect(all.length).toBe(Object.keys(data.engine.cards).length);
});
});