This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user