@@ -68,4 +68,28 @@ test('archives selected admin inventory items through the bulk API', async () =>
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
});
|
||||
|
||||
test('enqueues selected admin inventory pricing refreshes through the bulk API', async () => {
|
||||
const originalFetch = globalThis.fetch;
|
||||
globalThis.fetch = async (url, options) => {
|
||||
assert.equal(url, '/api/v1/admin/bulk');
|
||||
assert.equal(options.method, 'POST');
|
||||
assert.equal(options.headers['x-csrf-token'], 'csrf-token');
|
||||
assert.deepEqual(JSON.parse(options.body), {
|
||||
action: 'PRICING_REFRESH',
|
||||
inventoryItemIds: ['item-1'],
|
||||
providerId: 'fixture-provider',
|
||||
});
|
||||
return { ok: true, async json() { return { data: [{ id: 'job-1', status: 'PENDING' }] }; } };
|
||||
};
|
||||
|
||||
try {
|
||||
const { refreshAdminInventoryPricing } = await import('../src/services/admin-catalog-service.js');
|
||||
assert.deepEqual(await refreshAdminInventoryPricing(['item-1'], 'fixture-provider', 'csrf-token'), [
|
||||
{ id: 'job-1', status: 'PENDING' },
|
||||
]);
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user