|
|
@@ -21,6 +21,8 @@ beforeEach(() => {
|
|
|
// @ts-ignore
|
|
|
router = vi.fn() as Router
|
|
|
|
|
|
+ runtimeConfig.baseUrlAdminLegacy = 'https://mydomain.com/'
|
|
|
+
|
|
|
menuBuilder = new BasicomptaMenuBuilder(
|
|
|
runtimeConfig,
|
|
|
ability,
|
|
|
@@ -37,7 +39,13 @@ describe('getMenuName', () => {
|
|
|
})
|
|
|
|
|
|
describe('build', () => {
|
|
|
+ test('without ability', () => {
|
|
|
+ ability.can = vi.fn((action: string, subject: string) => false)
|
|
|
+ expect(menuBuilder.build()).toEqual(null)
|
|
|
+ })
|
|
|
+
|
|
|
test('without admin, administratif, or financial manager access', () => {
|
|
|
+ ability.can = vi.fn((action: string, subject: string) => true)
|
|
|
accessProfile.isAdminAccess = false
|
|
|
accessProfile.isAdministratifManager = false
|
|
|
accessProfile.isFinancialManager = false
|
|
|
@@ -45,29 +53,35 @@ describe('build', () => {
|
|
|
})
|
|
|
|
|
|
test('with admin access', () => {
|
|
|
+ ability.can = vi.fn((action: string, subject: string) => true)
|
|
|
accessProfile.isAdminAccess = true
|
|
|
expect(menuBuilder.build()).toEqual({
|
|
|
label: 'basicompta_admin',
|
|
|
icon: { name: 'fas fa-suitcase' },
|
|
|
to: 'https://mydomain.com/#/basicompta',
|
|
|
type: MENU_LINK_TYPE.V1,
|
|
|
+ target: '_self',
|
|
|
active: false,
|
|
|
})
|
|
|
})
|
|
|
|
|
|
test('with administratif manager access', () => {
|
|
|
+ ability.can = vi.fn((action: string, subject: string) => true)
|
|
|
accessProfile.isAdminAccess = false
|
|
|
accessProfile.isAdministratifManager = true
|
|
|
+
|
|
|
expect(menuBuilder.build()).toEqual({
|
|
|
label: 'basicompta_admin',
|
|
|
icon: { name: 'fas fa-suitcase' },
|
|
|
to: 'https://mydomain.com/#/basicompta',
|
|
|
type: MENU_LINK_TYPE.V1,
|
|
|
+ target: '_self',
|
|
|
active: false,
|
|
|
})
|
|
|
})
|
|
|
|
|
|
test('with financial manager access', () => {
|
|
|
+ ability.can = vi.fn((action: string, subject: string) => true)
|
|
|
accessProfile.isAdminAccess = false
|
|
|
accessProfile.isAdministratifManager = false
|
|
|
accessProfile.isFinancialManager = true
|
|
|
@@ -76,6 +90,7 @@ describe('build', () => {
|
|
|
icon: { name: 'fas fa-suitcase' },
|
|
|
to: 'https://mydomain.com/#/basicompta',
|
|
|
type: MENU_LINK_TYPE.V1,
|
|
|
+ target: '_self',
|
|
|
active: false,
|
|
|
})
|
|
|
})
|