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

+24 -39
View File
@@ -23,7 +23,7 @@ beforeEach(() => {
findManyMock.mockReset();
});
describe("listMethodRecommendations (CR-88 §9.2)", () => {
describe("listMethodRecommendations", () => {
it("returns empty rankings when no facets are requested", async () => {
const result = await listMethodRecommendations({
section: "communication",
@@ -33,55 +33,40 @@ describe("listMethodRecommendations (CR-88 §9.2)", () => {
expect(findManyMock).not.toHaveBeenCalled();
});
it("scores methods by counting matched (group, value) pairs", async () => {
findManyMock.mockResolvedValueOnce([
{ slug: "loomio", group: "size", value: "thirteenToOneHundred" },
{ slug: "loomio", group: "orgType", value: "workersCoop" },
{ slug: "in-person", group: "size", value: "thirteenToOneHundred" },
]);
const result = await listMethodRecommendations({
section: "communication",
it("ranks from the job rule and scores maturity once", async () => {
const once = await listMethodRecommendations({
section: "decisionApproaches",
facets: {
size: ["thirteenToOneHundred"],
orgType: ["workersCoop"],
maturity: ["established"],
},
});
expect(result).toEqual({
rankedSlugs: ["loomio", "in-person"],
matchesBySlug: {
loomio: {
score: 2,
matchedFacets: ["size:thirteenToOneHundred", "orgType:workersCoop"],
},
"in-person": {
score: 1,
matchedFacets: ["size:thirteenToOneHundred"],
},
const several = await listMethodRecommendations({
section: "decisionApproaches",
facets: {
size: ["thirteenToOneHundred"],
orgType: ["workersCoop"],
maturity: ["established", "earlyStage", "enterprise"],
},
});
expect(once?.rankedSlugs).toEqual(several?.rankedSlugs);
expect(once?.rankedSlugs[0]).toBeTruthy();
expect(findManyMock).not.toHaveBeenCalled();
});
it("returns null on query failure (caller falls back to authoring order)", async () => {
findManyMock.mockRejectedValueOnce(new Error("db down"));
it("uses only the main kind for eligibility", async () => {
const result = await listMethodRecommendations({
section: "communication",
facets: { size: ["oneMember"] },
section: "decisionApproaches",
facets: {
size: ["thirteenToOneHundred"],
orgType: ["workersCoop", "forProfit"],
scale: ["local"],
maturity: ["established"],
},
});
expect(result).toBeNull();
});
it("dedupes (group, value) so the same row never double-counts", async () => {
findManyMock.mockResolvedValueOnce([
{ slug: "loomio", group: "size", value: "twoToFive" },
{ slug: "loomio", group: "size", value: "twoToFive" },
]);
const result = await listMethodRecommendations({
section: "communication",
facets: { size: ["twoToFive"] },
});
expect(result?.matchesBySlug["loomio"]?.score).toBe(1);
expect(result?.rankedSlugs).toContain("consent-sociocracy");
expect(findManyMock).not.toHaveBeenCalled();
});
});