diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 29176489c..343a88f5c 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -101,6 +101,18 @@ export default { email: 'vn-user-mail-forwarding vn-textfield[ng-model="data.forwardTo"]', save: 'vn-user-mail-forwarding vn-submit' }, + accountAcl: { + addAcl: 'vn-acl-index button vn-icon[icon="add"]', + firstAcl: 'vn-acl-index vn-list:nth-child(1)', + firstAclName: 'vn-acl-index vn-list:nth-child(1) > vn-item-section > h6', + deleteFirstAcl: 'vn-acl-index vn-list:nth-child(1) vn-icon-button[icon="delete"]', + role: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.principalId"]', + model: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.model"]', + property: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.property"]', + accessType: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.accessType"]', + permission: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.permission"]', + save: 'vn-acl-create vn-submit' + }, clientsIndex: { createClientButton: `vn-float-button` }, diff --git a/e2e/paths/14-account/04_acl.spec.js b/e2e/paths/14-account/04_acl.spec.js new file mode 100644 index 000000000..f745f8114 --- /dev/null +++ b/e2e/paths/14-account/04_acl.spec.js @@ -0,0 +1,92 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +fdescribe('Account ACL path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('sysadmin', 'account'); + await page.accessToSection('account.acl'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should go to create new acl', async() => { + await page.waitToClick(selectors.accountAcl.addAcl); + await page.waitForState('account.acl.create'); + }); + + it('should create new acl', async() => { + await page.autocompleteSearch(selectors.accountAcl.role, 'trainee'); + await page.autocompleteSearch(selectors.accountAcl.model, 'ACL'); + await page.autocompleteSearch(selectors.accountAcl.accessType, 'WRITE'); + await page.autocompleteSearch(selectors.accountAcl.permission, 'DENY'); + await page.waitToClick(selectors.accountAcl.save); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should navigate to edit', async() => { + await page.doSearch(); + await page.waitToClick(selectors.accountAcl.firstAcl); + await page.waitForState('account.acl.edit'); + }); + + it('should edit the acl', async() => { + await page.autocompleteSearch(selectors.accountAcl.model, 'AccessToken'); + await page.autocompleteSearch(selectors.accountAcl.accessType, 'READ'); + await page.waitToClick(selectors.accountAcl.save); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should delete the first result', async() => { + const firstResult = await page.waitToGetProperty(selectors.accountAcl.firstAclName, 'value'); + await page.waitToClick(selectors.accountAcl.deleteFirstAcl); + await page.reloadSection('account.acl'); + const newFirstResult = await page.waitToGetProperty(selectors.accountAcl.firstAclName, 'value'); + + expect(firstResult).not.toEqual(newFirstResult); + }); + /* + it('should check the role description was edited successfully', async() => { + const result = await page.waitToGetProperty(selectors.accountRoleBasicData.description, 'value'); + + expect(result).toContain('psykers'); + }); + + it('should navigate to the subroles section', async() => { + await page.accessToSection('account.role.card.subroles'); + }); + + it('should asign a subrole', async() => { + await page.waitToClick(selectors.accountSubroles.addSubrole); + await page.autocompleteSearch(selectors.accountSubroles.role, 'teamManager'); + await page.waitToClick(selectors.accountSubroles.save); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Role added!'); + }); + + it('should reload the subroles section and check a role was added', async() => { + await page.reloadSection('account.role.card.subroles'); + const subrolesCount = await page.countElement(selectors.accountSubroles.anyResult); + + expect(subrolesCount).toEqual(1); + }); + + it('should access the employee roles inheritance then check the roles listed are the expected ones', async() => { + await page.accessToSearchResult('employee'); + await page.accessToSection('account.role.card.inherited'); + const rolesCount = await page.countElement(selectors.accountRoleInheritance.anyResult); + + expect(rolesCount).toEqual(6); + });*/ +});