Implement core value modals
This commit is contained in:
@@ -39,6 +39,7 @@ describe("buildPublishPayload", () => {
|
||||
],
|
||||
},
|
||||
],
|
||||
coreValues: [],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -58,6 +59,7 @@ describe("buildPublishPayload", () => {
|
||||
entries: [{ title: "Community", body: "We organize locally." }],
|
||||
},
|
||||
],
|
||||
coreValues: [],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -71,7 +73,7 @@ describe("buildPublishPayload", () => {
|
||||
const r = buildPublishPayload({ title: "T", sections });
|
||||
expect(r.ok).toBe(true);
|
||||
if (!r.ok) return;
|
||||
expect(r.document).toEqual({ sections });
|
||||
expect(r.document).toEqual({ sections, coreValues: [] });
|
||||
});
|
||||
|
||||
it("filters invalid section entries from state.sections", () => {
|
||||
@@ -86,8 +88,29 @@ describe("buildPublishPayload", () => {
|
||||
if (!r.ok) return;
|
||||
expect(r.document).toEqual({
|
||||
sections: [{ categoryName: "Values", entries: [{ title: "A", body: "B" }] }],
|
||||
coreValues: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("includes coreValues from selected chips and detail text", () => {
|
||||
const r = buildPublishPayload({
|
||||
title: "T",
|
||||
selectedCoreValueIds: ["1", "2"],
|
||||
coreValuesChipsSnapshot: [
|
||||
{ id: "1", label: "Alpha", state: "Selected" },
|
||||
{ id: "2", label: "Beta", state: "Selected" },
|
||||
],
|
||||
coreValueDetailsByChipId: {
|
||||
"1": { meaning: "m1", signals: "s1" },
|
||||
},
|
||||
});
|
||||
expect(r.ok).toBe(true);
|
||||
if (!r.ok) return;
|
||||
expect(r.document.coreValues).toEqual([
|
||||
{ chipId: "1", label: "Alpha", meaning: "m1", signals: "s1" },
|
||||
{ chipId: "2", label: "Beta", meaning: "", signals: "" },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseDocumentSectionsForDisplay", () => {
|
||||
|
||||
@@ -101,6 +101,25 @@ describe("createFlowStateSchema", () => {
|
||||
});
|
||||
expect(r.success).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts coreValueDetailsByChipId", () => {
|
||||
const r = createFlowStateSchema.safeParse({
|
||||
coreValueDetailsByChipId: {
|
||||
"1": { meaning: "We care about access.", signals: "Blocking access." },
|
||||
"uuid-here": { meaning: "", signals: "" },
|
||||
},
|
||||
});
|
||||
expect(r.success).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects core value detail strings that are too long", () => {
|
||||
const r = createFlowStateSchema.safeParse({
|
||||
coreValueDetailsByChipId: {
|
||||
"1": { meaning: "x".repeat(8001), signals: "y" },
|
||||
},
|
||||
});
|
||||
expect(r.success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("putDraftBodySchema", () => {
|
||||
|
||||
Reference in New Issue
Block a user