diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 931d726543..cc1419da59 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -28,6 +28,39 @@ export default { firstModulePinIcon: 'vn-home a:nth-child(1) vn-icon[icon="push_pin"]', firstModuleRemovePinIcon: 'vn-home a:nth-child(1) vn-icon[icon="remove_circle"]' }, + accountIndex: { + addAccount: 'vn-user-index button vn-icon[icon="add"]', + newName: 'vn-user-create vn-textfield[ng-model="$ctrl.user.name"]', + newNickname: 'vn-user-create vn-textfield[ng-model="$ctrl.user.nickname"]', + newEmail: 'vn-user-create vn-textfield[ng-model="$ctrl.user.email"]', + newRole: 'vn-user-create vn-autocomplete[ng-model="$ctrl.user.roleFk"]', + newPassword: 'vn-user-create vn-textfield[ng-model="$ctrl.user.password"]', + createAccountButton: 'vn-user-create button[type="submit"]', + }, + accountBasicData: { + name: 'vn-user-basic-data vn-textfield[ng-model="$ctrl.user.name"]', + nickname: 'vn-user-basic-data vn-textfield[ng-model="$ctrl.user.nickname"]', + email: 'vn-user-basic-data vn-textfield[ng-model="$ctrl.user.email"]', + language: 'vn-user-basic-data vn-autocomplete[ng-model="$ctrl.user.lang"]', + save: 'vn-user-basic-data button[type="submit"]' + }, + accountRoles: { + anyResult: 'vn-user-roles > vn-data-viewer vn-list > a' + }, + accountAliasIndex: { + addAlias: 'vn-alias-index button vn-icon[icon="add"]', + newName: 'vn-alias-create vn-textfield[ng-model="$ctrl.alias.alias"]', + newDescription: 'vn-alias-create vn-textfield[ng-model="$ctrl.alias.description"]', + createAliasButton: 'vn-alias-create button[type="submit"]', + }, + accountAliasBasicData: { + name: 'vn-alias-basic-data vn-textfield[ng-model="$ctrl.alias.alias"]', + description: 'vn-alias-basic-data vn-textfield[ng-model="$ctrl.alias.description"]', + save: 'vn-alias-basic-data button[type="submit"]' + }, + accountAliasUsers: { + anyResult: 'vn-alias-users > vn-data-viewer vn-tr' + }, clientsIndex: { createClientButton: `vn-float-button` }, diff --git a/e2e/paths/14-account/01_create_and_basic_data.spec.js b/e2e/paths/14-account/01_create_and_basic_data.spec.js new file mode 100644 index 0000000000..a33a4d1ee6 --- /dev/null +++ b/e2e/paths/14-account/01_create_and_basic_data.spec.js @@ -0,0 +1,81 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Account create and basic data path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('developer', 'account'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should open the new account form by clicking the add button', async() => { + await page.waitToClick(selectors.accountIndex.addAccount); + await page.waitForState('account.create'); + }); + + it('should fill the form and then save it by clicking the create button', async() => { + await page.write(selectors.accountIndex.newName, 'Remy'); + await page.write(selectors.accountIndex.newNickname, 'Gambit'); + await page.write(selectors.accountIndex.newEmail, 'RemyEtienneLeBeau@verdnatura.es'); + await page.autocompleteSearch(selectors.accountIndex.newRole, 'Trainee'); + await page.write(selectors.accountIndex.newPassword, 'cestlavie'); + await page.waitToClick(selectors.accountIndex.createAccountButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should redirect the user to the created account basic data section', async() => { + await page.waitForState('account.card.basicData'); + }); + + it('should edit the basic data', async() => { + await page.overwrite(selectors.accountBasicData.name, 'Anna'); + await page.overwrite(selectors.accountBasicData.nickname, 'Rogue'); + await page.overwrite(selectors.accountBasicData.email, 'AnnaMarieLeBeau@verdnatura.es'); + await page.autocompleteSearch(selectors.accountBasicData.language, 'english'); + await page.waitToClick(selectors.accountBasicData.save); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should reload the section and check the name was edited successfully', async() => { + await page.reloadSection('account.card.basicData'); + const result = await page.waitToGetProperty(selectors.accountBasicData.name, 'value'); + + expect(result).toEqual('Anna'); + }); + + it('should check the nickname was edited successfully', async() => { + const result = await page.waitToGetProperty(selectors.accountBasicData.nickname, 'value'); + + expect(result).toEqual('Rogue'); + }); + + it('should check the email was edited successfully', async() => { + const result = await page.waitToGetProperty(selectors.accountBasicData.email, 'value'); + + expect(result).toEqual('AnnaMarieLeBeau@verdnatura.es'); + }); + + it('should check the language was edited successfully', async() => { + const result = await page.waitToGetProperty(selectors.accountBasicData.language, 'value'); + + expect(result).toEqual('English'); + }); + + it('should navigate to the roles section to check the roles are correct', async() => { + await page.accessToSection('account.card.roles'); + const rolesCount = await page.countElement(selectors.accountRoles.anyResult); + + expect(rolesCount).toEqual(3); + }); +}); diff --git a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js new file mode 100644 index 0000000000..d19e2993f4 --- /dev/null +++ b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js @@ -0,0 +1,66 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Account Alias create and basic data path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('developer', 'account'); + await page.accessToSection('account.alias'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should open the new account alias form by clicking the add button', async() => { + await page.waitToClick(selectors.accountAliasIndex.addAlias); + await page.waitForState('account.alias.create'); + }); + + it('should fill the form and then save it by clicking the create alias button', async() => { + await page.write(selectors.accountAliasIndex.newName, 'Boring alias'); + await page.write(selectors.accountAliasIndex.newDescription, 'Boring description'); + await page.waitToClick(selectors.accountAliasIndex.createAliasButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should redirect the user to the created account alias basic data section', async() => { + await page.waitForState('account.alias.card.basicData'); + }); + + it('should edit alias the basic data', async() => { + await page.overwrite(selectors.accountAliasBasicData.name, 'Psykers'); + await page.overwrite(selectors.accountAliasBasicData.description, 'Email group for psykers'); + await page.waitToClick(selectors.accountAliasBasicData.save); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should reload the basicData section and check the name was edited successfully', async() => { + await page.reloadSection('account.alias.card.basicData'); + const result = await page.waitToGetProperty(selectors.accountAliasBasicData.name, 'value'); + + expect(result).toEqual('Psykers'); + }); + + it('should check the alias description was edited successfully', async() => { + const result = await page.waitToGetProperty(selectors.accountAliasBasicData.description, 'value'); + + expect(result).toContain('psykers'); + }); + + it('should search for the IT alias group then access to the users section then check the role listed is the expected one', async() => { + await page.accessToSearchResult('IT'); + await page.accessToSection('account.alias.card.users'); + const rolesCount = await page.countElement(selectors.accountAliasUsers.anyResult); + + expect(rolesCount).toEqual(1); + }); +});