This commit is contained in:
2026-08-26 11:10:42 +08:00
parent 15421db421
commit cf5d603a21
35 changed files with 664 additions and 435 deletions
@@ -7,23 +7,23 @@ const iamSeed = readFileSync(new URL('../../iam/src/main/resources/db/phase1-adm
const oceanBookingSchema = readFileSync(new URL('../../firstleg/src/main/resources/db/phase3-ocean-booking-schema.sql', import.meta.url), 'utf8')
const truckAppointmentSchema = readFileSync(new URL('../../firstleg/src/main/resources/db/phase3-truck-appointment-schema.sql', import.meta.url), 'utf8')
test('统一初始化 SQL 保留最小登录与客户主体', () => {
assert.match(sql, /一个平台系统管理员和一个 IT 测试客户管理员/)
test('统一初始化 SQL 只保留平台管理员且不创建固定客户', () => {
assert.match(sql, /最小登录基线只保留平台系统管理员/)
assert.equal((sql.match(/'platform_admin'/g) || []).length, 1)
assert.equal((sql.match(/'merchant_admin'/g) || []).length, 1)
assert.match(sql, /\(10001, 'IT_TEST', 'IT 测试客户'/)
assert.doesNotMatch(sql, /'merchant_admin'|'IT_TEST'|'IT 测试客户'/)
assert.doesNotMatch(iamSeed, /'IT_TEST'|'IT 测试客户'|\(10001,/)
const accountSeed = sql.match(/INSERT INTO auth_account \([\s\S]*?deleted = 0;/)?.[0]
assert.ok(accountSeed, 'missing auth account seed')
assert.doesNotMatch(accountSeed, /ON DUPLICATE KEY UPDATE[\s\S]*?password_hash\s*=/,
're-running the unified SQL must not reset an existing account password')
})
test('IT 测试客户初始化后具备已审核的必填资质和下单资格', () => {
for (const source of [sql, iamSeed]) {
assert.match(source, /\(2100001, 10001, 'BUSINESS_LICENSE', '91310000ITTEST0001', NULL,[\s\S]*?'APPROVED'/)
assert.match(source, /\(2100002, 10001, 'LEGAL_PERSON_ID', NULL, NULL,[\s\S]*?'APPROVED'/)
assert.match(source, /status = 'APPROVED'/)
}
test('统一初始化直接提供tenant0商户角色与权限模板', () => {
assert.match(sql, /4000100, 0, 'MERCHANT', 'MERCHANT_OWNER'/)
assert.match(sql, /5300000, 0, 'MERCHANT', 'MENU',[\s\S]*?'merchant:enterprise'/)
assert.match(sql, /5301024, 0, 'MERCHANT', 'BUTTON',[\s\S]*?'merchant:order:quick-create'/)
assert.match(sql, /5305000, 0, 'MERCHANT', 'MENU',[\s\S]*?'merchant:finance:statement'/)
assert.match(sql, /r\.id=4000100[\s\S]*?客户全局管理员 Finance 模板授权不完整/)
})
test('统一初始化 SQL 提供人工验收所需公共仓储主数据', () => {