This commit is contained in:
@@ -70,4 +70,30 @@ test('enqueues a pricing refresh and exposes seller-scoped job status', async (t
|
||||
const jobResponse = await app.inject({ method: 'GET', url: '/api/v1/admin/jobs/job-1' });
|
||||
assert.equal(jobResponse.statusCode, 200);
|
||||
assert.equal(jobResponse.json().data.status, 'COMPLETED');
|
||||
});
|
||||
|
||||
test('returns a conflict when refresh has no active product mapping', async (testContext) => {
|
||||
const app = buildApp({
|
||||
authenticateAdmin: async () => ({ sellerId: 'seller-1' }),
|
||||
authorizeUnsafeRequest: async () => {},
|
||||
pricingService: {
|
||||
async enqueueRefresh() {
|
||||
const error = new Error('No active pricing provider mapping exists for this product.');
|
||||
error.code = 'PRICING_PROVIDER_MAPPING_NOT_FOUND';
|
||||
error.statusCode = 409;
|
||||
throw error;
|
||||
},
|
||||
},
|
||||
});
|
||||
testContext.after(() => app.close());
|
||||
|
||||
const response = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/api/v1/admin/inventory/item-1/pricing/refresh',
|
||||
headers: { 'x-csrf-token': 'csrf' },
|
||||
payload: { productId: 'product-1', conditionId: 'condition-1' },
|
||||
});
|
||||
|
||||
assert.equal(response.statusCode, 409);
|
||||
assert.equal(response.json().error.code, 'PRICING_PROVIDER_MAPPING_NOT_FOUND');
|
||||
});
|
||||
Reference in New Issue
Block a user