feat: add public search pagination

This commit is contained in:
2026-09-08 19:28:13 -04:00
parent 43f4f69894
commit 27fe6c6116
6 changed files with 134 additions and 18 deletions
@@ -9,7 +9,10 @@ test('normalizes public search input and delegates to the repository with public
listingRepository: {
async searchPublic(filters) {
calls.push(filters);
return [{ id: 'listing-1', status: 'AVAILABLE' }];
return {
items: [{ id: 'listing-1', status: 'AVAILABLE' }],
total: 21,
};
},
},
});
@@ -23,7 +26,15 @@ test('normalizes public search input and delegates to the repository with public
limit: 10,
});
assert.deepEqual(result, [{ id: 'listing-1', status: 'AVAILABLE' }]);
assert.deepEqual(result, {
items: [{ id: 'listing-1', status: 'AVAILABLE' }],
pagination: {
page: 2,
limit: 10,
total: 21,
totalPages: 3,
},
});
assert.deepEqual(calls, [{
text: 'pikachu 199 holo',
category: 'Cards',
@@ -39,7 +50,7 @@ test('allows explicit public sold results and keeps the public filter defaults',
const service = createSearchService({
listingRepository: {
async searchPublic(filters) {
return filters;
return { items: [filters], total: 1 };
},
},
});
@@ -52,9 +63,17 @@ test('allows explicit public sold results and keeps the public filter defaults',
});
assert.deepEqual(filters, {
text: 'charizard',
page: 1,
limit: 25,
includeSold: true,
items: [{
text: 'charizard',
page: 1,
limit: 25,
includeSold: true,
}],
pagination: {
page: 1,
limit: 25,
total: 1,
totalPages: 1,
},
});
});