feat: add public listing catalog boundary

This commit is contained in:
2026-09-08 19:30:09 -04:00
parent 27fe6c6116
commit f42d3e4fd5
14 changed files with 838 additions and 3 deletions
@@ -0,0 +1,31 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createPublicListingService } from '../../src/modules/listings/services/public-listing-service.js';
test('lists visible public listings through the shared repository search boundary', async () => {
const service = createPublicListingService({
listingRepository: {
async searchPublic(filters) {
assert.deepEqual(filters, { query: '', page: 2, limit: 5 });
return { items: [{ id: 'listing-1' }], total: 1 };
},
},
});
assert.deepEqual(await service.list({ page: 2, limit: 5 }), {
items: [{ id: 'listing-1' }],
total: 1,
});
});
test('returns a not-found application error for a hidden public listing', async () => {
const service = createPublicListingService({
listingRepository: { async findPublicById() { return null; } },
});
await assert.rejects(
() => service.getById('listing-1'),
(error) => error.code === 'LISTING_NOT_FOUND' && error.statusCode === 404,
);
});