test: align full acceptance contracts

This commit is contained in:
2026-08-24 20:14:40 +08:00
parent 5edc2fc1bd
commit 005c3f54e2
10 changed files with 26 additions and 22 deletions
@@ -12,6 +12,10 @@ test('统一初始化 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 测试客户'/)
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 测试客户初始化后具备已审核的必填资质和下单资格', () => {
@@ -34,25 +38,22 @@ test('统一初始化 SQL 提供人工验收所需公共仓储主数据', () =>
assert.doesNotMatch(palletSeed, /\bstatus\b|'AVAILABLE'/)
})
test('三期权限迁移允许脚本历史版本写入的旧权限并在随后收敛', () => {
test('三期权限迁移删除退役权限并只保留 canonical 权限', () => {
for (const source of [sql, oceanBookingSchema]) {
assert.match(source, /id = 5102141[\s\S]*?ocean-booking:view/)
assert.match(source, /id = 5102147[\s\S]*?ocean-booking:cancel[\s\S]*?ocean-booking:edit/)
assert.match(source, /id = 5102148[\s\S]*?ocean-booking:change[\s\S]*?ocean-booking:delete/)
assert.match(source, /SET permission_code='platform:firstleg:ocean-booking:view',status='INACTIVE',deleted=1/)
assert.match(source, /UPDATE iam_permission SET status='INACTIVE',deleted=1 WHERE id=5102141/)
assert.match(source, /DELETE FROM iam_permission WHERE id IN \(5102143,5102144,5102145\)/)
assert.match(source, /DELETE FROM iam_permission WHERE id IN \(5102141,5102143,5102144,5102145\)/)
assert.match(source, /5102147[\s\S]*?platform:firstleg:ocean-booking:edit/)
assert.match(source, /5102148[\s\S]*?platform:firstleg:ocean-booking:delete/)
assert.doesNotMatch(source, /platform:firstleg:ocean-booking:(view|cancel|change)/)
assert.ok(
source.indexOf('DELETE FROM iam_permission WHERE id IN (5102143,5102144,5102145)') <
source.indexOf('DELETE FROM iam_permission WHERE id IN (5102141,5102143,5102144,5102145)') <
source.indexOf('(5102147,0,\'PLATFORM\',\'BUTTON\',5102140,\'platform:firstleg:ocean-booking:edit\''),
'legacy ocean-booking edit permission must be removed before assigning the code to 5102147',
)
}
for (const source of [sql, truckAppointmentSchema]) {
assert.match(source, /id = 5102151[\s\S]*?truck-appointment:view/)
assert.match(source, /SET permission_code='platform:firstleg:truck-appointment:view',status='INACTIVE',deleted=1/)
assert.match(source, /UPDATE iam_permission SET status='INACTIVE',deleted=1 WHERE id=5102151/)
assert.match(source, /DELETE FROM iam_permission WHERE id=5102151/)
assert.doesNotMatch(source, /platform:firstleg:truck-appointment:view[',]/)
}
assert.match(sql, /status='ACTIVE' AND deleted=0[\s\S]*?id BETWEEN 5102140 AND 5102149/)