feat: add asynchronous inventory exports
Quality / test (push) Canceled after 0s

This commit is contained in:
2026-09-10 01:25:11 -04:00
parent abb0b64217
commit 7c4885cf65
16 changed files with 269 additions and 1 deletions
@@ -100,3 +100,29 @@ test('downloads seller-scoped inventory Excel XML for an authenticated admin', a
assert.equal(response.headers['content-disposition'], 'attachment; filename="inventory.xls"');
assert.equal(response.body, '<?xml version="1.0"?><Workbook />');
});
test('enqueues and polls an asynchronous inventory export', async (testContext) => {
const app = buildApp({
authenticateAdmin: async () => ({ sellerId: 'seller-1' }),
adminExportService: {
async enqueueInventoryJson({ sellerId }) {
assert.equal(sellerId, 'seller-1');
return { id: 'job-1', status: 'PENDING', createdAt: '2026-09-10' };
},
async getExportJob({ sellerId, jobId }) {
assert.equal(sellerId, 'seller-1');
assert.equal(jobId, 'job-1');
return { id: jobId, format: 'JSON', status: 'COMPLETED', output: [{ id: 'item-1' }] };
},
},
});
testContext.after(() => app.close());
const enqueue = await app.inject({ method: 'POST', url: '/api/v1/admin/exports/inventory.json/jobs' });
const poll = await app.inject({ method: 'GET', url: '/api/v1/admin/exports/jobs/job-1' });
assert.equal(enqueue.statusCode, 202);
assert.equal(enqueue.json().data.id, 'job-1');
assert.equal(poll.statusCode, 200);
assert.deepEqual(poll.json().data.output, [{ id: 'item-1' }]);
});