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>
This commit is contained in:
adilalloandCursor committed 2026-11-04 14:22:54 -07:00
1 parent 96ca15d8e3
commit bcbc6f30d9
89 files changed
+36555 -2828

No files matched your search

+46 -77
View File
@@ -1,93 +1,62 @@
import { describe, expect, it } from "vitest";
import { deriveCompactCards } from "../../app/(app)/create/hooks/useFacetRecommendations";
const methods = [
{ id: "alpha" },
{ id: "bravo" },
{ id: "charlie" },
{ id: "delta" },
{ id: "echo" },
{ id: "foxtrot" },
{ id: "golf" },
] as const;
describe("deriveCompactCards", () => {
it("falls back to authoring order with no badges when no facets selected", () => {
const result = deriveCompactCards(methods, {}, false, 5);
expect(result.compactCardIds).toEqual([
"alpha",
"bravo",
"charlie",
"delta",
"echo",
]);
it("falls back to deck order with no tags when no facets are chosen", () => {
const result = deriveCompactCards("decisionApproaches", {}, 5);
expect(result.compactCardIds).toHaveLength(5);
expect(result.recommendedIds.size).toBe(0);
expect(result.orderedIds[0]).toBe(result.compactCardIds[0]);
});
it("falls back to authoring order with no badges when facets selected but every score is zero", () => {
const result = deriveCompactCards(methods, {}, true, 5);
expect(result.compactCardIds).toEqual([
"alpha",
"bravo",
"charlie",
"delta",
"echo",
]);
expect(result.recommendedIds.size).toBe(0);
});
it("shows only recommended (matched) cards when fewer than the limit match", () => {
it("shows the top five in deck order and leaves every-rule cards untagged", () => {
const result = deriveCompactCards(
methods,
{ bravo: 2, delta: 1 },
true,
"decisionApproaches",
{
size: "thirteenToOneHundred",
mainKind: "workersCoop",
scale: ["local"],
stage: "established",
traits: { risky: true, sponsor: true, employer: true },
},
5,
);
// Caller is responsible for pre-ranking by score (rankMethodsByScore).
// This test passes already-ranked input; the hook just respects ordering
// and tags only the matched subset — no padding with unrecommended cards.
expect(result.compactCardIds).toEqual(["bravo", "delta"]);
expect([...result.recommendedIds].sort()).toEqual(["bravo", "delta"]);
});
it("caps recommended cards at the limit when more than `limit` match", () => {
const scores = {
alpha: 4,
bravo: 3,
charlie: 3,
delta: 2,
echo: 1,
foxtrot: 1,
golf: 1,
};
const result = deriveCompactCards(methods, scores, true, 5);
expect(result.compactCardIds).toEqual([
"alpha",
"bravo",
"charlie",
"delta",
"echo",
]);
expect(result.recommendedIds.size).toBe(5);
expect([...result.recommendedIds].sort()).toEqual([
"alpha",
"bravo",
"charlie",
"delta",
"echo",
"decision-speeds",
"modified-consensus",
"emergency-decisions",
"on-site-lead",
"how-we-are-covered",
]);
expect(result.recommendedIds.has("decision-speeds")).toBe(false);
expect(result.recommendedIds.has("on-site-lead")).toBe(true);
});
it("returns a single card when only one method matches", () => {
const result = deriveCompactCards(methods, { charlie: 4 }, true, 5);
expect(result.compactCardIds).toEqual(["charlie"]);
expect([...result.recommendedIds]).toEqual(["charlie"]);
});
it("respects a smaller `limit` even when many methods match", () => {
const scores = { alpha: 4, bravo: 3, charlie: 3, delta: 2 };
const result = deriveCompactCards(methods, scores, true, 3);
expect(result.compactCardIds).toEqual(["alpha", "bravo", "charlie"]);
expect(result.recommendedIds.size).toBe(3);
it("shows seven when the screen asks for seven, with spending behind see all", () => {
const result = deriveCompactCards(
"decisionApproaches",
{
size: "thirteenToOneHundred",
mainKind: "workersCoop",
scale: ["local"],
stage: "established",
traits: { risky: true, sponsor: true, employer: true },
},
7,
);
expect(result.compactCardIds).toEqual([
"decision-speeds",
"modified-consensus",
"changing-this-rule",
"emergency-decisions",
"on-site-lead",
"how-we-are-covered",
"elected-board-of-directors",
]);
expect(result.orderedIds.slice(7, 10)).toEqual([
"shared-money",
"spending-limits",
"pay-and-hiring",
]);
});
});