mirror of
https://github.com/rommapp/romm.git
synced 2026-12-05 23:44:11 +01:00
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:
52
frontend/src/v2/utils/similarityReasons.test.ts
Normal file
52
frontend/src/v2/utils/similarityReasons.test.ts
Normal 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",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user