Create Community stage implemented
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
CREATE_FLOW_MD_UP_COLUMN_MAX_CLASS,
|
||||
CREATE_FLOW_MD_UP_GRID_CELL_CLASS,
|
||||
CREATE_FLOW_TWO_COLUMN_MAX_WIDTH_CLASS,
|
||||
} from "../../app/create/components/createFlowLayoutTokens";
|
||||
|
||||
describe("createFlowLayoutTokens", () => {
|
||||
it("exports create-flow column and two-column max class strings", () => {
|
||||
expect(CREATE_FLOW_MD_UP_COLUMN_MAX_CLASS).toBe(
|
||||
"w-full min-w-0 md:max-w-[640px]",
|
||||
);
|
||||
expect(CREATE_FLOW_MD_UP_GRID_CELL_CLASS).toBe(
|
||||
"w-full min-w-0 md:mx-auto md:max-w-[640px]",
|
||||
);
|
||||
expect(CREATE_FLOW_TWO_COLUMN_MAX_WIDTH_CLASS).toBe("md:max-w-[1328px]");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { getProportionBarProgressForCreateFlowStep } from "../../app/create/utils/createFlowProportionProgress";
|
||||
|
||||
describe("getProportionBarProgressForCreateFlowStep", () => {
|
||||
it("uses 1-2 on community-structure (third Create Community step)", () => {
|
||||
expect(getProportionBarProgressForCreateFlowStep("community-structure")).toBe(
|
||||
"1-2",
|
||||
);
|
||||
});
|
||||
|
||||
it("advances proportion after structure for context and size", () => {
|
||||
expect(getProportionBarProgressForCreateFlowStep("community-context")).toBe(
|
||||
"1-3",
|
||||
);
|
||||
expect(getProportionBarProgressForCreateFlowStep("community-size")).toBe(
|
||||
"1-4",
|
||||
);
|
||||
});
|
||||
|
||||
it("uses 2-0 on community-save and review (end of Create Community segment)", () => {
|
||||
expect(getProportionBarProgressForCreateFlowStep("community-save")).toBe(
|
||||
"2-0",
|
||||
);
|
||||
expect(getProportionBarProgressForCreateFlowStep("review")).toBe("2-0");
|
||||
});
|
||||
});
|
||||
@@ -71,6 +71,13 @@ describe("createFlowStateSchema", () => {
|
||||
const r = createFlowStateSchema.safeParse({ title: "x".repeat(600) });
|
||||
expect(r.success).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects communitySaveEmail longer than 320 chars", () => {
|
||||
const r = createFlowStateSchema.safeParse({
|
||||
communitySaveEmail: "x".repeat(321),
|
||||
});
|
||||
expect(r.success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("putDraftBodySchema", () => {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import messages from "../../messages/en/index";
|
||||
|
||||
describe("create footer messages", () => {
|
||||
it("exposes confirmName for the community-name footer CTA", () => {
|
||||
expect(messages.create.footer.confirmName).toBe("Confirm name");
|
||||
});
|
||||
|
||||
it("exposes confirmDetails for the community-structure footer CTA", () => {
|
||||
expect(messages.create.footer.confirmDetails).toBe("Confirm details");
|
||||
});
|
||||
|
||||
it("exposes confirmDescription for the community-context footer CTA", () => {
|
||||
expect(messages.create.footer.confirmDescription).toBe(
|
||||
"Confirm description",
|
||||
);
|
||||
});
|
||||
|
||||
it("exposes confirmMembers for the community-size footer CTA", () => {
|
||||
expect(messages.create.footer.confirmMembers).toBe("Confirm members");
|
||||
});
|
||||
});
|
||||
@@ -8,6 +8,8 @@ describe("createFlowStateHasKeys", () => {
|
||||
|
||||
it("returns true when any key is present", () => {
|
||||
expect(createFlowStateHasKeys({ title: "x" })).toBe(true);
|
||||
expect(createFlowStateHasKeys({ currentStep: "text" })).toBe(true);
|
||||
expect(createFlowStateHasKeys({ currentStep: "community-name" })).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,4 +46,13 @@ describe("flowSteps", () => {
|
||||
// @ts-expect-error — invalid step id
|
||||
expect(getStepIndex("bogus")).toBe(-1);
|
||||
});
|
||||
|
||||
it("places community-structure before community-context and community-size (Figma order)", () => {
|
||||
expect(getStepIndex("community-structure")).toBe(2);
|
||||
expect(getStepIndex("community-context")).toBe(3);
|
||||
expect(getStepIndex("community-size")).toBe(4);
|
||||
expect(getNextStep("community-name")).toBe("community-structure");
|
||||
expect(getNextStep("community-structure")).toBe("community-context");
|
||||
expect(getNextStep("community-context")).toBe("community-size");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { migrateLegacyCreateFlowState } from "../../lib/create/migrateLegacyCreateFlowState";
|
||||
|
||||
describe("migrateLegacyCreateFlowState", () => {
|
||||
it("maps communityReflection to communitySaveEmail when save email empty", () => {
|
||||
const out = migrateLegacyCreateFlowState({
|
||||
title: "T",
|
||||
communityReflection: "old@example.com",
|
||||
});
|
||||
expect(out.communitySaveEmail).toBe("old@example.com");
|
||||
expect("communityReflection" in out).toBe(false);
|
||||
});
|
||||
|
||||
it("does not overwrite existing communitySaveEmail", () => {
|
||||
const out = migrateLegacyCreateFlowState({
|
||||
communityReflection: "old@example.com",
|
||||
communitySaveEmail: "kept@example.com",
|
||||
});
|
||||
expect(out.communitySaveEmail).toBe("kept@example.com");
|
||||
});
|
||||
|
||||
it("rewrites currentStep slug", () => {
|
||||
const out = migrateLegacyCreateFlowState({
|
||||
currentStep: "community-reflection",
|
||||
});
|
||||
expect(out.currentStep).toBe("community-save");
|
||||
});
|
||||
|
||||
it("returns empty object for nullish input", () => {
|
||||
expect(migrateLegacyCreateFlowState(null)).toEqual({});
|
||||
expect(migrateLegacyCreateFlowState(undefined)).toEqual({});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user