feat: add public product catalog boundary
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
categories,
|
||||
conditionProfiles,
|
||||
conditions,
|
||||
listings,
|
||||
mfaMethods,
|
||||
passwordResetTokens,
|
||||
securityAuditEvents,
|
||||
@@ -154,6 +155,41 @@ test('finds a product by both its seller and slug', async () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('finds only products with active inventory and a public listing', async () => {
|
||||
const { seller, category, condition } = await createCatalogPrerequisites();
|
||||
const product = await productRepository.create({
|
||||
sellerId: seller.id,
|
||||
categoryId: category.id,
|
||||
name: 'Public Pikachu Plush',
|
||||
slug: 'public-pikachu-plush',
|
||||
});
|
||||
const inventoryItem = await inventoryItemRepository.create({
|
||||
productId: product.id,
|
||||
conditionId: condition.id,
|
||||
});
|
||||
|
||||
await database.db.insert(listings).values({
|
||||
inventoryItemId: inventoryItem.id,
|
||||
productName: product.name,
|
||||
categoryId: category.id,
|
||||
conditionId: condition.id,
|
||||
askingPriceMinor: 2499,
|
||||
status: 'PENDING',
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
(await productRepository.findPublicBySlug(product.slug))?.id,
|
||||
product.id,
|
||||
);
|
||||
|
||||
await database.db
|
||||
.update(listings)
|
||||
.set({ status: 'CLOSED' })
|
||||
.where(sql`inventory_item_id = ${inventoryItem.id}`);
|
||||
|
||||
assert.equal(await productRepository.findPublicBySlug(product.slug), null);
|
||||
});
|
||||
|
||||
test('retrieves only non-revoked, non-expired sessions', async () => {
|
||||
const { user, seller } = await createCatalogPrerequisites();
|
||||
const tokenHash = 'a hashed session token';
|
||||
|
||||
Reference in New Issue
Block a user