Public Access
feat(library): sort by rating and priority
This commit is contained in:
1 parent
bad11807e0
commit
03259d0515
4 files changed
+18
-3
No files matched your search
+3
-1
@@ -123,7 +123,9 @@
|
||||
"LAST_SYNCED": "Zuletzt synchronisiert {{when}}",
|
||||
"FILTER_ALL": "Alle",
|
||||
"SEARCH_PLACEHOLDER": "Spiel suchen …",
|
||||
"NO_MATCH": "Keine Spiele für diesen Filter."
|
||||
"NO_MATCH": "Keine Spiele für diesen Filter.",
|
||||
"SORT_RATING": "Beste Bewertung",
|
||||
"SORT_PRIORITY": "Höchste Priorität"
|
||||
},
|
||||
"GAME_DETAIL": {
|
||||
"BACK": "Zurück",
|
||||
|
||||
+3
-1
@@ -123,7 +123,9 @@
|
||||
"LAST_SYNCED": "Last synced {{when}}",
|
||||
"FILTER_ALL": "All",
|
||||
"SEARCH_PLACEHOLDER": "Search games …",
|
||||
"NO_MATCH": "No games match this filter."
|
||||
"NO_MATCH": "No games match this filter.",
|
||||
"SORT_RATING": "Best rated",
|
||||
"SORT_PRIORITY": "Highest priority"
|
||||
},
|
||||
"GAME_DETAIL": {
|
||||
"BACK": "Back",
|
||||
|
||||
@@ -26,6 +26,8 @@ const SORT_OPTIONS = [
|
||||
{value: 'playtimeMinutes,asc', labelKey: 'LIBRARY.SORT_PLAYTIME_ASC'},
|
||||
{value: 'lastSeenAt,desc', labelKey: 'LIBRARY.SORT_LAST_SEEN'},
|
||||
{value: 'firstSeenAt,desc', labelKey: 'LIBRARY.SORT_FIRST_SEEN'},
|
||||
{value: 'rating,desc', labelKey: 'LIBRARY.SORT_RATING'},
|
||||
{value: 'priority,desc', labelKey: 'LIBRARY.SORT_PRIORITY'},
|
||||
];
|
||||
|
||||
export default function GameLibrary() {
|
||||
|
||||
@@ -39,7 +39,6 @@ function renderLibrary(initialEntry = '/library') {
|
||||
|
||||
const typeInto = (value) => fireEvent.change(screen.getByRole('searchbox'), {target: {value}});
|
||||
|
||||
describe('GameLibrary search', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.setItem('tbp_jwt', 'token');
|
||||
globalThis.fetch = vi.fn(async () => ({ok: true, status: 200, json: async () => page}));
|
||||
@@ -50,6 +49,7 @@ describe('GameLibrary search', () => {
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
describe('GameLibrary search', () => {
|
||||
it('writes the trimmed search to the URL after the delay and resets the page', async () => {
|
||||
const lib = renderLibrary('/library?page=3');
|
||||
|
||||
@@ -93,3 +93,12 @@ describe('GameLibrary search', () => {
|
||||
await waitFor(() => expect(screen.getByRole('searchbox').value).toBe(''));
|
||||
});
|
||||
});
|
||||
|
||||
describe('GameLibrary sort', () => {
|
||||
it.each(['rating,desc', 'priority,desc'])('sends the sort %s from the URL', async (sort) => {
|
||||
renderLibrary(`/library?sort=${encodeURIComponent(sort)}`);
|
||||
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalled());
|
||||
expect(new URL(fetch.mock.calls[0][0], 'http://x').searchParams.get('sort')).toBe(sort);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user