This commit is contained in:
2026-09-29 18:47:37 +08:00
parent 2c60a29e0f
commit c2927ab9a6
291 changed files with 4008 additions and 6298 deletions
@@ -5,11 +5,11 @@ import { readInitialization, tableDefinitions, table, seedRows, roleAuthorities
const cn = readInitialization()
const overseas = readInitialization('OVERSEAS')
const domesticSchemas = ['baiyue_auth', 'baiyue_iam', 'baiyue_order', 'baiyue_warehouse',
'baiyue_firstleg', 'baiyue_file', 'baiyue_audit', 'baiyue_event_bridge', 'baiyue_finance']
const overseasSchemas = ['baiyue_event_bridge_overseas', 'baiyue_lastleg', 'baiyue_lastlag_warehouse']
'baiyue_firstleg', 'baiyue_file', 'baiyue_audit', 'baiyue_finance']
const overseasSchemas = ['baiyue_lastleg', 'baiyue_lastlag_warehouse']
test('两个入口分别只操作国内九库与海外三库,包括限定名引用', () => {
for (const [sql, allowed, other, count] of [[cn, domesticSchemas, overseasSchemas, 223], [overseas, overseasSchemas, domesticSchemas, 138]]) {
test('两个入口分别只操作八个主业务库与两个仓储业务库,包括限定名引用', () => {
for (const [sql, allowed, other, count] of [[cn, domesticSchemas, overseasSchemas, 223], [overseas, overseasSchemas, domesticSchemas, 135]]) {
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, '')
@@ -28,7 +28,7 @@ test('纯初始化禁止迁移、数据回填、清理、重复建表和提前
assert.doesNotMatch(body.replace(/^CREATE TRIGGER [\s\S]*?\$\$/gm, ''), /^\s*(?:UPDATE|DELETE FROM|REPLACE INTO)\b/gmi)
assert.doesNotMatch(body, /CREATE TABLE IF NOT EXISTS/i)
assert.equal((body.match(/AS initialization_status/g) ?? []).length, 1)
assert.match(body.trim(), /SELECT 'PASS' AS initialization_status, '(CN|OVERSEAS)' AS region, (223|138) AS initialized_tables;$/)
assert.match(body.trim(), /SELECT 'PASS' AS initialization_status, '(CN|OVERSEAS)' AS region, (223|135) AS initialized_tables;$/)
}
})
@@ -53,7 +53,7 @@ test('必要系统种子完整保留,但不写入示例资源与业务事实',
file_export_task_guard: 1, fin_subject: 1 })) assert.equal(seedRows(cn, name).length, count, name)
for (const name of ['wh_pallet', 'wh_location', 'wh_partner', 'wh_partner_type', 'wh_express_company',
'ord_order', 'fl_inbound_order', 'fin_fee_source']) assert.equal(seedRows(cn, name).length, 0, name)
assert.deepEqual([...new Set([...overseas.matchAll(/^INSERT INTO (\w+)/gm)].map(m => m[1]))], ['ll_security_projection'])
assert.deepEqual([...new Set([...overseas.matchAll(/^INSERT INTO (\w+)/gm)].map(m => m[1]))], [])
assert.ok(seedRows(cn, 'wh_warehouse').every(r => r.tenant_id === '0'))
assert.ok(seedRows(cn, 'wh_service_capability').every(r => r.service_type === 'RECEIVING' || r.capability_code === 'RECEIVING' || Object.values(r).includes('RECEIVING')))
})
@@ -98,19 +98,13 @@ test('近期头程与海外结构完整进入各自统一初始化入口', () =>
/shared_overflow tinyint\(1\) NOT NULL DEFAULT '?0'?/i)
})
test('海外固定身份投影完全匹配国内管理员的当前海外权限', () => {
const rows = seedRows(overseas, 'll_security_projection')
assert.equal(rows.length, 2)
const authorization = rows.find(r => r.projection_type === 'AUTHORIZATION' || r.subject_type === 'AUTHORIZATION' || Object.values(r).includes('AUTHORIZATION'))
assert.ok(authorization)
const authorities = JSON.parse(authorization.authorities_json)
const expected = [...roleAuthorities(cn, 'PLATFORM_ADMIN')].filter(code =>
/^(platform:finance:|platform:overseas-business:|platform:overseas-master-data:|platform:overseas-warehouse:)/.test(code))
assert.equal(authorities.length, 106)
assert.equal(new Set(authorities).size, authorities.length)
assert.deepEqual([...authorities].sort(), expected.sort())
assert.deepEqual(JSON.parse(authorization.roles_json), ['PLATFORM_ADMIN'])
for (const row of rows) assert.ok(Object.values(row).includes('1000001'))
test('统一认证保留持久版本,不再初始化安全投影或桥接发件箱', () => {
for (const retired of ['iam_security_event_outbox', 'll_security_event_inbox', 'll_security_projection']) {
assert.doesNotMatch(cn + overseas, new RegExp('CREATE TABLE ' + retired + '\\b'))
}
assert.ok(table(cn, 'baiyue_iam', 'iam_security_subject_version'))
assert.ok(table(cn, 'baiyue_iam', 'iam_security_tenant_version'))
assert.equal(seedRows(overseas, 'll_security_projection').length, 0)
})
test('跨区域放错位置的最终字段归正确区域且保留财务精度', () => {