feat: establish auth listing and image vertical slices
Includes MFA-capable authentication, session and CSRF security, password recovery, listing lifecycle and ownership rules, inventory image metadata, local ImageStorage, migrations, tests, and implementation status documentation. Verification: npm test (62 passing) and integration suite (14 passing).
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { createProductService } from '../../src/modules/products/services/product-service.js';
|
||||
|
||||
test('creates seller-scoped slugs and increments duplicate names', async () => {
|
||||
const createdProducts = [];
|
||||
const productService = createProductService({
|
||||
productRepository: {
|
||||
async create(product) {
|
||||
createdProducts.push(product);
|
||||
return product;
|
||||
},
|
||||
async findBySellerIdAndSlug(sellerId, slug) {
|
||||
return (
|
||||
createdProducts.find(
|
||||
(product) => product.sellerId === sellerId && product.slug === slug,
|
||||
) ?? null
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const input = {
|
||||
name: 'Pikachu Plush',
|
||||
categoryId: 'category-id',
|
||||
sellerId: 'seller-id',
|
||||
};
|
||||
|
||||
await productService.create(input);
|
||||
const secondProduct = await productService.create(input);
|
||||
|
||||
assert.equal(secondProduct.slug, 'pikachu-plush-2');
|
||||
});
|
||||
Reference in New Issue
Block a user