mirror of
https://github.com/rommapp/romm.git
synced 2026-12-05 05:07:31 +01:00
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:
36
frontend/src/v2/components/Player/AssetCard.test.ts
Normal file
36
frontend/src/v2/components/Player/AssetCard.test.ts
Normal 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!");
|
||||
});
|
||||
});
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user