|
|
@@ -6,6 +6,22 @@ import AbilityBuilder from '~/services/rights/abilityBuilder'
|
|
|
import { ABILITIES } from '~/types/enum/enums'
|
|
|
import type OrganizationProfile from '~/models/Organization/OrganizationProfile'
|
|
|
|
|
|
+// Mock the abilities config to return only test data
|
|
|
+vi.mock('~/config/abilities/config-precompiled', () => {
|
|
|
+ return {
|
|
|
+ default: {
|
|
|
+ 'subject1': {
|
|
|
+ action: 'display',
|
|
|
+ conditions: [{ function: 'accessHasAnyProfile', parameters: ['guardian'] }]
|
|
|
+ },
|
|
|
+ 'subject2': {
|
|
|
+ action: 'display',
|
|
|
+ conditions: [{ function: 'organizationIsSchool' }]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
let ability: MongoAbility
|
|
|
let accessProfile: AccessProfile
|
|
|
let organizationProfile: OrganizationProfile
|
|
|
@@ -109,8 +125,8 @@ describe('buildAbilitiesFromConfig', () => {
|
|
|
abilityBuilder.hasConfigAbility = vi.fn(() => true)
|
|
|
|
|
|
expect(abilityBuilder.buildAbilitiesFromConfig()).toEqual([
|
|
|
- { action: 'read', subject: 'subject1', inverted: false },
|
|
|
- { action: 'read', subject: 'subject2', inverted: false },
|
|
|
+ { action: 'display', subject: 'subject1', inverted: false },
|
|
|
+ { action: 'display', subject: 'subject2', inverted: false },
|
|
|
])
|
|
|
})
|
|
|
})
|