Public Access
feat(library): hide and unhide games
This commit is contained in:
1 parent
42ed0afe51
commit
011711fe4f
9 files changed
+180
-14
No files matched your search
@@ -126,6 +126,46 @@ describe('GameLibrary short games', () => {
|
||||
await waitFor(() => expect(fetch.mock.calls.at(-1)[0]).toMatch(/[?&]maxMinutes=600(&|$)/));
|
||||
expect(screen.getByRole('button', {name: 'LIBRARY.FILTER_SHORT'}).getAttribute('aria-pressed')).toBe('true');
|
||||
});
|
||||
|
||||
it('shows only the hidden games and clears the other filters', async () => {
|
||||
const lib = renderLibrary('/library?status=BACKLOG&maxMinutes=600');
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalled());
|
||||
|
||||
fireEvent.click(screen.getByRole('button', {name: 'LIBRARY.FILTER_HIDDEN'}));
|
||||
|
||||
await waitFor(() => expect(lib.params().get('hidden')).toBe('true'));
|
||||
expect(lib.params().get('status')).toBeNull();
|
||||
expect(lib.params().get('maxMinutes')).toBeNull();
|
||||
await waitFor(() => expect(fetch.mock.calls.at(-1)[0]).toMatch(/[?&]hidden=true(&|$)/));
|
||||
expect(fetch.mock.calls.at(-1)[0]).not.toMatch(/status=|maxMinutes=/);
|
||||
expect(screen.getByRole('button', {name: 'LIBRARY.FILTER_ALL'}).getAttribute('aria-pressed')).toBe('false');
|
||||
});
|
||||
|
||||
it('leaves the hidden games with a status click', async () => {
|
||||
const lib = renderLibrary('/library?hidden=true');
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalled());
|
||||
|
||||
fireEvent.click(screen.getByRole('button', {name: 'BACKLOG.STATUS.PLAYING'}));
|
||||
|
||||
await waitFor(() => expect(lib.params().get('status')).toBe('PLAYING'));
|
||||
expect(lib.params().get('hidden')).toBeNull();
|
||||
await waitFor(() => expect(fetch.mock.calls.at(-1)[0]).not.toMatch(/hidden=/));
|
||||
});
|
||||
|
||||
it('ignores a status in a hidden link', async () => {
|
||||
renderLibrary('/library?hidden=true&status=BACKLOG');
|
||||
const gamesUrl = () => fetch.mock.calls.map(([url]) => String(url)).find((url) => url.includes('/api/library/games?'));
|
||||
|
||||
await waitFor(() => expect(gamesUrl()).toMatch(/[?&]hidden=true(&|$)/));
|
||||
expect(gamesUrl()).not.toMatch(/status=/);
|
||||
});
|
||||
|
||||
it('says so when no game is hidden', async () => {
|
||||
globalThis.fetch = vi.fn(async () => ({ok: true, status: 200, json: async () => ({...page, content: [], totalElements: 0, totalPages: 0})}));
|
||||
renderLibrary('/library?hidden=true');
|
||||
|
||||
expect(await screen.findByText('LIBRARY.NO_HIDDEN')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('GameLibrary with games added by hand', () => {
|
||||
|
||||
Reference in new issue
Block a user