Treat a typed main kind as no kind so recommendations still fall back to size.
A custom kind no longer empties a job of eligible cards, and other catalog kinds stay ranking hints instead of becoming the main kind.
This commit is contained in:
1 parent
dad8661268
commit
f795951443
5 files changed
+116
-16
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { deckData, recommendDeck } from "../../lib/create/deckRecommend";
|
||||
import type { Kind } from "../../lib/create/deckTypes";
|
||||
|
||||
describe("recommendDeck typed main kind", () => {
|
||||
const sizeOnly = {
|
||||
size: "sixToTwelve",
|
||||
mainKind: null,
|
||||
};
|
||||
|
||||
it("treats a typed main kind as no kind so eligibility falls back to size", () => {
|
||||
const typed = recommendDeck(deckData("decisionApproaches"), {
|
||||
size: "sixToTwelve",
|
||||
mainKind: "streetMedicCrew" as Kind,
|
||||
});
|
||||
const none = recommendDeck(deckData("decisionApproaches"), sizeOnly);
|
||||
const coop = recommendDeck(deckData("decisionApproaches"), {
|
||||
size: "sixToTwelve",
|
||||
mainKind: "workersCoop",
|
||||
});
|
||||
|
||||
expect(typed.fallback).toBe(false);
|
||||
expect(typed.recommended.map((card) => card.id)).toEqual(
|
||||
none.recommended.map((card) => card.id),
|
||||
);
|
||||
expect(
|
||||
typed.recommended.some(
|
||||
(card) =>
|
||||
(card.reason.kind === "fit" || card.reason.kind === "opened") &&
|
||||
card.reason.matched.includes("kind"),
|
||||
),
|
||||
).toBe(false);
|
||||
expect(
|
||||
coop.recommended.some(
|
||||
(card) =>
|
||||
(card.reason.kind === "fit" || card.reason.kind === "opened") &&
|
||||
card.reason.matched.includes("kind"),
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps other catalog kinds as ranking hints, not as the main kind", () => {
|
||||
const typedWithOther = recommendDeck(deckData("decisionApproaches"), {
|
||||
size: "sixToTwelve",
|
||||
mainKind: null,
|
||||
otherKinds: ["workersCoop"],
|
||||
});
|
||||
const none = recommendDeck(deckData("decisionApproaches"), sizeOnly);
|
||||
|
||||
expect(typedWithOther.fallback).toBe(false);
|
||||
expect(new Set(typedWithOther.recommended.map((card) => card.job))).toEqual(
|
||||
new Set(none.recommended.map((card) => card.job)),
|
||||
);
|
||||
expect(
|
||||
typedWithOther.recommended.some(
|
||||
(card) =>
|
||||
(card.reason.kind === "fit" || card.reason.kind === "opened") &&
|
||||
card.reason.matched.includes("kind"),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -19,6 +19,15 @@ describe("maturity and chip aliases", () => {
|
||||
expect(answers.mainKind).toBe("workersCoop");
|
||||
});
|
||||
|
||||
it("treats a typed main kind as no kind and keeps catalog kinds as other kinds", () => {
|
||||
const answers = groupAnswersFromCreateFlowState({
|
||||
selectedCommunitySizeIds: ["sixToTwelve"],
|
||||
selectedOrganizationTypeIds: ["custom-tenants-union", "workersCoop"],
|
||||
});
|
||||
expect(answers.mainKind).toBeNull();
|
||||
expect(answers.otherKinds).toEqual(["workersCoop"]);
|
||||
});
|
||||
|
||||
it("passes ticked setup answers through as traits", () => {
|
||||
const answers = groupAnswersFromCreateFlowState({
|
||||
setupTraits: { employer: true, records: false },
|
||||
|
||||
@@ -55,6 +55,17 @@ describe("listMethodRecommendations", () => {
|
||||
expect(findManyMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("still ranks when only size is set and the main kind is missing", async () => {
|
||||
const result = await listMethodRecommendations({
|
||||
section: "decisionApproaches",
|
||||
facets: {
|
||||
size: ["sixToTwelve"],
|
||||
},
|
||||
});
|
||||
expect(result?.rankedSlugs.length).toBeGreaterThan(0);
|
||||
expect(findManyMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("uses only the main kind for eligibility", async () => {
|
||||
const result = await listMethodRecommendations({
|
||||
section: "decisionApproaches",
|
||||
|
||||
Reference in new issue
Block a user