feat: add admin inventory CSV export
Quality / test (push) Canceled after 0s

This commit is contained in:
2026-09-10 00:31:00 -04:00
parent d3821e9c76
commit 7c9518923d
8 changed files with 95 additions and 2 deletions
@@ -57,3 +57,26 @@ test('requires authentication for inventory JSON exports', async (testContext) =
assert.equal(response.statusCode, 401);
assert.equal(response.json().error.code, 'UNAUTHORIZED');
});
test('downloads seller-scoped inventory CSV for an authenticated admin', async (testContext) => {
const app = buildApp({
authenticateAdmin: async () => ({ sellerId: 'seller-1' }),
adminExportService: {
async inventoryCsv({ sellerId }) {
assert.equal(sellerId, 'seller-1');
return 'id,status\r\n"item-1","ACTIVE"';
},
},
});
testContext.after(() => app.close());
const response = await app.inject({
method: 'GET',
url: '/api/v1/admin/exports/inventory.csv',
});
assert.equal(response.statusCode, 200);
assert.equal(response.headers['content-type'], 'text/csv; charset=utf-8');
assert.equal(response.headers['content-disposition'], 'attachment; filename="inventory.csv"');
assert.equal(response.body, 'id,status\r\n"item-1","ACTIVE"');
});