This commit is contained in:
2026-08-04 10:31:53 +08:00
parent 198101c42c
commit 5c25806081
10 changed files with 100 additions and 31 deletions
@@ -6,6 +6,7 @@ const source = readFileSync(new URL('./merchantIam.ts', import.meta.url), 'utf8'
const storeSource = readFileSync(new URL('../store/tenantAdministration.ts', import.meta.url), 'utf8')
const contractsSource = readFileSync(new URL('../contracts.ts', import.meta.url), 'utf8')
const authSource = readFileSync(new URL('../../auth/store/auth.ts', import.meta.url), 'utf8')
const permissionsViewSource = readFileSync(new URL('../views/PermissionsView.vue', import.meta.url), 'utf8')
test('declares the documented merchant role and member endpoints', () => {
assert.match(source, /url: '\/merchant\/v1\/iam\/roles'/)
@@ -66,3 +67,12 @@ test('shares the merchant permission map and preserves resources not rendered by
assert.match(storeSource, /const nextPermissionIds = \[\.\.\.new Set\(\[\.\.\.preservedPermissionIds, \.\.\.selectedPermissionIds\]\)\]/)
assert.match(storeSource, /await replaceMerchantRolePermissions\(id, nextPermissionIds\)/)
})
test('keeps client baseline permissions selected when server resources do not define them', () => {
assert.match(contractsSource, /REQUIRED_TENANT_PERMISSION_CODES = \['account:profile:view', 'dashboard:view'\]/)
assert.match(storeSource, /\.\.\.REQUIRED_TENANT_PERMISSION_CODES, \.\.\.permissionCodes/)
assert.match(storeSource, /role\.permissionCodes = effectivePermissionCodes/)
assert.match(permissionsViewSource, /group\.items\.every\(\(item\) => isRequiredPermission\(item\.code\)\)/)
assert.match(permissionsViewSource, /:disabled="isRequiredPermission\(item\.code\)"/)
assert.doesNotMatch(permissionsViewSource, /selectedCodes\.value\.unshift\('account:profile:view'\)/)
})