This commit is contained in:
@@ -244,6 +244,17 @@ test('persists image metadata only for the owning seller and counts item images'
|
||||
);
|
||||
});
|
||||
|
||||
test('enforces per-item image limits across concurrent inserts', async () => {
|
||||
const { seller, inventoryItem } = await createInventoryFixture();
|
||||
const image = (suffix) => ({ inventoryItemId: inventoryItem.id, storageKey: `inventory/${suffix}.jpg`, originalFilename: `${suffix}.jpg`, mimeType: 'image/jpeg', fileSize: 4, width: 2, height: 2, sortOrder: 0, isPrimary: false, processingStatus: 'PENDING' });
|
||||
const results = await Promise.allSettled([
|
||||
inventoryImageRepository.createForSellerWithLimit(image('a'), seller.id, 1),
|
||||
inventoryImageRepository.createForSellerWithLimit(image('b'), seller.id, 1),
|
||||
]);
|
||||
assert.equal(results.filter((result) => result.status === 'fulfilled').length, 1);
|
||||
assert.equal(results.filter((result) => result.status === 'rejected' && result.reason.code === 'IMAGE_COUNT_LIMIT_REACHED').length, 1);
|
||||
});
|
||||
|
||||
test('reads and updates listings only through the owning seller scope', async () => {
|
||||
const { seller, category, condition, inventoryItem } = await createInventoryFixture();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user