feat: add pricing provider boundary
Quality / test (push) Canceled after 0s

This commit is contained in:
2026-09-09 11:19:27 -04:00
parent 7c4a299838
commit 4effebd2f8
8 changed files with 135 additions and 1 deletions
@@ -44,4 +44,30 @@ test('accepts a CSRF-protected market-value override', async (testContext) => {
assert.equal(response.statusCode, 201);
assert.equal(received.actorUserId, 'user-1');
assert.equal(response.json().data.valueMinor, 2600);
});
test('returns a clear unavailable response when no provider is configured', async (testContext) => {
const app = buildApp({
authenticateAdmin: async () => ({ sellerId: 'seller-1' }),
authorizeUnsafeRequest: async () => {},
pricingService: {
async refresh() {
const error = new Error('Pricing provider is not configured.');
error.code = 'PRICING_PROVIDER_UNAVAILABLE';
error.statusCode = 503;
throw error;
},
},
});
testContext.after(() => app.close());
const response = await app.inject({
method: 'POST',
url: '/api/v1/admin/inventory/inventory-1/pricing/refresh',
headers: { 'x-csrf-token': 'csrf' },
payload: { providerId: 'missing' },
});
assert.equal(response.statusCode, 503);
assert.equal(response.json().error.code, 'PRICING_PROVIDER_UNAVAILABLE');
});