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
@@ -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", () => {
|
||||
|
||||
Reference in new issue
Block a user