fix: allow sellers to remove public contact methods
Quality / test (push) Canceled after 0s

This commit is contained in:
2026-09-10 07:56:17 -04:00
parent 73c430b8a5
commit 9a790ce294
12 changed files with 122 additions and 22 deletions
@@ -1,3 +1,5 @@
import { createSellerSettingsService } from '../../src/modules/settings/services/seller-settings-service.js';
import { createSellerSettingsRepository } from '../../src/modules/settings/repositories/seller-settings-repository.js';
import assert from 'node:assert/strict';
import test, { after, beforeEach } from 'node:test';
@@ -194,6 +196,17 @@ test('finds only products with active inventory and a public listing', async ()
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.');
const settingsService = createSellerSettingsService({ sellerSettingsRepository: createSellerSettingsRepository(database.db) });
await settingsService.update({ sellerId: seller.id, settings: { general: { publicContactEmail: 'owner@example.test', publicContactPhone: '555-0100' } } });
assert.equal((await productRepository.findPublicBySlug(product.slug)).sellerContactEmail, 'owner@example.test');
assert.equal((await productRepository.findPublicBySlug(product.slug)).sellerContactPhone, '555-0100');
await settingsService.update({ sellerId: seller.id, settings: { general: { publicContactEmail: '' } } });
assert.equal((await productRepository.findPublicBySlug(product.slug)).sellerContactEmail, null);
assert.equal((await productRepository.findPublicBySlug(product.slug)).sellerContactPhone, '555-0100');
await settingsService.update({ sellerId: seller.id, settings: { general: { publicContactPhone: ' ' } } });
assert.equal((await productRepository.findPublicBySlug(product.slug)).sellerContactPhone, null);
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);
@@ -1,3 +1,5 @@
import { createSellerSettingsService } from '../../src/modules/settings/services/seller-settings-service.js';
import { createSellerSettingsRepository } from '../../src/modules/settings/repositories/seller-settings-repository.js';
import assert from 'node:assert/strict';
import test, { after, beforeEach } from 'node:test';
@@ -152,6 +154,17 @@ test('searches public listings with pagination and hides sold items by default',
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.');
const settingsService = createSellerSettingsService({ sellerSettingsRepository: createSellerSettingsRepository(database.db) });
await settingsService.update({ sellerId: product.sellerId, settings: { general: { publicContactEmail: 'owner@example.test', publicContactPhone: '555-0100' } } });
assert.equal((await listingRepository.findPublicById(visible.items[0].id)).sellerContactEmail, 'owner@example.test');
assert.equal((await listingRepository.findPublicById(visible.items[0].id)).sellerContactPhone, '555-0100');
await settingsService.update({ sellerId: product.sellerId, settings: { general: { publicContactEmail: '' } } });
assert.equal((await listingRepository.findPublicById(visible.items[0].id)).sellerContactEmail, null);
assert.equal((await listingRepository.findPublicById(visible.items[0].id)).sellerContactPhone, '555-0100');
await settingsService.update({ sellerId: product.sellerId, settings: { general: { publicContactPhone: ' ' } } });
assert.equal((await listingRepository.findPublicById(visible.items[0].id)).sellerContactPhone, null);
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);