fix: clear re-match selection when searching again
This commit is contained in:
@@ -25,7 +25,10 @@ export default function ItemPage() {
|
|||||||
function searchAlbums() {
|
function searchAlbums() {
|
||||||
void api
|
void api
|
||||||
.searchAlbums(albumQuery)
|
.searchAlbums(albumQuery)
|
||||||
.then((res) => setAlbums(res.albums))
|
.then((res) => {
|
||||||
|
setAlbums(res.albums)
|
||||||
|
setPickedAlbum(null)
|
||||||
|
})
|
||||||
.catch(() => setAlbums([]))
|
.catch(() => setAlbums([]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,4 +110,21 @@ describe('ItemPage', () => {
|
|||||||
await waitFor(() => expect(api.deleteItem).toHaveBeenCalledWith(1))
|
await waitFor(() => expect(api.deleteItem).toHaveBeenCalledWith(1))
|
||||||
await waitFor(() => expect(screen.getByText('library')).toBeTruthy())
|
await waitFor(() => expect(screen.getByText('library')).toBeTruthy())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('re-match clears the picked album when searching again', async () => {
|
||||||
|
vi.mocked(api.searchAlbums)
|
||||||
|
.mockResolvedValueOnce({
|
||||||
|
albums: [{ id: 77, subsonicId: 'a1', title: 'Motion (Remaster)', artist: 'The Cinematic Orchestra' }],
|
||||||
|
} as never)
|
||||||
|
.mockResolvedValueOnce({
|
||||||
|
albums: [{ id: 88, subsonicId: 'a2', title: 'Something Else', artist: 'Other Artist' }],
|
||||||
|
} as never)
|
||||||
|
renderItem()
|
||||||
|
await userEvent.click(await screen.findByRole('button', { name: /re-match/i }))
|
||||||
|
await userEvent.click(screen.getByRole('button', { name: /^search$/i }))
|
||||||
|
await userEvent.click(await screen.findByRole('radio', { name: /motion \(remaster\)/i }))
|
||||||
|
await userEvent.click(screen.getByRole('button', { name: /^search$/i }))
|
||||||
|
const linkBtn = await screen.findByRole('button', { name: /^link$/i })
|
||||||
|
expect(linkBtn).toHaveProperty('disabled', true)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user