feat: enforce per-item image count limits
Quality / test (push) Canceled after 0s

This commit is contained in:
2026-09-11 00:39:27 -04:00
parent e6510c0317
commit f54223966c
7 changed files with 62 additions and 6 deletions
@@ -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();