Final review edit modals created

This commit is contained in:
adilallo
2026-04-20 17:57:17 -06:00
parent c08cd62872
commit a22d53e860
27 changed files with 2410 additions and 620 deletions
+47 -1
View File
@@ -1,5 +1,8 @@
import { describe, expect, it } from "vitest";
import { buildTemplateCustomizePrefill } from "../../lib/create/applyTemplatePrefill";
import {
buildCoreValuesPrefillFromTemplateBody,
buildTemplateCustomizePrefill,
} from "../../lib/create/applyTemplatePrefill";
import coreValuesMessages from "../../messages/en/create/customRule/coreValues.json";
function coreValuePresetId(label: string): string {
@@ -107,3 +110,46 @@ describe("buildTemplateCustomizePrefill", () => {
expect(prefill).toEqual({});
});
});
describe("buildCoreValuesPrefillFromTemplateBody", () => {
it("returns {} for malformed bodies", () => {
expect(buildCoreValuesPrefillFromTemplateBody(null)).toEqual({});
expect(buildCoreValuesPrefillFromTemplateBody({})).toEqual({});
expect(
buildCoreValuesPrefillFromTemplateBody({ sections: "nope" }),
).toEqual({});
});
it("returns {} when the body has no Values section", () => {
expect(
buildCoreValuesPrefillFromTemplateBody({
sections: [
{ categoryName: "Communication", entries: [{ title: "Signal" }] },
],
}),
).toEqual({});
});
it("seeds the snapshot + selected ids from the Values section only", () => {
const prefill = buildCoreValuesPrefillFromTemplateBody({
sections: [
{
categoryName: "Values",
entries: [
{ title: "Consensus", body: "" },
{ title: "Community Care", body: "" },
],
},
{
categoryName: "Communication",
entries: [{ title: "Signal", body: "" }],
},
],
});
const selected = prefill.selectedCoreValueIds ?? [];
expect(selected).toContain(coreValuePresetId("Consensus"));
expect(selected).toContain(coreValuePresetId("Community Care"));
// Methods should not be touched by the values-only helper.
expect(prefill.selectedCommunicationMethodIds).toBeUndefined();
});
});