新增 /customers/mall 卡片管理、Excel 导入、上下架/描述/收藏/移出;复用客户销售价接口;修复共享报价单并发改价、i18n、迁移空 schema、并发计数。
60 lines
2.7 KiB
TypeScript
60 lines
2.7 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const read = (rel: string) => readFileSync(new URL(`../${rel}`, import.meta.url), 'utf8');
|
|
const migration = read('../migrations/20261088_customer_skus_mall_fields.sql');
|
|
const svc = read('src/services/customerMallAdminService.ts');
|
|
const route = read('src/modules/workflow/routes/customerRoutes.ts');
|
|
const page = readFileSync(new URL('../../src/pages/customers/MallManagement.tsx', import.meta.url), 'utf8');
|
|
|
|
describe('商城管理一期', () => {
|
|
it('迁移幂等:is_listed/default true、description', () => {
|
|
expect(migration).toContain('ADD COLUMN IF NOT EXISTS is_listed BOOLEAN NOT NULL DEFAULT true');
|
|
expect(migration).toContain('ADD COLUMN IF NOT EXISTS description TEXT');
|
|
const mapping = read('src/services/importMappingMemoryService.ts');
|
|
expect(mapping).toContain("'mall_product'");
|
|
});
|
|
|
|
it('列表价格复用录单取价;只读 customer_skus/skus/categories', () => {
|
|
expect(svc).toContain('enrichOrderItemsWithPrices');
|
|
expect(svc).toContain('branch_code = $4');
|
|
expect(svc).toContain('FROM customer_skus cs');
|
|
expect(svc).toContain('sale_price');
|
|
expect(svc).not.toMatch(/INSERT INTO orders|UPDATE orders|inventory|settlement/i);
|
|
});
|
|
|
|
it('添加/导入只新增不覆盖;已存在/停用/不存在计数', () => {
|
|
expect(svc).toContain('ON CONFLICT (customer_code, sku_code) DO NOTHING');
|
|
expect(svc).toContain('already');
|
|
expect(svc).toContain('unknown');
|
|
expect(svc).toContain('sku_disabled');
|
|
expect(svc).toContain('will_skip');
|
|
});
|
|
|
|
it('更新展示字段/上下架/收藏;删除二次确认页面', () => {
|
|
expect(svc).toContain('customer_sku_name');
|
|
expect(svc).toContain('is_listed');
|
|
expect(svc).toContain("operationType: 'customer_mall_sku_update'");
|
|
expect(svc).toContain("operationType: 'customer_mall_sku_remove'");
|
|
expect(page).toContain('confirmDialog');
|
|
});
|
|
|
|
it('6 个 workflow 路由 + customer_manage', () => {
|
|
for (const path of ['mall-products', 'mall-catalog']) {
|
|
expect(route).toContain(path);
|
|
}
|
|
expect(route).toContain("requireWorkflowPermission(ctx, ['customer_manage'])");
|
|
expect(route).toContain("dry_run");
|
|
});
|
|
|
|
it('前端价格复用 setCustomerSkuSalePriceApi、原位编辑、导入预览', () => {
|
|
expect(page).toContain('setCustomerSkuSalePriceApi');
|
|
expect(page).toContain('onBlur');
|
|
expect(page).toContain('BulkImportModal');
|
|
expect(page).toContain('mapMallImportRows');
|
|
expect(page).toContain('resolveSkuImageUrl');
|
|
expect(page).toContain('TablePaginationBar');
|
|
expect(page).toContain('removeMallLibrarySkuApi');
|
|
});
|
|
});
|