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"); }); });