feat(ui): book browse field registry, facet and sort query helpers (#2571)

This commit is contained in:
Alex
2026-09-26 12:55:44 +01:00
committed by GitHub
parent 0780199b4c
commit 742b550d56
17 changed files with 1069 additions and 50 deletions
@@ -1,9 +1,11 @@
import {describe, expect, it} from 'vitest';
import {
bookFacetQueryParams,
normalizeBookCollectionFilterParams,
normalizeBookQueryParams,
normalizeBookPageParams,
parseFacetParams,
toCollectionHttpParams,
toIdsHttpParams,
toPageHttpParams,
@@ -39,6 +41,15 @@ describe('book query parameters', () => {
});
});
it('round-trips a selection through route params and drops unknown keys', () => {
const selection = parseFacetParams([
'genre:Comedy', 'genre:Drama', 'tag:Anthology', 'future_group:a:b', '__proto__:READ',
]);
expect(selection).toEqual({genre: ['Comedy', 'Drama'], tag: ['Anthology']});
expect(bookFacetQueryParams(selection)).toEqual({facet: ['genre:Comedy', 'genre:Drama', 'tag:Anthology']});
expect(bookFacetQueryParams({})).toEqual({facet: null});
});
it('passes an empty sort through without imposing a default', () => {
const normalized = normalizeBookQueryParams({
facets: {},