|
|
@@ -121,9 +121,7 @@ describe('buildAbilitiesFromConfig', () => {
|
|
|
describe('hasConfigAbility', () => {
|
|
|
beforeEach(() => {
|
|
|
accessProfile.isGuardian = true
|
|
|
- // @ts-ignore
|
|
|
organizationProfile.isSchool = true
|
|
|
- // @ts-ignore
|
|
|
organizationProfile.isCmf = false
|
|
|
})
|
|
|
test('fulfill all conditions', () => {
|
|
|
@@ -158,7 +156,7 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'accessHasAllRoleAbilities',
|
|
|
parameters: [
|
|
|
@@ -169,7 +167,7 @@ describe('execAndValidateCondition', () => {
|
|
|
).toBeTruthy()
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'accessHasAllRoleAbilities',
|
|
|
parameters: [
|
|
|
@@ -186,7 +184,7 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'accessHasAnyRoleAbility',
|
|
|
parameters: [
|
|
|
@@ -197,7 +195,7 @@ describe('execAndValidateCondition', () => {
|
|
|
).toBeTruthy()
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'accessHasAnyRoleAbility',
|
|
|
parameters: [{ action: ABILITIES.READ, subject: 'subject2' }],
|
|
|
@@ -211,7 +209,7 @@ describe('execAndValidateCondition', () => {
|
|
|
accessProfile.isPayer = true
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'accessHasAnyProfile',
|
|
|
parameters: ['guardian', 'payer'],
|
|
|
@@ -219,7 +217,7 @@ describe('execAndValidateCondition', () => {
|
|
|
).toBeTruthy()
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'accessHasAnyProfile',
|
|
|
parameters: ['guardian', 'caMember'],
|
|
|
@@ -227,7 +225,7 @@ describe('execAndValidateCondition', () => {
|
|
|
).toBeTruthy()
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'accessHasAnyProfile',
|
|
|
parameters: ['caMember'],
|
|
|
@@ -236,13 +234,13 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('organizationHasAllModules', () => {
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error for testing purposes
|
|
|
organizationProfile.hasModule = vi.fn(
|
|
|
(module: string) => module === 'module1' || module === 'module2',
|
|
|
)
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasAllModules',
|
|
|
parameters: ['module1', 'module2'],
|
|
|
@@ -250,7 +248,7 @@ describe('execAndValidateCondition', () => {
|
|
|
).toBeTruthy()
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasAllModules',
|
|
|
parameters: ['module1', 'module3'],
|
|
|
@@ -258,7 +256,7 @@ describe('execAndValidateCondition', () => {
|
|
|
).toBeFalsy()
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasAllModules',
|
|
|
parameters: ['module3'],
|
|
|
@@ -267,13 +265,13 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('organizationHasAnyModule', () => {
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.hasModule = vi.fn(
|
|
|
+ // @ts-expect-error accessing non-existent property for testing purposes
|
|
|
+ organizationProfile.hasModule = vi.fn(
|
|
|
(module: string) => module === 'module1' || module === 'module2',
|
|
|
)
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasAnyModule',
|
|
|
parameters: ['module1', 'module2'],
|
|
|
@@ -281,7 +279,7 @@ describe('execAndValidateCondition', () => {
|
|
|
).toBeTruthy()
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasAnyModule',
|
|
|
parameters: ['module1', 'module3'],
|
|
|
@@ -289,7 +287,7 @@ describe('execAndValidateCondition', () => {
|
|
|
).toBeTruthy()
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasAnyModule',
|
|
|
parameters: ['module3'],
|
|
|
@@ -298,19 +296,17 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('organizationHasAnyModule', () => {
|
|
|
- // @ts-ignore
|
|
|
accessProfile.isAdminAccount = true
|
|
|
- // @ts-ignore
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'accessIsAdminAccount',
|
|
|
}),
|
|
|
).toBeTruthy()
|
|
|
|
|
|
- // @ts-ignore
|
|
|
accessProfile.isAdminAccount = false
|
|
|
- // @ts-ignore
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'accessIsAdminAccount',
|
|
|
}),
|
|
|
@@ -318,19 +314,17 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('organizationIsSchool', () => {
|
|
|
- // @ts-ignore
|
|
|
organizationProfile.isSchool = true
|
|
|
- // @ts-ignore
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsSchool',
|
|
|
}),
|
|
|
).toBeTruthy()
|
|
|
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.isSchool = false
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.isSchool = false
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsSchool',
|
|
|
}),
|
|
|
@@ -338,19 +332,17 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('organizationIsArtist', () => {
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.isArtist = true
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.isArtist = true
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsArtist',
|
|
|
}),
|
|
|
).toBeTruthy()
|
|
|
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.isArtist = false
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.isArtist = false
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsArtist',
|
|
|
}),
|
|
|
@@ -358,19 +350,17 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('organizationIsManagerProduct', () => {
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.isManagerProduct = true
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.isManagerProduct = true
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsManagerProduct',
|
|
|
}),
|
|
|
).toBeTruthy()
|
|
|
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.isManagerProduct = false
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.isManagerProduct = false
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsManagerProduct',
|
|
|
}),
|
|
|
@@ -378,19 +368,17 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('organizationHasChildren', () => {
|
|
|
- // @ts-ignore
|
|
|
organizationProfile.hasChildren = true
|
|
|
- // @ts-ignore
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasChildren',
|
|
|
}),
|
|
|
).toBeTruthy()
|
|
|
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.hasChildren = false
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.hasChildren = false
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasChildren',
|
|
|
}),
|
|
|
@@ -398,19 +386,17 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('organizationIsAssociation', () => {
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.isAssociation = true
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.isAssociation = true
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsAssociation',
|
|
|
}),
|
|
|
).toBeTruthy()
|
|
|
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.isAssociation = false
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.isAssociation = false
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsAssociation',
|
|
|
}),
|
|
|
@@ -418,19 +404,17 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('organizationIsShowAdherentList', () => {
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.isShowAdherentList = true
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.isShowAdherentList = true
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsShowAdherentList',
|
|
|
}),
|
|
|
).toBeTruthy()
|
|
|
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.isShowAdherentList = false
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.isShowAdherentList = false
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsShowAdherentList',
|
|
|
}),
|
|
|
@@ -438,19 +422,17 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('organizationIsCmf', () => {
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.isCmf = true
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.isCmf = true
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsCmf',
|
|
|
}),
|
|
|
).toBeTruthy()
|
|
|
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.isCmf = false
|
|
|
- // @ts-ignore
|
|
|
+ organizationProfile.isCmf = false
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationIsCmf',
|
|
|
}),
|
|
|
@@ -458,19 +440,19 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('organizationHasWebsite', () => {
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error testing with intentionally wrong type
|
|
|
organizationProfile.getWebsite = true
|
|
|
- // @ts-ignore
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasWebsite',
|
|
|
}),
|
|
|
).toBeTruthy()
|
|
|
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error testing with intentionally wrong type
|
|
|
organizationProfile.getWebsite = false
|
|
|
- // @ts-ignore
|
|
|
expect(
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasWebsite',
|
|
|
}),
|
|
|
@@ -478,11 +460,11 @@ describe('execAndValidateCondition', () => {
|
|
|
})
|
|
|
|
|
|
test('with expected result', () => {
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error testing with intentionally wrong type
|
|
|
organizationProfile.getWebsite = true
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasWebsite',
|
|
|
expectedResult: true,
|
|
|
@@ -490,9 +472,10 @@ describe('execAndValidateCondition', () => {
|
|
|
).toBeTruthy()
|
|
|
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
abilityBuilder.execAndValidateCondition({
|
|
|
function: 'organizationHasWebsite',
|
|
|
+ // @ts-expect-error testing with intentionally wrong type
|
|
|
expectedResult: 'abc',
|
|
|
}),
|
|
|
).toBeFalsy()
|
|
|
@@ -500,7 +483,7 @@ describe('execAndValidateCondition', () => {
|
|
|
|
|
|
test('invalid function', () => {
|
|
|
expect(
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-expect-error accessing protected method for testing purposes
|
|
|
() => abilityBuilder.execAndValidateCondition({ function: 'invalid' }),
|
|
|
).toThrowError('unknown condition function : invalid')
|
|
|
})
|
|
|
@@ -710,8 +693,7 @@ describe('hasAllProfiles', () => {
|
|
|
|
|
|
describe('hasRole', () => {
|
|
|
beforeEach(() => {
|
|
|
- // @ts-ignore
|
|
|
- accessProfile.hasRole = vi.fn((role: string) => role === 'foo')
|
|
|
+ accessProfile.hasRole = vi.fn((role: string) => role === 'foo')
|
|
|
})
|
|
|
|
|
|
test('has role', () => {
|
|
|
@@ -724,8 +706,7 @@ describe('hasRole', () => {
|
|
|
|
|
|
describe('hasAnyRole', () => {
|
|
|
beforeEach(() => {
|
|
|
- // @ts-ignore
|
|
|
- accessProfile.hasRole = vi.fn(
|
|
|
+ accessProfile.hasRole = vi.fn(
|
|
|
(role: string) => role === 'role1' || role === 'role2',
|
|
|
)
|
|
|
})
|
|
|
@@ -745,8 +726,7 @@ describe('hasAnyRole', () => {
|
|
|
|
|
|
describe('hasAllRoles', () => {
|
|
|
beforeEach(() => {
|
|
|
- // @ts-ignore
|
|
|
- accessProfile.hasRole = vi.fn(
|
|
|
+ accessProfile.hasRole = vi.fn(
|
|
|
(role: string) => role === 'role1' || role === 'role2',
|
|
|
)
|
|
|
})
|
|
|
@@ -766,8 +746,8 @@ describe('hasAllRoles', () => {
|
|
|
|
|
|
describe('hasModule', () => {
|
|
|
beforeEach(() => {
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.hasModule = vi.fn((module: string) => module === 'foo')
|
|
|
+ // @ts-expect-error accessing non-existent property for testing purposes
|
|
|
+ organizationProfile.hasModule = vi.fn((module: string) => module === 'foo')
|
|
|
})
|
|
|
|
|
|
test('has module', () => {
|
|
|
@@ -780,8 +760,8 @@ describe('hasModule', () => {
|
|
|
|
|
|
describe('hasAnyModule', () => {
|
|
|
beforeEach(() => {
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.hasModule = vi.fn(
|
|
|
+ // @ts-expect-error accessing non-existent property for testing purposes
|
|
|
+ organizationProfile.hasModule = vi.fn(
|
|
|
(Module: string) => Module === 'Module1' || Module === 'Module2',
|
|
|
)
|
|
|
})
|
|
|
@@ -801,8 +781,8 @@ describe('hasAnyModule', () => {
|
|
|
|
|
|
describe('hasAllModules', () => {
|
|
|
beforeEach(() => {
|
|
|
- // @ts-ignore
|
|
|
- organizationProfile.hasModule = vi.fn(
|
|
|
+ // @ts-expect-error accessing non-existent property for testing purposes
|
|
|
+ organizationProfile.hasModule = vi.fn(
|
|
|
(Module: string) => Module === 'Module1' || Module === 'Module2',
|
|
|
)
|
|
|
})
|