From fce9c1c984e1d4a66c91eccd56cea63bae3c3c6b Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Fri, 15 Dec 2017 10:07:52 +0100 Subject: [PATCH] e2e web access path completed --- e2e/helpers/selectors.js | 6 ++ e2e/paths/05_edit_web_access.spec.js | 146 +++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 e2e/paths/05_edit_web_access.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 0417d1d1e..4b9562a26 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -101,5 +101,11 @@ export default { activeCheckbox: `${components.vnCheck}[label='Enabled'] > label > input`, equalizationTaxCheckboxLabel: `${components.vnCheck}[label='Is equalizated'] > label > input`, saveButton: `${components.vnSubmit}` + }, + webAccess: { + webAccessButton: `${components.vnMenuItem}[ui-sref="clientCard.webAccess"]`, + enableWebAccessCheckbox: `${components.vnCheck}[label='Enable web access'] > label > input`, + userNameInput: `${components.vnTextfield}[name="name"]`, + saveButton: `${components.vnSubmit}` } }; diff --git a/e2e/paths/05_edit_web_access.spec.js b/e2e/paths/05_edit_web_access.spec.js new file mode 100644 index 000000000..3748dbb9c --- /dev/null +++ b/e2e/paths/05_edit_web_access.spec.js @@ -0,0 +1,146 @@ +import config from '../helpers/config.js'; +import createNightmare from '../helpers/nightmare'; +import selectors from '../helpers/selectors.js'; +import {catchErrors} from '../../services/utils/jasmineHelpers'; +const nightmare = createNightmare(); +const moduleAccessViewHashURL = '#!/'; + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; + +describe('Edit web access path', () => { + describe('warm up', () => { + it('should warm up login and fixtures', done => { + nightmare + .login() + .waitForURL(moduleAccessViewHashURL) + .waitToClick(selectors.globalItems.logOutButton) + .then(() => { + done(); + }) + .catch(catchErrors(done)); + }); + }); + + it('should log in', done => { + nightmare + .login() + .waitForURL(moduleAccessViewHashURL) + .url() + .then(url => { + expect(url).toEqual(config.url + moduleAccessViewHashURL); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should make sure the language is English', done => { + nightmare + .changeLanguageToEnglish() + .then(() => { + done(); + }) + .catch(catchErrors(done)); + }); + + it('should click on the Clients button of the top bar menu', done => { + nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .url() + .then(url => { + expect(url).toEqual(config.url + '#!/clients'); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should search for the user Bruce Banner', done => { + nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countSearchResults(selectors.clientsIndex.searchResult) + .then(result => { + expect(result).toEqual(1); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should click on the search result to access to the client's web access`, done => { + nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.webAccess.webAccessButton) + .waitForURL('web-access') + .url() + .then(url => { + expect(url).toContain('web-access'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should click on the Enable web access checkbox to uncheck it`, done => { + nightmare + .waitToClick(selectors.webAccess.enableWebAccessCheckbox) + .waitToClick(selectors.fiscalData.saveButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain(`Data saved!`); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should confirm Enable web access checkbox is unchecked', done => { + nightmare + .waitForSnackbarReset() + .waitToClick(selectors.basicData.basicDataButton) + .wait(selectors.basicData.nameInput) + .waitToClick(selectors.webAccess.webAccessButton) + .wait(selectors.webAccess.enableWebAccessCheckbox) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.webAccess.enableWebAccessCheckbox) + .then(value => { + expect(value).toBeFalsy(); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should edit the User name', done => { + nightmare + .wait(selectors.webAccess.userNameInput) + .clearInput(selectors.webAccess.userNameInput) + .type(selectors.webAccess.userNameInput, 'Hulk') + .click(selectors.webAccess.saveButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toEqual('Data saved!'); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should confirm the User name have been edited', done => { + nightmare + .waitForSnackbarReset() + .click(selectors.basicData.basicDataButton) + .wait(selectors.basicData.nameInput) + .click(selectors.webAccess.webAccessButton) + .wait(selectors.webAccess.userNameInput) + .getInputValue(selectors.webAccess.userNameInput) + .then(result => { + expect(result).toEqual('Hulk'); + done(); + }) + .catch(catchErrors(done)); + }); +});