feat: expose bulk archive in admin workspace
Quality / test (push) Canceled after 0s

This commit is contained in:
2026-09-09 23:48:34 -04:00
parent 12eced8b19
commit e0d231facc
4 changed files with 83 additions and 1 deletions
+23
View File
@@ -45,4 +45,27 @@ test('fetches a public product using its stable slug URL', async () => {
} finally {
globalThis.fetch = originalFetch;
}
});
test('archives selected admin inventory items 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: 'ARCHIVE',
inventoryItemIds: ['item-1'],
});
return { ok: true, async json() { return { data: [{ id: 'item-1', status: 'ARCHIVED' }] }; } };
};
try {
const { archiveAdminInventory } = await import('../src/services/admin-catalog-service.js');
assert.deepEqual(await archiveAdminInventory(['item-1'], 'csrf-token'), [
{ id: 'item-1', status: 'ARCHIVED' },
]);
} finally {
globalThis.fetch = originalFetch;
}
});