Files
community-rule/tests/unit/groupAnswers.test.ts
T
adilalloandCursor bcbc6f30d9 Import the remade decks on stable ids and recommend one card per job, so a saved draft still loads after a chip is renamed.
The real-group profiles stay as a test, so a change that moves a pick fails.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-04 14:22:54 -07:00

69 lines
2.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { migrateLegacyCreateFlowState } from "../../lib/create/migrateLegacyCreateFlowState";
import { groupAnswersFromCreateFlowState } from "../../lib/create/groupAnswers";
describe("maturity and chip aliases", () => {
it("scores one maturity answer and keeps a draft that stored several", () => {
const draft = migrateLegacyCreateFlowState({
selectedMaturityIds: ["1", "2", "4"],
selectedOrganizationTypeIds: ["1"],
});
expect(draft.selectedMaturityIds).toEqual([
"earlyStage",
"growthStage",
"established",
]);
expect(draft.selectedOrganizationTypeIds).toEqual(["workersCoop"]);
const answers = groupAnswersFromCreateFlowState(draft);
expect(answers.stage).toBe("earlyStage");
expect(answers.mainKind).toBe("workersCoop");
});
it("loads Enterprise and Larger organization as Established", () => {
const fromId = migrateLegacyCreateFlowState({
selectedMaturityIds: ["4"],
communityStructureChipSnapshots: {
maturity: [
{ id: "1", label: "Early stage", state: "unselected" },
{ id: "2", label: "Growth stage", state: "unselected" },
{ id: "3", label: "Established", state: "unselected" },
{ id: "4", label: "Enterprise", state: "selected" },
],
},
});
expect(fromId.selectedMaturityIds).toEqual(["established"]);
expect(
fromId.communityStructureChipSnapshots?.maturity?.find(
(row) => row.id === "established",
)?.label,
).toBe("Established");
const fromLabel = migrateLegacyCreateFlowState({
selectedMaturityIds: ["larger-organization"],
communityStructureChipSnapshots: {
maturity: [
{ id: "larger-organization", label: "Larger organization", state: "selected" },
],
},
});
expect(fromLabel.selectedMaturityIds).toEqual(["established"]);
});
it("keeps the worker co-op pick when the label was Worker cooperative", () => {
const draft = migrateLegacyCreateFlowState({
selectedOrganizationTypeIds: ["1"],
communityStructureChipSnapshots: {
organizationTypes: [
{ id: "1", label: "Worker cooperative", state: "selected" },
],
},
});
expect(draft.selectedOrganizationTypeIds).toEqual(["workersCoop"]);
expect(
draft.communityStructureChipSnapshots?.organizationTypes?.find(
(row) => row.id === "workersCoop",
)?.label,
).toBe("Worker co-op");
});
});