refactor(search): simplify order by + wire reverse
This commit is contained in:
@@ -16,12 +16,12 @@ it('builds search requests including filters', async () => {
|
||||
fileTypes: ['mp3', 'wav'],
|
||||
minSize: 1,
|
||||
maxSize: 9,
|
||||
sortBy: 'date'
|
||||
sortBy: 'updated_at'
|
||||
}).catch(() => {});
|
||||
expect(j).toHaveBeenCalledWith(expect.stringContaining('type=mp3%2Cwav'), expect.anything());
|
||||
// Sort dimension is sent on the wire as `order_by`, matching the
|
||||
// backend's `SearchResourcesQuery` (post-normalization).
|
||||
expect(j).toHaveBeenCalledWith(expect.stringContaining('order_by=date'), expect.anything());
|
||||
expect(j).toHaveBeenCalledWith(expect.stringContaining('order_by=updated_at'), expect.anything());
|
||||
await searchSuggest('q').catch(() => {});
|
||||
await clearSearchCache().catch(() => {});
|
||||
expect(f.mock.calls.length + j.mock.calls.length).toBeGreaterThan(1);
|
||||
|
||||
@@ -248,14 +248,14 @@ export interface AuthResponse {
|
||||
expires_in: number;
|
||||
}
|
||||
|
||||
export type SortBy =
|
||||
| 'relevance'
|
||||
| 'name'
|
||||
| 'name_desc'
|
||||
| 'date'
|
||||
| 'date_desc'
|
||||
| 'size'
|
||||
| 'size_desc';
|
||||
/**
|
||||
* Sort dimension for `GET /api/search`. Wire-matches the backend's
|
||||
* `SearchResourcesQuery.order_by` — 5 canonical values, direction is
|
||||
* a separate `reverse` boolean (the `_desc` suffix pattern was
|
||||
* retired 2026-07-26; `date` was renamed to the more explicit
|
||||
* `updated_at` alongside the new `created_at`).
|
||||
*/
|
||||
export type SortBy = 'relevance' | 'name' | 'size' | 'updated_at' | 'created_at';
|
||||
|
||||
/**
|
||||
* Per-item search metadata inline on every hit in the normalized
|
||||
|
||||
Reference in New Issue
Block a user