Keep every picked card on the finished Rule, and wait for its words before Continue.
This commit is contained in:
1 parent
a846169960
commit
a2815ae05f
16 files changed
+417
-114
No files matched your search
@@ -241,6 +241,14 @@ describe("FinalReviewScreen — prefilled selections", () => {
|
||||
expect(
|
||||
screen.getByRole("button", { name: "Signal, missing words" }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText("Add words before you finish"),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(
|
||||
/These still need words: Accessibility, Signal, Open admission/,
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("warns when binding arbitration sits next to a join that records no yes", async () => {
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
parseDocumentSectionsForDisplay,
|
||||
parseSectionsFromCreateFlowState,
|
||||
} from "../../lib/create/buildPublishPayload";
|
||||
import { mergeCoreValueDetailWithPresets } from "../../lib/create/finalReviewChipPresets";
|
||||
import type { CreateFlowState } from "../../app/(app)/create/types";
|
||||
|
||||
describe("buildPublishPayload", () => {
|
||||
@@ -144,15 +143,9 @@ describe("buildPublishPayload", () => {
|
||||
});
|
||||
expect(r.ok).toBe(true);
|
||||
if (!r.ok) return;
|
||||
const preset2 = mergeCoreValueDetailWithPresets("2", "Beta", undefined);
|
||||
expect(r.document.coreValues).toEqual([
|
||||
{ chipId: "1", label: "Alpha", meaning: "m1", signals: "s1" },
|
||||
{
|
||||
chipId: "2",
|
||||
label: "Beta",
|
||||
meaning: preset2.meaning,
|
||||
signals: preset2.signals,
|
||||
},
|
||||
{ chipId: "2", label: "Beta", meaning: "", signals: "" },
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -188,11 +181,12 @@ describe("buildPublishPayload — methodSelections", () => {
|
||||
expect(ms?.communication?.length).toBe(1);
|
||||
expect(ms?.communication?.[0]?.id).toBe("slack");
|
||||
const first = ms?.communication?.[0];
|
||||
expect(first?.sections.corePrinciple.length).toBeGreaterThan(10);
|
||||
expect(first?.sections.corePrinciple).toBe("");
|
||||
const entries =
|
||||
(r.document.sections as Array<{ entries: Array<{ blocks?: unknown[] }> }>)[0]
|
||||
?.entries;
|
||||
expect(entries?.[0]?.blocks?.length).toBeGreaterThanOrEqual(1);
|
||||
(r.document.sections as Array<{
|
||||
entries: Array<{ title: string; body: string; blocks?: unknown[] }>;
|
||||
}>)[0]?.entries;
|
||||
expect(entries?.[0]).toEqual({ title: "Slack", body: "" });
|
||||
});
|
||||
|
||||
it("uses customMethodCardMetaById label when preset id is unknown", () => {
|
||||
@@ -251,7 +245,7 @@ describe("buildPublishPayload — methodSelections", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("emits preset-only sections when a method is selected without an override", () => {
|
||||
it("keeps blank card parts blank when a method is selected without an override", () => {
|
||||
const r = buildPublishPayload({
|
||||
title: "T",
|
||||
selectedCommunicationMethodIds: ["signal"],
|
||||
@@ -270,9 +264,7 @@ describe("buildPublishPayload — methodSelections", () => {
|
||||
};
|
||||
expect(entry.id).toBe("signal");
|
||||
expect(entry.label).toBe("Signal");
|
||||
// Preset corePrinciple is non-empty for `signal` in the shipped messages
|
||||
// file — proves we read presets when no override is present.
|
||||
expect(entry.sections.corePrinciple.length).toBeGreaterThan(0);
|
||||
expect(entry.sections.corePrinciple).toBe("");
|
||||
});
|
||||
|
||||
it("does not seed 75% consensus on a custom decision-making card", () => {
|
||||
@@ -311,7 +303,7 @@ describe("buildPublishPayload — methodSelections", () => {
|
||||
expect(ms.decisionApproaches?.[0]?.sections.consensusLevel).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps catalog decision consensus in methodSelections", () => {
|
||||
it("does not fill catalog decision consensus when the card has no words", () => {
|
||||
const r = buildPublishPayload({
|
||||
title: "T",
|
||||
selectedDecisionApproachIds: ["lazy-consensus"],
|
||||
@@ -321,7 +313,7 @@ describe("buildPublishPayload — methodSelections", () => {
|
||||
const ms = r.document.methodSelections as {
|
||||
decisionApproaches?: Array<{ sections: { consensusLevel?: number } }>;
|
||||
};
|
||||
expect(ms.decisionApproaches?.[0]?.sections.consensusLevel).toBe(100);
|
||||
expect(ms.decisionApproaches?.[0]?.sections.consensusLevel).toBeUndefined();
|
||||
});
|
||||
|
||||
it("merges override on top of preset for the selected method", () => {
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { isFinalReviewContinueBlocked } from "../../app/(app)/create/utils/createFlowFooterLabels";
|
||||
import { communityInitialsFromTitle } from "../../lib/create/communityInitials";
|
||||
import { finalReviewChipHasWarning } from "../../lib/create/finalReviewChipWarnings";
|
||||
import {
|
||||
finalReviewChipBlocksContinue,
|
||||
finalReviewChipHasWarning,
|
||||
finalReviewMissingWordsLabels,
|
||||
} from "../../lib/create/finalReviewChipWarnings";
|
||||
import type { CreateFlowState } from "../../app/(app)/create/types";
|
||||
|
||||
const completeCards: CreateFlowState = {
|
||||
@@ -12,11 +16,47 @@ const completeCards: CreateFlowState = {
|
||||
selectedConflictManagementIds: ["conflict-ladder"],
|
||||
};
|
||||
|
||||
const completeCardsWithWords: CreateFlowState = {
|
||||
...completeCards,
|
||||
communicationMethodDetailsById: {
|
||||
signal: {
|
||||
corePrinciple: "We talk in the open.",
|
||||
logisticsAdmin: "Post in Signal.",
|
||||
codeOfConduct: "No pile-ons.",
|
||||
},
|
||||
},
|
||||
membershipMethodDetailsById: {
|
||||
"open-admission": {
|
||||
eligibility: "Anyone who shares the work.",
|
||||
joiningProcess: "Show up.",
|
||||
expectations: "Keep the keys.",
|
||||
},
|
||||
},
|
||||
decisionApproachDetailsById: {
|
||||
"lazy-consensus": {
|
||||
corePrinciple: "Silence is assent.",
|
||||
applicableScope: [],
|
||||
selectedApplicableScope: [],
|
||||
stepByStepInstructions: "Post the proposal.",
|
||||
objectionsDeadlocks: "A named block stops it.",
|
||||
},
|
||||
},
|
||||
conflictManagementDetailsById: {
|
||||
"conflict-ladder": {
|
||||
corePrinciple: "Start small.",
|
||||
applicableScope: [],
|
||||
selectedApplicableScope: [],
|
||||
processProtocol: "Talk, then mediate.",
|
||||
restorationFallbacks: "A panel if that fails.",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
describe("isFinalReviewContinueBlocked", () => {
|
||||
it("blocks when the community name is empty", () => {
|
||||
expect(
|
||||
isFinalReviewContinueBlocked({
|
||||
...completeCards,
|
||||
...completeCardsWithWords,
|
||||
title: " ",
|
||||
}),
|
||||
).toBe(true);
|
||||
@@ -25,14 +65,45 @@ describe("isFinalReviewContinueBlocked", () => {
|
||||
it("blocks when any of the four questions has no card", () => {
|
||||
expect(
|
||||
isFinalReviewContinueBlocked({
|
||||
...completeCards,
|
||||
...completeCardsWithWords,
|
||||
selectedMembershipMethodIds: [],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("does not block when values are empty and the four questions have cards", () => {
|
||||
expect(isFinalReviewContinueBlocked(completeCards)).toBe(false);
|
||||
it("blocks when a picked card is missing its words", () => {
|
||||
expect(isFinalReviewContinueBlocked(completeCards)).toBe(true);
|
||||
});
|
||||
|
||||
it("does not block when values are empty and every card has its words", () => {
|
||||
expect(isFinalReviewContinueBlocked(completeCardsWithWords)).toBe(false);
|
||||
});
|
||||
|
||||
it("blocks when a picked value is missing its meaning", () => {
|
||||
expect(
|
||||
isFinalReviewContinueBlocked({
|
||||
...completeCardsWithWords,
|
||||
selectedCoreValueIds: ["1"],
|
||||
coreValuesChipsSnapshot: [
|
||||
{ id: "1", label: "Care", state: "selected" },
|
||||
],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("does not block when a value has meaning but no signals", () => {
|
||||
expect(
|
||||
isFinalReviewContinueBlocked({
|
||||
...completeCardsWithWords,
|
||||
selectedCoreValueIds: ["1"],
|
||||
coreValuesChipsSnapshot: [
|
||||
{ id: "1", label: "Care", state: "selected" },
|
||||
],
|
||||
coreValueDetailsByChipId: {
|
||||
"1": { meaning: "We look after each other.", signals: "" },
|
||||
},
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -70,6 +141,83 @@ describe("finalReviewChipHasWarning", () => {
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("clears the warning when a custom card's fields have text", () => {
|
||||
const customId = "00000000-0000-4000-8000-000000000190";
|
||||
expect(
|
||||
finalReviewChipHasWarning(
|
||||
{
|
||||
customMethodCardMetaById: {
|
||||
[customId]: { label: "S13 comms card", supportText: "" },
|
||||
},
|
||||
customMethodCardFieldBlocksById: {
|
||||
[customId]: [
|
||||
{
|
||||
kind: "text",
|
||||
id: "b1",
|
||||
blockTitle: "How we talk",
|
||||
placeholderText: "Post in the hall.",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
"communication",
|
||||
customId,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("finalReviewChipBlocksContinue", () => {
|
||||
it("does not block a value that has meaning but no signals", () => {
|
||||
expect(
|
||||
finalReviewChipBlocksContinue(
|
||||
{
|
||||
coreValueDetailsByChipId: {
|
||||
"1": { meaning: "Care", signals: "" },
|
||||
},
|
||||
},
|
||||
"coreValues",
|
||||
"1",
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("blocks a custom card until its fields have text", () => {
|
||||
const customId = "00000000-0000-4000-8000-000000000191";
|
||||
expect(
|
||||
finalReviewChipBlocksContinue(
|
||||
{
|
||||
customMethodCardMetaById: {
|
||||
[customId]: { label: "S13 comms card", supportText: "" },
|
||||
},
|
||||
customMethodCardFieldBlocksById: {
|
||||
[customId]: [
|
||||
{
|
||||
kind: "text",
|
||||
id: "b1",
|
||||
blockTitle: "How we talk",
|
||||
placeholderText: "",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
"communication",
|
||||
customId,
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("finalReviewMissingWordsLabels", () => {
|
||||
it("names the cards that still need words", () => {
|
||||
expect(finalReviewMissingWordsLabels(completeCards)).toEqual([
|
||||
"Signal",
|
||||
"Open admission",
|
||||
"Lazy consensus",
|
||||
"Conflict ladder",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("communityInitialsFromTitle", () => {
|
||||
|
||||
@@ -81,7 +81,7 @@ describe("parsePublishedDocumentForCommunityRuleDisplay", () => {
|
||||
expect(out[0].entries[0].body).toBe("x\n\ny");
|
||||
});
|
||||
|
||||
it("enriches empty core value copy from presets (label match)", () => {
|
||||
it("keeps empty core value copy blank instead of filling library text", () => {
|
||||
const doc = {
|
||||
sections: [],
|
||||
coreValues: [
|
||||
@@ -89,7 +89,8 @@ describe("parsePublishedDocumentForCommunityRuleDisplay", () => {
|
||||
],
|
||||
};
|
||||
const out = parsePublishedDocumentForCommunityRuleDisplay(doc);
|
||||
expect(out[0].entries[0].body).toMatch(/well-being is bound up/);
|
||||
expect(out[0].entries[0].title).toBe("Interdependence");
|
||||
expect(out[0].entries[0].body).toBe("");
|
||||
});
|
||||
|
||||
it("replaces template placeholder bodies with preset copy, Values first", () => {
|
||||
|
||||
@@ -61,6 +61,37 @@ describe("inviteRuleCountsLabel", () => {
|
||||
}),
|
||||
).toBe("3 VALUES AND 2 CARDS");
|
||||
});
|
||||
|
||||
it("counts titled cards that still have no words", () => {
|
||||
expect(
|
||||
inviteRuleCountsLabel({
|
||||
methodSelections: {
|
||||
communication: [
|
||||
{
|
||||
id: "signal",
|
||||
label: "Signal",
|
||||
sections: {
|
||||
corePrinciple: "",
|
||||
logisticsAdmin: "",
|
||||
codeOfConduct: "",
|
||||
},
|
||||
},
|
||||
],
|
||||
membership: [
|
||||
{
|
||||
id: "open-admission",
|
||||
label: "Open admission",
|
||||
sections: {
|
||||
eligibility: "",
|
||||
joiningProcess: "",
|
||||
expectations: "",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
).toBe("0 VALUES AND 2 CARDS");
|
||||
});
|
||||
});
|
||||
|
||||
describe("inviteRuleCountsSpoken", () => {
|
||||
|
||||
@@ -45,6 +45,16 @@ describe("withoutUnpublishedDecisionConsensus", () => {
|
||||
});
|
||||
|
||||
describe("communityRuleEntryFromMethodChip", () => {
|
||||
it("keeps a titled card when there are no words yet", () => {
|
||||
expect(
|
||||
communityRuleEntryFromMethodChip(
|
||||
"Signal",
|
||||
{ corePrinciple: "" },
|
||||
{ corePrinciple: "Core Principle" },
|
||||
),
|
||||
).toEqual({ title: "Signal", body: "" });
|
||||
});
|
||||
|
||||
it("publishes supportText as body when there are no labeled blocks", () => {
|
||||
expect(
|
||||
communityRuleEntryFromMethodChip(
|
||||
|
||||
Reference in new issue
Block a user