chore(test): 清理旧迁移测试并统一前端格式
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import test from 'node:test'
|
||||
|
||||
const migration = readFileSync(
|
||||
fileURLToPath(new URL('../../db/migrations/113_finance_channel_cutover.sql', import.meta.url)),
|
||||
'utf8',
|
||||
)
|
||||
|
||||
test('113 迁移必须先删旧约束、再归一销售事实,最后加新约束', () => {
|
||||
const dropIndex = migration.indexOf(
|
||||
'DROP CONSTRAINT IF EXISTS chk_sales_daily_facts_fulfillment_mode',
|
||||
)
|
||||
const updateIndex = migration.indexOf('UPDATE sales_daily_facts')
|
||||
const constraintIndex = migration.indexOf('ADD CONSTRAINT chk_sales_daily_facts_fulfillment_mode')
|
||||
assert.ok(dropIndex > 0, '缺少旧渠道约束的删除')
|
||||
assert.ok(updateIndex > dropIndex, '必须先删旧约束再归一;否则 archived 会被旧约束拒绝')
|
||||
assert.ok(constraintIndex > updateIndex, '必须先归一数据,再加新约束')
|
||||
assert.ok(
|
||||
migration.includes("WHEN fulfillment_mode = 'legacy_platform' THEN 'archived'"),
|
||||
'legacy_platform 必须归入 archived',
|
||||
)
|
||||
assert.ok(
|
||||
migration.includes("ELSE 'unclassified'"),
|
||||
'其它未知旧值必须归入 unclassified,避免约束因脏数据失败',
|
||||
)
|
||||
for (const channel of [
|
||||
'work_order',
|
||||
'affiliate_dash',
|
||||
'third_party_voucher',
|
||||
'manual',
|
||||
'unclassified',
|
||||
'archived',
|
||||
]) {
|
||||
assert.ok(migration.includes(`'${channel}'`), `新约束必须允许 ${channel}`)
|
||||
}
|
||||
})
|
||||
|
||||
test('113 迁移的异常表旧行 scope_key 必须保证唯一', () => {
|
||||
assert.ok(
|
||||
migration.includes("'|legacy:' || id"),
|
||||
'旧异常行 scope_key 必须拼 id,避免同 reason + subject_id 撞唯一索引',
|
||||
)
|
||||
})
|
||||
@@ -6,7 +6,9 @@ import test from 'node:test'
|
||||
test('寄售仓库必须提供通过审核入库时间范围筛选,并透传到库存查询', () => {
|
||||
// Windows 检出为 CRLF,多行断言里的 \n 会匹配失败,先统一换行
|
||||
const source = readFileSync(
|
||||
fileURLToPath(new URL('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx', import.meta.url)),
|
||||
fileURLToPath(
|
||||
new URL('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx', import.meta.url),
|
||||
),
|
||||
'utf8',
|
||||
).replace(/\r\n/g, '\n')
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ function assertTopLevelMount(filePath: string, componentName: string) {
|
||||
|
||||
test('库存面板:手动匹配订单弹窗挂在顶层(按钮点了必须能弹出来)', () => {
|
||||
assertTopLevelMount(
|
||||
fileURLToPath(new URL('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx', import.meta.url)),
|
||||
fileURLToPath(
|
||||
new URL('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx', import.meta.url),
|
||||
),
|
||||
'ConsignmentManualMatchModal',
|
||||
)
|
||||
})
|
||||
@@ -39,7 +41,9 @@ test('订单面板:手动指定现货弹窗同样挂在顶层', () => {
|
||||
|
||||
test('按钮点击要真的把状态设上,弹窗的 open 由该状态驱动', () => {
|
||||
const source = readFileSync(
|
||||
fileURLToPath(new URL('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx', import.meta.url)),
|
||||
fileURLToPath(
|
||||
new URL('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx', import.meta.url),
|
||||
),
|
||||
'utf8',
|
||||
)
|
||||
assert.ok(source.includes('setManualMatchItem(record)'), '行内按钮必须设置待匹配的现货')
|
||||
@@ -48,7 +52,9 @@ test('按钮点击要真的把状态设上,弹窗的 open 由该状态驱动',
|
||||
|
||||
test('手动匹配入口必须按 consignment.fulfill 门控(提交的是履约动作,不能只挂 manage)', () => {
|
||||
const inventoryPanel = readFileSync(
|
||||
fileURLToPath(new URL('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx', import.meta.url)),
|
||||
fileURLToPath(
|
||||
new URL('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx', import.meta.url),
|
||||
),
|
||||
'utf8',
|
||||
)
|
||||
// 库存面板:手动匹配订单按钮要与编辑/作废拆开 —— 前者 fulfill(提交打到
|
||||
@@ -81,7 +87,9 @@ test('手动匹配入口必须按 consignment.fulfill 门控(提交的是履
|
||||
|
||||
test('手动匹配弹窗:数据过期的 409 要清选择并刷新,走内部现货直接履约', () => {
|
||||
const source = readFileSync(
|
||||
fileURLToPath(new URL('../src/components/admin/ConsignmentManualMatchModal.tsx', import.meta.url)),
|
||||
fileURLToPath(
|
||||
new URL('../src/components/admin/ConsignmentManualMatchModal.tsx', import.meta.url),
|
||||
),
|
||||
'utf8',
|
||||
)
|
||||
// 并发占用/规格在打开弹窗后被改 → 清空选择并重新拉列表,不能让运营循环撞同一个错
|
||||
@@ -120,7 +128,9 @@ test('发布拦截弹窗:只走内部现货履约,文案停在待加好友
|
||||
|
||||
test('寄售仓库库存面板:必须包含「通过审核入库时间」列,且详情弹窗正确展示时间', () => {
|
||||
const source = readFileSync(
|
||||
fileURLToPath(new URL('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx', import.meta.url)),
|
||||
fileURLToPath(
|
||||
new URL('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx', import.meta.url),
|
||||
),
|
||||
'utf8',
|
||||
)
|
||||
assert.ok(source.includes("title: '通过审核入库时间'"), '库存表格必须有「通过审核入库时间」列')
|
||||
@@ -137,7 +147,9 @@ test('寄售仓库库存面板:必须包含「通过审核入库时间」列
|
||||
|
||||
test('手动匹配弹窗:候选订单必须展示创建时间,现货展示审核入库时间', () => {
|
||||
const source = readFileSync(
|
||||
fileURLToPath(new URL('../src/components/admin/ConsignmentManualMatchModal.tsx', import.meta.url)),
|
||||
fileURLToPath(
|
||||
new URL('../src/components/admin/ConsignmentManualMatchModal.tsx', import.meta.url),
|
||||
),
|
||||
'utf8',
|
||||
)
|
||||
assert.ok(
|
||||
|
||||
@@ -5,7 +5,9 @@ import test from 'node:test'
|
||||
|
||||
test('自动核销最近任务展示并搜索核销码', () => {
|
||||
const page = readFileSync(
|
||||
fileURLToPath(new URL('../src/pages/admin/panels/VoucherConsumePolicyPanel.tsx', import.meta.url)),
|
||||
fileURLToPath(
|
||||
new URL('../src/pages/admin/panels/VoucherConsumePolicyPanel.tsx', import.meta.url),
|
||||
),
|
||||
'utf8',
|
||||
)
|
||||
const service = readFileSync(
|
||||
|
||||
Reference in New Issue
Block a user