Show the whole Rule on one review card, with quiet flags for missing cards and Continue once each question has one.
This commit is contained in:
1 parent
cc878e3c19
commit
6e2e1915ae
30 files changed
+571
-218
No files matched your search
@@ -10,9 +10,21 @@ const NAMES = {
|
||||
conflict: "Conflict management",
|
||||
};
|
||||
|
||||
function rowsWith(
|
||||
chipsByName: Partial<Record<string, string[]>>,
|
||||
): { name: string; chips: string[] }[] {
|
||||
return [
|
||||
"Values",
|
||||
"Communication",
|
||||
"Membership",
|
||||
"Decision-making",
|
||||
"Conflict management",
|
||||
].map((name) => ({ name, chips: chipsByName[name] ?? [] }));
|
||||
}
|
||||
|
||||
describe("buildFinalReviewCategoriesFromState", () => {
|
||||
it("returns [] when state has no selections and no sections", () => {
|
||||
expect(buildFinalReviewCategoriesFromState({}, NAMES)).toEqual([]);
|
||||
it("returns five empty rows when state has no selections and no sections", () => {
|
||||
expect(buildFinalReviewCategoriesFromState({}, NAMES)).toEqual(rowsWith({}));
|
||||
});
|
||||
|
||||
it("resolves method ids to labels from message presets", () => {
|
||||
@@ -33,7 +45,7 @@ describe("buildFinalReviewCategoriesFromState", () => {
|
||||
expect(byName.get("Membership")).toEqual(["Open admission"]);
|
||||
expect(byName.get("Decision-making")).toEqual(["Lazy consensus"]);
|
||||
expect(byName.get("Conflict management")).toEqual(["Conflict ladder"]);
|
||||
expect(byName.has("Values")).toBe(false);
|
||||
expect(byName.get("Values")).toEqual([]);
|
||||
});
|
||||
|
||||
it("derives core values via buildCoreValuesForDocument (snapshot + selected ids)", () => {
|
||||
@@ -46,9 +58,9 @@ describe("buildFinalReviewCategoriesFromState", () => {
|
||||
],
|
||||
};
|
||||
const rows = buildFinalReviewCategoriesFromState(state, NAMES);
|
||||
expect(rows).toEqual([
|
||||
{ name: "Values", chips: ["Accessibility", "Resilience"] },
|
||||
]);
|
||||
expect(rows).toEqual(
|
||||
rowsWith({ Values: ["Accessibility", "Resilience"] }),
|
||||
);
|
||||
});
|
||||
|
||||
it("drops unknown ids silently instead of inserting empty labels", () => {
|
||||
@@ -56,7 +68,7 @@ describe("buildFinalReviewCategoriesFromState", () => {
|
||||
selectedCommunicationMethodIds: ["signal", "bogus-id"],
|
||||
};
|
||||
const rows = buildFinalReviewCategoriesFromState(state, NAMES);
|
||||
expect(rows).toEqual([{ name: "Communication", chips: ["Signal"] }]);
|
||||
expect(rows).toEqual(rowsWith({ Communication: ["Signal"] }));
|
||||
});
|
||||
|
||||
it("resolves user-authored method ids from customMethodCardMetaById", () => {
|
||||
@@ -77,7 +89,7 @@ describe("buildFinalReviewCategoriesFromState", () => {
|
||||
selectedCommunicationMethodIds: ["signal", "signal"],
|
||||
};
|
||||
const rows = buildFinalReviewCategoriesFromState(state, NAMES);
|
||||
expect(rows).toEqual([{ name: "Communication", chips: ["Signal"] }]);
|
||||
expect(rows).toEqual(rowsWith({ Communication: ["Signal"] }));
|
||||
});
|
||||
|
||||
it("uses section titles for method facets when selections were cleared (use-without-changes)", () => {
|
||||
@@ -98,10 +110,12 @@ describe("buildFinalReviewCategoriesFromState", () => {
|
||||
selectedCommunicationMethodIds: [],
|
||||
};
|
||||
const rows = buildFinalReviewCategoriesFromState(state, NAMES);
|
||||
expect(rows).toEqual([
|
||||
{ name: "Values", chips: ["Consciousness", "Ecology"] },
|
||||
{ name: "Communication", chips: ["Signal"] },
|
||||
]);
|
||||
expect(rows).toEqual(
|
||||
rowsWith({
|
||||
Values: ["Consciousness", "Ecology"],
|
||||
Communication: ["Signal"],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("when sections exist but facet selections are set, matches publish pickMethodIds (state wins)", () => {
|
||||
@@ -115,9 +129,9 @@ describe("buildFinalReviewCategoriesFromState", () => {
|
||||
selectedCommunicationMethodIds: ["in-person-meetings"],
|
||||
};
|
||||
const rows = buildFinalReviewCategoriesFromState(state, NAMES);
|
||||
expect(rows).toEqual([
|
||||
{ name: "Communication", chips: ["In-person meetings"] },
|
||||
]);
|
||||
expect(rows).toEqual(
|
||||
rowsWith({ Communication: ["In-person meetings"] }),
|
||||
);
|
||||
});
|
||||
|
||||
it("shows custom communication chips when sections exist and selections include a UUID", () => {
|
||||
@@ -153,10 +167,12 @@ describe("buildFinalReviewCategoriesFromState", () => {
|
||||
],
|
||||
};
|
||||
const rows = buildFinalReviewCategoriesFromState(state, NAMES);
|
||||
expect(rows).toEqual([
|
||||
{ name: "Values", chips: ["Accessibility"] },
|
||||
{ name: "Communication", chips: ["Signal"] },
|
||||
]);
|
||||
expect(rows).toEqual(
|
||||
rowsWith({
|
||||
Values: ["Accessibility"],
|
||||
Communication: ["Signal"],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("prefers the chip snapshot over a duplicated Values section in sections", () => {
|
||||
@@ -177,8 +193,6 @@ describe("buildFinalReviewCategoriesFromState", () => {
|
||||
],
|
||||
};
|
||||
const rows = buildFinalReviewCategoriesFromState(state, NAMES);
|
||||
expect(rows).toEqual([
|
||||
{ name: "Values", chips: ["Accessibility"] },
|
||||
]);
|
||||
expect(rows).toEqual(rowsWith({ Values: ["Accessibility"] }));
|
||||
});
|
||||
});
|
||||
@@ -20,7 +20,11 @@ describe("create footer messages", () => {
|
||||
expect(messages.create.footer.confirmSize).toBe("Confirm size");
|
||||
});
|
||||
|
||||
it("exposes publishCommunityRule for the final-review footer CTA", () => {
|
||||
it("exposes Continue for the final-review footer CTA", () => {
|
||||
expect(messages.create.footer.continue).toBe("Continue");
|
||||
});
|
||||
|
||||
it("exposes publishCommunityRule for the edit-rule footer CTA", () => {
|
||||
expect(messages.create.footer.publishCommunityRule).toBe(
|
||||
"Publish CommunityRule",
|
||||
);
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
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 type { CreateFlowState } from "../../app/(app)/create/types";
|
||||
|
||||
const completeCards: CreateFlowState = {
|
||||
title: "Oak Park Commons",
|
||||
selectedCommunicationMethodIds: ["signal"],
|
||||
selectedMembershipMethodIds: ["open-admission"],
|
||||
selectedDecisionApproachIds: ["lazy-consensus"],
|
||||
selectedConflictManagementIds: ["conflict-ladder"],
|
||||
};
|
||||
|
||||
describe("isFinalReviewContinueBlocked", () => {
|
||||
it("blocks when the community name is empty", () => {
|
||||
expect(
|
||||
isFinalReviewContinueBlocked({
|
||||
...completeCards,
|
||||
title: " ",
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("blocks when any of the four questions has no card", () => {
|
||||
expect(
|
||||
isFinalReviewContinueBlocked({
|
||||
...completeCards,
|
||||
selectedMembershipMethodIds: [],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("does not block when values are empty and the four questions have cards", () => {
|
||||
expect(isFinalReviewContinueBlocked(completeCards)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("finalReviewChipHasWarning", () => {
|
||||
it("warns when a value is missing meaning or signals", () => {
|
||||
expect(
|
||||
finalReviewChipHasWarning(
|
||||
{
|
||||
coreValueDetailsByChipId: {
|
||||
"1": { meaning: "Care", signals: "" },
|
||||
},
|
||||
},
|
||||
"coreValues",
|
||||
"1",
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("warns when a method card has no saved words", () => {
|
||||
expect(
|
||||
finalReviewChipHasWarning({}, "communication", "signal"),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("does not warn when meaning and signals are both filled", () => {
|
||||
expect(
|
||||
finalReviewChipHasWarning(
|
||||
{
|
||||
coreValueDetailsByChipId: {
|
||||
"1": { meaning: "Care", signals: "We talk over people." },
|
||||
},
|
||||
},
|
||||
"coreValues",
|
||||
"1",
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("communityInitialsFromTitle", () => {
|
||||
it("uses the first letters of the first two words", () => {
|
||||
expect(communityInitialsFromTitle("Oak Park Commons")).toBe("OP");
|
||||
});
|
||||
|
||||
it("uses two letters from a single word", () => {
|
||||
expect(communityInitialsFromTitle("Neighbors")).toBe("NE");
|
||||
});
|
||||
});
|
||||
@@ -16,9 +16,9 @@ import {
|
||||
} from "../../app/(app)/create/utils/flowSteps";
|
||||
|
||||
describe("flowSteps", () => {
|
||||
it("places confirm-stakeholders immediately before final-review", () => {
|
||||
const i = FLOW_STEP_ORDER.indexOf("confirm-stakeholders");
|
||||
const j = FLOW_STEP_ORDER.indexOf("final-review");
|
||||
it("places final-review immediately before confirm-stakeholders", () => {
|
||||
const i = FLOW_STEP_ORDER.indexOf("final-review");
|
||||
const j = FLOW_STEP_ORDER.indexOf("confirm-stakeholders");
|
||||
expect(i).toBeGreaterThanOrEqual(0);
|
||||
expect(j).toBe(i + 1);
|
||||
});
|
||||
@@ -27,8 +27,8 @@ describe("flowSteps", () => {
|
||||
expect(getNextStep("communication-methods")).toBe("membership-methods");
|
||||
expect(getNextStep("membership-methods")).toBe("decision-approaches");
|
||||
expect(getNextStep("decision-approaches")).toBe("conflict-management");
|
||||
expect(getNextStep("conflict-management")).toBe("confirm-stakeholders");
|
||||
expect(getNextStep("confirm-stakeholders")).toBe("final-review");
|
||||
expect(getNextStep("conflict-management")).toBe("final-review");
|
||||
expect(getNextStep("final-review")).toBe("confirm-stakeholders");
|
||||
});
|
||||
|
||||
it("getNextStep returns null for last step or invalid", () => {
|
||||
@@ -39,7 +39,8 @@ describe("flowSteps", () => {
|
||||
});
|
||||
|
||||
it("getPreviousStep returns prior step or null", () => {
|
||||
expect(getPreviousStep("final-review")).toBe("confirm-stakeholders");
|
||||
expect(getPreviousStep("final-review")).toBe("conflict-management");
|
||||
expect(getPreviousStep("confirm-stakeholders")).toBe("final-review");
|
||||
expect(getPreviousStep("informational")).toBeNull();
|
||||
expect(getPreviousStep(null)).toBeNull();
|
||||
});
|
||||
@@ -91,19 +92,17 @@ describe("flowSteps", () => {
|
||||
expect(getPreviousStep("communication-methods", opts)).toBe("core-values");
|
||||
});
|
||||
|
||||
it("useWithoutChangesIdentityOnly walks name → description → photo → stakeholders", () => {
|
||||
it("useWithoutChangesIdentityOnly walks name → description → photo → final-review", () => {
|
||||
const opts = { useWithoutChangesIdentityOnly: true } as const;
|
||||
expect(getNextStep("community-name", opts)).toBe("community-context");
|
||||
expect(getNextStep("community-context", opts)).toBe("community-upload");
|
||||
expect(getNextStep("community-size", opts)).toBe("community-upload");
|
||||
expect(getNextStep("setup-questions", opts)).toBe("community-upload");
|
||||
expect(getNextStep("community-upload", opts)).toBe("confirm-stakeholders");
|
||||
expect(getNextStep("confirm-stakeholders", opts)).toBe("final-review");
|
||||
expect(getNextStep("community-upload", opts)).toBe("final-review");
|
||||
expect(getNextStep("final-review", opts)).toBe("confirm-stakeholders");
|
||||
expect(getPreviousStep("community-context", opts)).toBe("community-name");
|
||||
expect(getPreviousStep("community-upload", opts)).toBe("community-context");
|
||||
expect(getPreviousStep("confirm-stakeholders", opts)).toBe(
|
||||
"community-upload",
|
||||
);
|
||||
expect(getPreviousStep("final-review", opts)).toBe("community-upload");
|
||||
expect(getPreviousStep("community-name", opts)).toBeNull();
|
||||
});
|
||||
|
||||
@@ -112,16 +111,14 @@ describe("flowSteps", () => {
|
||||
skipCommunitySave: true,
|
||||
useWithoutChangesIdentityOnly: true,
|
||||
} as const;
|
||||
expect(getNextStep("community-upload", opts)).toBe("confirm-stakeholders");
|
||||
expect(getPreviousStep("confirm-stakeholders", opts)).toBe(
|
||||
"community-upload",
|
||||
);
|
||||
expect(getNextStep("community-upload", opts)).toBe("final-review");
|
||||
expect(getPreviousStep("final-review", opts)).toBe("community-upload");
|
||||
});
|
||||
|
||||
it("resolveCreateFlowBackTarget returns template review when use-without slug is set on confirm-stakeholders", () => {
|
||||
it("resolveCreateFlowBackTarget returns template review when use-without slug is set on final-review", () => {
|
||||
expect(
|
||||
resolveCreateFlowBackTarget(
|
||||
"confirm-stakeholders",
|
||||
"final-review",
|
||||
undefined,
|
||||
"mutual-aid-mondays",
|
||||
),
|
||||
@@ -138,10 +135,10 @@ describe("flowSteps", () => {
|
||||
).toEqual({ kind: "templateReview", slug: "mutual-aid-mondays" });
|
||||
});
|
||||
|
||||
it("resolveCreateFlowBackTarget uses photo step behind stakeholders on the identity-only path", () => {
|
||||
it("resolveCreateFlowBackTarget uses photo step behind final-review on the identity-only path", () => {
|
||||
expect(
|
||||
resolveCreateFlowBackTarget(
|
||||
"confirm-stakeholders",
|
||||
"final-review",
|
||||
{ useWithoutChangesIdentityOnly: true },
|
||||
"mutual-aid-mondays",
|
||||
),
|
||||
@@ -151,13 +148,13 @@ describe("flowSteps", () => {
|
||||
it("resolveCreateFlowBackTarget falls back to linear previous when slug is absent", () => {
|
||||
expect(
|
||||
resolveCreateFlowBackTarget("confirm-stakeholders", undefined, undefined),
|
||||
).toEqual({ kind: "step", step: "conflict-management" });
|
||||
).toEqual({ kind: "step", step: "final-review" });
|
||||
});
|
||||
|
||||
it("resolveCreateFlowBackTarget ignores whitespace-only slug", () => {
|
||||
expect(
|
||||
resolveCreateFlowBackTarget("confirm-stakeholders", undefined, " "),
|
||||
).toEqual({ kind: "step", step: "conflict-management" });
|
||||
).toEqual({ kind: "step", step: "final-review" });
|
||||
});
|
||||
|
||||
it("buildTemplateReviewHref encodes slug and optional fromFlow query", () => {
|
||||
|
||||
@@ -129,7 +129,7 @@ describe("useTemplateReviewActions", () => {
|
||||
await result.current.handleUseWithoutChanges();
|
||||
});
|
||||
|
||||
expect(router.push).toHaveBeenCalledWith("/create/confirm-stakeholders");
|
||||
expect(router.push).toHaveBeenCalledWith("/create/final-review");
|
||||
expect(applied?.title).toBe("Neighborhood");
|
||||
expect(applied?.communityContext).toBe("We meet weekly");
|
||||
expect(applied?.setupTraits).toEqual({ employer: true });
|
||||
|
||||
Reference in new issue
Block a user