fix(v2): give the split company facets their own reason icon

Splitting `companies` into developer and publisher left both facets
unmapped, so every studio match rendered with the generic tag icon --
Gunstar Heroes explained four of its six matches as "Treasure" under a
keyword glyph. `platform` was never mapped either.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Sam Dornan
2026-08-08 09:58:11 -05:00
parent 4e13e1a612
commit eb0656ee9f
2 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import { describe, expect, it } from "vitest";
import type { SimilarityReasonSchema } from "@/__generated__";
import { reasonIcon, reasonLabel } from "@/v2/utils/similarityReasons";
function reason(facet: string, value = "x"): SimilarityReasonSchema {
return { facet, value } as SimilarityReasonSchema;
}
const DEFAULT_ICON = "mdi-tag-outline";
describe("reasonIcon", () => {
it.each([
"collection",
"franchise",
"developer",
"publisher",
"company",
"genre",
"theme",
"perspective",
"keyword",
"game_mode",
"platform",
"decade",
"igdb",
"top_rated",
])("maps %s to a dedicated icon", (facet) => {
expect(reasonIcon(reason(facet))).not.toBe(DEFAULT_ICON);
});
it("falls back for a facet it does not know", () => {
expect(reasonIcon(reason("something_new"))).toBe(DEFAULT_ICON);
});
});
describe("reasonLabel", () => {
const t = (key: string) => key;
it("shows the value for facets that are already proper nouns", () => {
expect(reasonLabel(reason("developer", "Treasure"), t)).toBe("Treasure");
});
it("pluralises a decade", () => {
expect(reasonLabel(reason("decade", "1990"), t)).toBe("1990s");
});
it("translates facets with no meaningful value", () => {
expect(reasonLabel(reason("igdb", ""), t)).toBe(
"recommendations.reason-igdb",
);
});
});

View File

@@ -12,12 +12,15 @@ import type { SimilarityReasonSchema } from "@/__generated__";
const FACET_ICONS: Record<string, string> = {
collection: "mdi-bookmark-multiple-outline",
franchise: "mdi-star-outline",
developer: "mdi-domain",
publisher: "mdi-domain",
company: "mdi-domain",
genre: "mdi-shape-outline",
theme: "mdi-palette-outline",
perspective: "mdi-camera-outline",
keyword: "mdi-tag-multiple-outline",
game_mode: "mdi-account-group-outline",
platform: "mdi-controller-classic-outline",
decade: "mdi-calendar-outline",
igdb: "mdi-link-variant",
top_rated: "mdi-trophy-outline",