优化
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import test from 'node:test'
|
||||
import { readInitialization, tableDefinitions, table, seedRows, roleAuthorities } from '../sql-baseline-contract-helpers.mjs'
|
||||
|
||||
@@ -17,7 +18,7 @@ test('种子解析覆盖多行多值、函数括号及带逗号和引号的文
|
||||
})
|
||||
|
||||
test('两个入口分别只操作八个主业务库与两个仓储业务库,包括限定名引用', () => {
|
||||
for (const [sql, allowed, other, count] of [[cn, domesticSchemas, overseasSchemas, 227], [overseas, overseasSchemas, domesticSchemas, 214]]) {
|
||||
for (const [sql, allowed, other, count] of [[cn, domesticSchemas, overseasSchemas, 227], [overseas, overseasSchemas, domesticSchemas, 228]]) {
|
||||
assert.deepEqual([...sql.matchAll(/^CREATE DATABASE IF NOT EXISTS (\w+)/gm)].map(m => m[1]), allowed)
|
||||
assert.deepEqual([...new Set([...sql.matchAll(/^USE (\w+);/gm)].map(m => m[1]))], allowed)
|
||||
const body = sql.replace(/^--.*$/gm, '')
|
||||
@@ -76,7 +77,47 @@ test('退回实收按真实流水唯一保存,重派拣货必须明确唯一
|
||||
}
|
||||
const pick = table(overseas, 'baiyue_lastleg', 'll_dispatch_pda_pick_order')
|
||||
assert.match(pick, /\breceipt_id BIGINT NULL/i)
|
||||
assert.match(pick, /CHECK\(\(receipt_id IS NOT NULL\) \+ \(return_receipt_id IS NOT NULL\) \+ \(return_carton_id IS NOT NULL\) = 1\)/i)
|
||||
assert.match(pick, /\bdispatch_item_source_id BIGINT NULL/i)
|
||||
assert.match(pick, /CHECK\(\(receipt_id IS NOT NULL\) \+ \(return_receipt_id IS NOT NULL\) \+ \(return_carton_id IS NOT NULL\) \+ \(dispatch_item_source_id IS NOT NULL\) = 1\)/i)
|
||||
})
|
||||
|
||||
test('同实托初始化分离无代表客户的物理占用与逐来源占用', () => {
|
||||
const physical = table(overseas, 'baiyue_lastleg', 'll_dispatch_physical_pallet_lock')
|
||||
assert.doesNotMatch(physical, /\bcustomer_id\b/i)
|
||||
assert.match(physical, /UNIQUE KEY[^\n]*\(active_warehouse_pallet_id\)/i)
|
||||
assert.match(physical, /CHECK\(\(status='ACTIVE' AND active_warehouse_pallet_id IS NOT NULL AND active_warehouse_pallet_id=warehouse_pallet_id\)/i)
|
||||
assert.match(physical, /dispatch_order_id IS NOT NULL AND draft_token IS NULL AND draft_container_id IS NULL/i)
|
||||
assert.match(physical, /dispatch_order_id IS NULL AND draft_token IS NOT NULL AND draft_container_id IS NOT NULL/i)
|
||||
const logical = table(overseas, 'baiyue_lastleg', 'll_dispatch_pallet_lock')
|
||||
assert.match(logical, /physical_lock_id BIGINT NULL/i)
|
||||
assert.match(logical, /UNIQUE KEY[^\n]*\(customer_id,active_key\)/i)
|
||||
assert.doesNotMatch(logical, /active_warehouse_pallet_id/i)
|
||||
assert.match(table(overseas, 'baiyue_lastleg', 'll_dispatch_item'), /UNIQUE KEY[^\n]*\(dispatch_order_id,source_key\)/i)
|
||||
const source = table(overseas, 'baiyue_lastleg', 'll_dispatch_item_source')
|
||||
assert.match(source, /UNIQUE KEY[^\n]*\(dispatch_item_id,relabel_item_id,inventory_position_id\)/i)
|
||||
assert.match(source, /product_quantity BIGINT NULL/i)
|
||||
assert.match(source, /source_inbound_order_id BIGINT NULL/i)
|
||||
assert.match(source, /relabel_round_key VARCHAR\(128\) NOT NULL/i)
|
||||
assert.match(source, /unit_facts_json JSON NOT NULL/i)
|
||||
})
|
||||
|
||||
test('实托组成串行点只保存真实主键和首次创建时间', () => {
|
||||
const guard = table(overseas, 'baiyue_lastleg', 'll_physical_pallet_guard')
|
||||
assert.match(guard, /warehouse_pallet_id BIGINT NOT NULL/i)
|
||||
assert.match(guard, /created_at DATETIME\(3\) NOT NULL DEFAULT CURRENT_TIMESTAMP\(3\)/i)
|
||||
assert.match(guard, /PRIMARY KEY\s*\(warehouse_pallet_id\)/i)
|
||||
assert.doesNotMatch(guard, /\b(?:customer_id|status|expires_at|dispatch_order_id|draft_token|draft_container_id)\b/i)
|
||||
})
|
||||
|
||||
test('同实托六表定义在模块和统一空库入口保持一致', () => {
|
||||
const module = 'USE baiyue_lastleg;\n' + readFileSync(new URL('../../lastleg-service/src/main/resources/db/lastleg.sql', import.meta.url), 'utf8')
|
||||
.replace(/^[ \t]*CREATE TABLE IF NOT EXISTS /gm, 'CREATE TABLE ')
|
||||
.replace(/^[ \t]+\) ENGINE=/gm, ') ENGINE=')
|
||||
const body = value => value.slice(value.indexOf('('), value.lastIndexOf(') ENGINE='))
|
||||
.replace(/\r\n/g, '\n').replace(/[ \t]+/g, ' ').trim()
|
||||
for (const name of ['ll_dispatch_item', 'll_dispatch_item_source', 'll_physical_pallet_guard', 'll_dispatch_physical_pallet_lock', 'll_dispatch_pallet_lock', 'll_dispatch_pda_pick_order']) {
|
||||
assert.equal(body(table(overseas, 'baiyue_lastleg', name)), body(table(module, 'baiyue_lastleg', name)), name)
|
||||
}
|
||||
})
|
||||
|
||||
test('车辆报价与实测记录保留业务去重和不可变版本', () => {
|
||||
@@ -133,7 +174,7 @@ test('平台管理员由外部bcrypt引导,强制首登改密且不创建客
|
||||
})
|
||||
|
||||
test('必要系统种子完整保留,但不写入示例资源与业务事实', () => {
|
||||
for (const [name, count] of Object.entries({ iam_role: 8, iam_permission: 433, iam_role_permission: 614,
|
||||
for (const [name, count] of Object.entries({ iam_role: 8, iam_permission: 434, iam_role_permission: 618,
|
||||
iam_data_scope: 7, wh_warehouse: 318, wh_warehouse_address: 318, wh_service_capability: 4,
|
||||
fl_fee_item: 112, fl_price_channel_catalog: 15, fl_price_origin_alias: 7, fl_price_warehouse_mapping: 4,
|
||||
file_export_task_guard: 1, fin_subject: 1 })) assert.equal(seedRows(cn, name).length, count, name)
|
||||
@@ -160,8 +201,15 @@ test('国内IAM权限与角色授权没有丢失或悬挂,客户模板仍完
|
||||
for (const row of permissions) if (row.parent_id && row.parent_id !== '0') assert.ok(permissionIds.has(row.parent_id), 'missing parent ' + row.parent_id)
|
||||
const merchant = roleAuthorities(cn, 'MERCHANT_OWNER')
|
||||
for (const code of ['merchant:enterprise', 'merchant:order:quick-create', 'merchant:finance:statement',
|
||||
'merchant:warehouse:delivery:list', 'merchant:warehouse:delivery:create']) assert.ok(merchant.has(code), code)
|
||||
'merchant:warehouse:delivery:list']) assert.ok(merchant.has(code), code)
|
||||
assert.ok(!permissions.some(row => row.permission_code === 'merchant:warehouse:delivery:create'))
|
||||
assert.ok(!merchant.has('merchant:warehouse:delivery:create'))
|
||||
const admin = roleAuthorities(cn, 'PLATFORM_ADMIN')
|
||||
for (const action of ['create', 'loading-complete', 'depart']) {
|
||||
const code = `platform:overseas-warehouse:dispatch:${action}`
|
||||
assert.ok(admin.has(code), code)
|
||||
assert.ok(!merchant.has(code), code)
|
||||
}
|
||||
assert.ok(admin.has('platform:overseas-warehouse:discard:approve'), 'discard review endpoint must be grantable to platform administrator')
|
||||
for (const action of ['list', 'create', 'edit', 'status', 'review', 'upload']) {
|
||||
assert.ok(admin.has(`platform:overseas-master-data:driver:${action}`))
|
||||
|
||||
Reference in New Issue
Block a user