fix(streaming): label the emulator on save and state picker cards

The pickers before a launch still showed the raw id, so a Play! save read
"play" there while every other asset chip named it.
This commit is contained in:
Zach Clendenen
2026-09-17 18:38:40 -05:00
parent d3795cb1b8
commit d545e13b3d
2 changed files with 39 additions and 1 deletions

View File

@@ -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: `<span class="tag">{{ text }}</span>`,
};
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!");
});
});

View File

@@ -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)"
/>
<RTag size="x-small" :text="formatBytes(asset.file_size_bytes)" />
</div>