fix: refetch item detail after re-match so the play button stays honest
This commit is contained in:
@@ -119,6 +119,27 @@ describe('ItemPage', () => {
|
||||
await waitFor(() => expect(api.setMatch).toHaveBeenCalledWith(1, 77))
|
||||
})
|
||||
|
||||
it('re-match refreshes the play button state', async () => {
|
||||
vi.mocked(api.getItem)
|
||||
.mockResolvedValueOnce({ ...rippedItem, matchedAlbum: null } as never)
|
||||
.mockResolvedValue({ ...rippedItem } as never)
|
||||
vi.mocked(api.searchAlbums).mockResolvedValue({
|
||||
albums: [{ id: 77, subsonicId: 'a1', title: 'Motion (Remaster)', artist: 'The Cinematic Orchestra' }],
|
||||
} as never)
|
||||
vi.mocked(api.setMatch).mockResolvedValue({ ...item } as never)
|
||||
renderItem()
|
||||
await waitFor(() => expect(screen.getByRole('heading', { name: 'Motion' })).toBeTruthy())
|
||||
expect(screen.queryByRole('button', { name: /play album/i })).toBeNull()
|
||||
|
||||
await userEvent.click(screen.getByRole('button', { name: /re-match/i }))
|
||||
await userEvent.click(screen.getByRole('button', { name: /^search$/i }))
|
||||
const albumRadio = await screen.findByRole('radio', { name: /motion \(remaster\)/i })
|
||||
await userEvent.click(albumRadio)
|
||||
await userEvent.click(screen.getByRole('button', { name: /^link$/i }))
|
||||
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: /play album/i })).toBeTruthy())
|
||||
})
|
||||
|
||||
it('unlink clears the match', async () => {
|
||||
vi.mocked(api.setMatch).mockResolvedValue(item as never)
|
||||
renderItem()
|
||||
|
||||
Reference in New Issue
Block a user