Show the remade card names on template detail, matching final review, and say one size fits all.
This commit is contained in:
1 parent
f634a91bb2
commit
54a4871ad1
4 files changed
+256
-8
No files matched your search
@@ -1,10 +1,15 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildAppliedTemplateCreateFlowState } from "../../lib/create/applyTemplatePrefill";
|
||||
import { buildFinalReviewCategoriesFromState } from "../../lib/create/buildFinalReviewCategories";
|
||||
import {
|
||||
templateBodyToCategories,
|
||||
templateBodyToReviewData,
|
||||
templateCategoryToGroupKey,
|
||||
templateReviewDataForSlug,
|
||||
templateSummaryFromBody,
|
||||
} from "../../lib/create/templateReviewMapping";
|
||||
import templateChipsFile from "../../data/templates/templateChips.json";
|
||||
import templateReviewMessages from "../../messages/en/create/templateReview.json";
|
||||
|
||||
describe("templateReviewMapping", () => {
|
||||
it("maps body sections to Rule categories", () => {
|
||||
@@ -117,3 +122,113 @@ describe("templateReviewMapping", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const FINAL_REVIEW_NAMES = {
|
||||
values: "Values",
|
||||
communication: "Communication",
|
||||
membership: "Membership",
|
||||
decisions: "Decision-making",
|
||||
conflict: "Conflict management",
|
||||
};
|
||||
|
||||
const STALE_CONSENSUS_BODY = {
|
||||
sections: [
|
||||
{
|
||||
categoryName: "Values",
|
||||
entries: [{ title: "Community Care", body: "" }],
|
||||
},
|
||||
{
|
||||
categoryName: "Communication",
|
||||
entries: [
|
||||
{ title: "In-Person Meetings", body: "" },
|
||||
{ title: "Loomio", body: "" },
|
||||
],
|
||||
},
|
||||
{
|
||||
categoryName: "Membership",
|
||||
entries: [{ title: "Peer Sponsorship", body: "" }],
|
||||
},
|
||||
{
|
||||
categoryName: "Decision-making",
|
||||
entries: [
|
||||
{ title: "Consensus or Vote-Based Approval", body: "" },
|
||||
{ title: "Consensus Decision-Making", body: "" },
|
||||
],
|
||||
},
|
||||
{
|
||||
categoryName: "Conflict management",
|
||||
entries: [{ title: "Facilitated Negotiation", body: "" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe("templateReviewDataForSlug", () => {
|
||||
it("lists remade catalog names for consensus, not API body titles", () => {
|
||||
const { categories } = templateReviewDataForSlug(
|
||||
"consensus",
|
||||
STALE_CONSENSUS_BODY,
|
||||
);
|
||||
const labels = categories.flatMap((row) =>
|
||||
row.chipOptions.map((chip) => chip.label),
|
||||
);
|
||||
expect(labels).toContain("How we run meetings");
|
||||
expect(labels).toContain("In-person meetings");
|
||||
expect(labels).toContain("Conflict ladder");
|
||||
expect(labels).toContain("Community care");
|
||||
expect(labels).toContain("Decision speeds");
|
||||
expect(labels).not.toContain("In-Person Meetings");
|
||||
expect(labels).not.toContain("Community Care");
|
||||
expect(labels).not.toContain("Peer Sponsorship");
|
||||
expect(labels).not.toContain("Facilitated Negotiation");
|
||||
});
|
||||
|
||||
it("matches Use without changes final-review labels", () => {
|
||||
const slugs = Object.keys(
|
||||
(templateChipsFile as { templates: Record<string, unknown> }).templates,
|
||||
);
|
||||
for (const slug of slugs) {
|
||||
const detail = templateReviewDataForSlug(slug, STALE_CONSENSUS_BODY);
|
||||
const seeded = buildAppliedTemplateCreateFlowState({
|
||||
slug,
|
||||
body: STALE_CONSENSUS_BODY,
|
||||
mode: "useWithoutChanges",
|
||||
});
|
||||
const review = buildFinalReviewCategoriesFromState(
|
||||
seeded,
|
||||
FINAL_REVIEW_NAMES,
|
||||
);
|
||||
const detailByName = new Map(
|
||||
detail.categories.map((row) => [
|
||||
row.name,
|
||||
row.chipOptions.map((chip) => chip.label),
|
||||
]),
|
||||
);
|
||||
for (const row of review) {
|
||||
if (row.chips.length === 0) continue;
|
||||
expect(detailByName.get(row.name), slug).toEqual(row.chips);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("falls back to body titles when the slug is not in the catalog", () => {
|
||||
const cats = templateReviewDataForSlug("unknown-template", {
|
||||
sections: [
|
||||
{
|
||||
categoryName: "Values",
|
||||
entries: [{ title: "Solidarity", body: "Long body" }],
|
||||
},
|
||||
],
|
||||
}).categories;
|
||||
expect(cats[0].chipOptions.map((chip) => chip.label)).toEqual([
|
||||
"Solidarity",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("template review intro", () => {
|
||||
it("reads one size fits all", () => {
|
||||
expect(templateReviewMessages.intro.description).toContain(
|
||||
"one size fits all",
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user