diff --git a/frontend/src/v2/components/Player/AssetCard.test.ts b/frontend/src/v2/components/Player/AssetCard.test.ts new file mode 100644 index 000000000..a7ca22492 --- /dev/null +++ b/frontend/src/v2/components/Player/AssetCard.test.ts @@ -0,0 +1,36 @@ +import { mount } from "@vue/test-utils"; +import { describe, expect, it, vi } from "vitest"; +import type { SaveSchema } from "@/__generated__"; +import AssetCard from "./AssetCard.vue"; + +vi.mock("vue-i18n", () => ({ + useI18n: () => ({ t: (key: string) => key, locale: { value: "en-US" } }), +})); +vi.mock("@/stores/streaming", () => ({ + useStreamingStore: () => ({ + emulatorLabel: (id: string) => (id === "play" ? "Play!" : id), + }), +})); + +const RTag = { + props: { text: { type: String, default: "" } }, + template: `{{ text }}`, +}; + +const save = { + file_name: "slot1.ps2", + file_size_bytes: 2048, + emulator: "play", + updated_at: "2026-05-10T18:45:00Z", +} as SaveSchema; + +describe("AssetCard", () => { + it("names the emulator the way the backend labels it", () => { + const wrapper = mount(AssetCard, { + props: { asset: save, type: "save" }, + global: { stubs: { RTag, RImg: true } }, + }); + + expect(wrapper.findAll(".tag").map((el) => el.text())).toContain("Play!"); + }); +}); diff --git a/frontend/src/v2/components/Player/AssetCard.vue b/frontend/src/v2/components/Player/AssetCard.vue index 43b0001c1..13c16da9d 100644 --- a/frontend/src/v2/components/Player/AssetCard.vue +++ b/frontend/src/v2/components/Player/AssetCard.vue @@ -10,6 +10,7 @@ import { RImg, RTag } from "@v2/lib"; import { computed } from "vue"; import { useI18n } from "vue-i18n"; import type { SaveSchema, StateSchema } from "@/__generated__"; +import { useStreamingStore } from "@/stores/streaming"; import { formatBytes, formatRelativeDate, formatTimestamp } from "@/utils"; import { getEmptyCoverImage } from "@/v2/utils/covers"; @@ -27,6 +28,7 @@ defineEmits<{ }>(); const { t, locale } = useI18n(); +const { emulatorLabel } = useStreamingStore(); // States carry a screenshot; saves don't. Fall back to a placeholder // keyed by the file name so identical filenames render the same colour @@ -82,7 +84,7 @@ const relativeText = computed(() => formatRelativeDate(props.asset.updated_at)); v-if="asset.emulator" tone="warning" size="x-small" - :text="asset.emulator" + :text="emulatorLabel(asset.emulator)" />