This commit is contained in:
@@ -40,3 +40,19 @@ test('rejects unknown or invalid settings', async () => {
|
||||
() => service.update({ sellerId: 'seller-1', settings: { secrets: { token: 'nope' } } }),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
test('seller descriptions are trimmed, bounded, preserved on partial updates and clearable', async () => {
|
||||
let stored;
|
||||
const service = createSellerSettingsService({ sellerSettingsRepository: {
|
||||
async findBySellerId() { return stored; },
|
||||
async upsert(sellerId, settings) { stored = { sellerId, settings }; return stored; },
|
||||
} });
|
||||
const update = (general) => service.update({ sellerId: 'seller-1', settings: { general } });
|
||||
assert.equal((await update({ publicDescription: ' Collector. ' })).general.publicDescription, 'Collector.');
|
||||
assert.equal((await update({ publicContactPhone: '555-0100' })).general.publicDescription, 'Collector.');
|
||||
await assert.rejects(() => update({ publicDescription: 'x'.repeat(2001) }));
|
||||
await assert.rejects(() => update({ publicDescription: 123 }));
|
||||
assert.equal((await update({ publicDescription: 'x'.repeat(2000) })).general.publicDescription.length, 2000);
|
||||
assert.equal((await update({ publicDescription: ' ' })).general.publicDescription, '');
|
||||
});
|
||||
|
||||
@@ -37,6 +37,7 @@ function createTestApp() {
|
||||
askingPriceMinor: 2499,
|
||||
status: 'PENDING',
|
||||
sellerDisplayName: 'Pika Collectibles',
|
||||
sellerDescription: 'Independent Pokémon collector.',
|
||||
sellerContactEmail: 'hello@pika.example',
|
||||
sellerContactPhone: null,
|
||||
};
|
||||
@@ -76,6 +77,7 @@ test('returns a public listing detail or a not-found response', async (testConte
|
||||
assert.equal(detailResponse.statusCode, 200);
|
||||
assert.equal('inventoryItemId' in detailResponse.json().data, false);
|
||||
assert.equal(detailResponse.json().data.sellerDisplayName, 'Pika Collectibles');
|
||||
assert.equal(detailResponse.json().data.sellerDescription, 'Independent Pokémon collector.');
|
||||
assert.equal(detailResponse.json().data.sellerContactEmail, 'hello@pika.example');
|
||||
assert.equal(missingResponse.statusCode, 404);
|
||||
assert.equal(missingResponse.json().error.code, 'LISTING_NOT_FOUND');
|
||||
|
||||
@@ -22,6 +22,7 @@ function createTestApp() {
|
||||
slug,
|
||||
description: 'A friendly plush.',
|
||||
sellerDisplayName: 'Pika Collectibles',
|
||||
sellerDescription: 'Independent Pokémon collector.',
|
||||
sellerContactEmail: 'hello@pika.example',
|
||||
sellerContactPhone: null,
|
||||
createdAt: new Date('2026-09-07T00:00:00.000Z'),
|
||||
@@ -55,6 +56,7 @@ test('returns a public product without private seller identity', async (testCont
|
||||
releaseYear: null,
|
||||
tags: [],
|
||||
sellerDisplayName: 'Pika Collectibles',
|
||||
sellerDescription: 'Independent Pokémon collector.',
|
||||
sellerContactEmail: 'hello@pika.example',
|
||||
sellerContactPhone: null,
|
||||
createdAt: '2026-09-07T00:00:00.000Z',
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
products,
|
||||
securityAuditEvents,
|
||||
sellers,
|
||||
sellerSettings,
|
||||
sessions,
|
||||
users,
|
||||
} from '../../src/infrastructure/database/schema.js';
|
||||
@@ -190,6 +191,12 @@ test('finds only products with active inventory and a public listing', async ()
|
||||
product.id,
|
||||
);
|
||||
|
||||
assert.equal((await productRepository.findPublicBySlug(product.slug)).sellerDescription, null);
|
||||
await database.db.insert(sellerSettings).values({ sellerId: seller.id, settings: { general: { publicDescription: 'Collector.' }, security: { sessionIdleMinutes: 60 } } });
|
||||
assert.equal((await productRepository.findPublicBySlug(product.slug)).sellerDescription, 'Collector.');
|
||||
await database.db.update(sellerSettings).set({ settings: { general: { publicDescription: '' } } });
|
||||
assert.equal((await productRepository.findPublicBySlug(product.slug)).sellerDescription, null);
|
||||
|
||||
await database.db
|
||||
.update(listings)
|
||||
.set({ status: 'CLOSED' })
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
listings,
|
||||
products,
|
||||
sellers,
|
||||
sellerSettings,
|
||||
users,
|
||||
} from '../../src/infrastructure/database/schema.js';
|
||||
import { createInventoryImageRepository } from '../../src/modules/inventory/repositories/inventory-image-repository.js';
|
||||
@@ -148,6 +149,12 @@ test('searches public listings with pagination and hides sold items by default',
|
||||
visible.items[0].id,
|
||||
);
|
||||
|
||||
assert.equal((await listingRepository.findPublicById(visible.items[0].id)).sellerDescription, null);
|
||||
await database.db.insert(sellerSettings).values({ sellerId: product.sellerId, settings: { general: { publicDescription: 'Collector.' }, security: { sessionIdleMinutes: 60 } } });
|
||||
assert.equal((await listingRepository.findPublicById(visible.items[0].id)).sellerDescription, 'Collector.');
|
||||
await database.db.update(sellerSettings).set({ settings: { general: { publicDescription: '' } } });
|
||||
assert.equal((await listingRepository.findPublicById(visible.items[0].id)).sellerDescription, null);
|
||||
|
||||
await database.db
|
||||
.update(listings)
|
||||
.set({ status: 'CLOSED' })
|
||||
|
||||
Reference in New Issue
Block a user