Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Only show audio message when track ID matches active (#5305)
Anujcaed135ccf80
diff --git a/frontend/src/components/VAudioTrack/VAudioTrack.vue b/frontend/src/components/VAudioTrack/VAudioTrack.vueindex c945ce73b..15dcfed27 100644--- a/frontend/src/components/VAudioTrack/VAudioTrack.vue+++ b/frontend/src/components/VAudioTrack/VAudioTrack.vue@@ -297,7 +297,7 @@ watch(/* Timekeeping */const message = computed(() =>- activeMediaStore.message+ activeMediaStore.id === props.audio.id && activeMediaStore.message? t(`audioTrack.messages.${activeMediaStore.message}`): "")diff --git a/frontend/src/components/VAudioTrack/VWaveform.vue b/frontend/src/components/VAudioTrack/VWaveform.vueindex 183f65998..c39a13225 100644--- a/frontend/src/components/VAudioTrack/VWaveform.vue+++ b/frontend/src/components/VAudioTrack/VWaveform.vue@@ -481,6 +481,7 @@ const seekTimeLeft = computed(() => ({<divv-elseclass="loading absolute inset-0 flex items-center justify-center text-xs font-bold"+ data-testid="error-message">{{ message }}</div>diff --git a/frontend/test/unit/specs/components/AudioTrack/v-audio-track.spec.js b/frontend/test/unit/specs/components/AudioTrack/v-audio-track.spec.jsindex 5e7bdcecc..b60837134 100644--- a/frontend/test/unit/specs/components/AudioTrack/v-audio-track.spec.js+++ b/frontend/test/unit/specs/components/AudioTrack/v-audio-track.spec.js@@ -22,6 +22,7 @@ const RouterLinkStub = createApp({}).component("RouterLink", {},})._context.components.RouterLink+const ACTIVE_AUDIO = getAudioObj()const stubs = {VLicense: true,VWaveform: true,@@ -33,21 +34,17 @@ describe("AudioTrack", () => {let options = nulllet props = null+ const activeMediaStore = useActiveMediaStore()+ activeMediaStore.setActiveMediaItem({+ type: "audio",+ id: ACTIVE_AUDIO.id,+ })+beforeEach(() => {props = {- audio: getAudioObj(),+ audio: ACTIVE_AUDIO,layout: "full",}- const activeMediaStore = useActiveMediaStore()- activeMediaStore.$patch({- state: {- type: "audio",- id: "e19345b8-6937-49f7-a0fd-03bf057efc28",- message: null,- state: "paused",- },- })-options = {props: props,global: {@@ -103,8 +100,6 @@ describe("AudioTrack", () => {options.global.stubs.VWaveform = falseoptions.global.stubs.VAudioThumbnail = true- vi.clearAllMocks()-const pauseStub = vi.fn(() => undefined)const playStub = vi.fn(() => Promise.reject(playError))const playError = new DOMException("msg", errorType)@@ -117,13 +112,18 @@ describe("AudioTrack", () => {playStub)- const { getByRole, getByText } = await render(VAudioTrack, options)+ const { getByRole, getByText, getByTestId } = await render(+ VAudioTrack,+ options+ )await fireEvent.click(getByRole("button", { name: /play/i }))await nextTick()expect(playStub).toHaveBeenCalledTimes(1)expect(pauseStub).toHaveBeenCalledTimes(1)+expect(getByText(errorText)).toBeVisible()+ expect(getByTestId("error-message").textContent).toMatch(errorText)})@@ -158,4 +158,13 @@ describe("AudioTrack", () => {expect(screen.queryAllByTitle(match)).toEqual([])expect(screen.queryAllByAltText(match)).toEqual([])})++ it("should not show message when audio ID doesn't match active ID", async () => {+ activeMediaStore.id = "different-id"+ activeMediaStore.setMessage({ message: "err_network" })+ options.global.stubs.VWaveform = false++ const { queryByTestId } = await render(VAudioTrack, options)+ expect(queryByTestId("error-message")).not.toBeInTheDocument()+ })})