From 8f307b28b6c24c25d00b147dc51bd9396b626731 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Tue, 20 Nov 2018 14:22:00 +0100 Subject: [PATCH] e2e refactor --- .../client-module/01_create_client.spec.js | 192 +++++++------ .../client-module/02_edit_basic_data.spec.js | 4 +- .../client-module/05_add_address.spec.js | 214 +++++++-------- .../06_add_address_notes.spec.js | 2 +- .../client-module/07_edit_web_access.spec.js | 120 ++++---- e2e/paths/client-module/08_add_notes.spec.js | 106 ++++--- e2e/paths/client-module/09_add_credit.spec.js | 110 ++++---- e2e/paths/client-module/10_add_greuge.spec.js | 130 +++++---- e2e/paths/client-module/11_mandate.spec.js | 84 +++--- .../12_lock_of_verified_data.spec.js | 10 +- e2e/paths/client-module/13_log.spec.js | 2 +- e2e/paths/client-module/14_risk.spec.js | 2 +- e2e/paths/item-module/01_item_summary.spec.js | 35 ++- .../02_edit_item_basic_data.spec.js | 203 +++++++------- .../item-module/03_edit_item_tax.spec.js | 2 +- .../item-module/04_create_item_tags.spec.js | 2 +- .../item-module/05_create_item_niche.spec.js | 2 +- .../06_create_item_botanical.spec.js | 164 +++++------ .../07_create_item_barcode.spec.js | 80 +++--- .../08_item_create_and_clone.spec.js | 258 +++++++++--------- .../item-module/09_regularize_item.spec.js | 2 +- 21 files changed, 837 insertions(+), 887 deletions(-) diff --git a/e2e/paths/client-module/01_create_client.spec.js b/e2e/paths/client-module/01_create_client.spec.js index 5d0b0c32d..9d3599313 100644 --- a/e2e/paths/client-module/01_create_client.spec.js +++ b/e2e/paths/client-module/01_create_client.spec.js @@ -1,125 +1,123 @@ import selectors from '../../helpers/selectors'; import createNightmare from '../../helpers/nightmare'; -describe('Client', () => { - describe('create path', () => { - const nightmare = createNightmare(); +describe('Client create path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare - .waitForLogin('employee'); - }); + beforeAll(() => { + nightmare + .waitForLogin('employee'); + }); - it('should access to the clients index by clicking the clients button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.clientsSectionButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); + it('should access to the clients index by clicking the clients button', async () => { + const url = await nightmare + .click(selectors.moduleAccessView.clientsSectionButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/index'); - }); + expect(url.hash).toEqual('#!/client/index'); + }); - it(`should search for the user Carol Danvers to confirm it isn't created yet`, async () => { - const result = await nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 0) - .countElement(selectors.clientsIndex.searchResult); + it(`should search for the user Carol Danvers to confirm it isn't created yet`, async () => { + const result = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 0) + .countElement(selectors.clientsIndex.searchResult); - expect(result).toEqual(0); - }); + expect(result).toEqual(0); + }); - it('should access to the create client view by clicking the create-client floating button', async () => { - const url = await nightmare - .click(selectors.clientsIndex.createClientButton) - .wait(selectors.createClientView.createButton) - .parsedUrl(); + it('should access to the create client view by clicking the create-client floating button', async () => { + const url = await nightmare + .click(selectors.clientsIndex.createClientButton) + .wait(selectors.createClientView.createButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/create'); - }); + expect(url.hash).toEqual('#!/client/create'); + }); - it('should return to the client index by clicking the cancel button', async () => { - const url = await nightmare - .click(selectors.createClientView.cancelButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); + it('should return to the client index by clicking the cancel button', async () => { + const url = await nightmare + .click(selectors.createClientView.cancelButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/index'); - }); + expect(url.hash).toEqual('#!/client/index'); + }); - it('should now access to the create client view by clicking the create-client floating button', async () => { - const url = await nightmare - .click(selectors.clientsIndex.createClientButton) - .wait(selectors.createClientView.createButton) - .parsedUrl(); + it('should now access to the create client view by clicking the create-client floating button', async () => { + const url = await nightmare + .click(selectors.clientsIndex.createClientButton) + .wait(selectors.createClientView.createButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/create'); - }); + expect(url.hash).toEqual('#!/client/create'); + }); - it('should receive an error when clicking the create button having all the form fields empty', async () => { - const result = await nightmare - .click(selectors.createClientView.createButton) - .waitForLastSnackbar(); + it('should receive an error when clicking the create button having all the form fields empty', async () => { + const result = await nightmare + .click(selectors.createClientView.createButton) + .waitForLastSnackbar(); - expect(result).toEqual('Some fields are invalid'); - }); + expect(result).toEqual('Some fields are invalid'); + }); - it('should receive an error when clicking the create button having name and Business name fields empty', async () => { - const result = await nightmare - .type(selectors.createClientView.taxNumber, '74451390E') - .type(selectors.createClientView.userName, 'CaptainMarvel') - .type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es') - .waitToClick(selectors.createClientView.salesPersonInput) - .waitToClick(selectors.createClientView.salesBruceBannerOption) - .click(selectors.createClientView.createButton) - .waitForLastSnackbar(); + it('should receive an error when clicking the create button having name and Business name fields empty', async () => { + const result = await nightmare + .type(selectors.createClientView.taxNumber, '74451390E') + .type(selectors.createClientView.userName, 'CaptainMarvel') + .type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es') + .waitToClick(selectors.createClientView.salesPersonInput) + .waitToClick(selectors.createClientView.salesBruceBannerOption) + .click(selectors.createClientView.createButton) + .waitForLastSnackbar(); - expect(result).toEqual('Some fields are invalid'); - }); + expect(result).toEqual('Some fields are invalid'); + }); - it(`should attempt to create a new user with all it's data but wrong email`, async () => { - const result = await nightmare - .type(selectors.createClientView.name, 'Carol Danvers') - .type(selectors.createClientView.socialName, 'AVG tax') - .clearInput(selectors.createClientView.email) - .type(selectors.createClientView.email, 'incorrect email format') - .click(selectors.createClientView.createButton) - .waitForLastSnackbar(); + it(`should attempt to create a new user with all it's data but wrong email`, async () => { + const result = await nightmare + .type(selectors.createClientView.name, 'Carol Danvers') + .type(selectors.createClientView.socialName, 'AVG tax') + .clearInput(selectors.createClientView.email) + .type(selectors.createClientView.email, 'incorrect email format') + .click(selectors.createClientView.createButton) + .waitForLastSnackbar(); - expect(result).toEqual('Some fields are invalid'); - }); + expect(result).toEqual('Some fields are invalid'); + }); - it(`should create a new user with all correct data`, async () => { - const result = await nightmare - .clearInput(selectors.createClientView.email) - .type(selectors.createClientView.email, 'caroldanvers@verdnatura.es') - .click(selectors.createClientView.createButton) - .waitForLastSnackbar(); + it(`should create a new user with all correct data`, async () => { + const result = await nightmare + .clearInput(selectors.createClientView.email) + .type(selectors.createClientView.email, 'caroldanvers@verdnatura.es') + .click(selectors.createClientView.createButton) + .waitForLastSnackbar(); - expect(result).toEqual('Data saved!'); - }); + expect(result).toEqual('Data saved!'); + }); - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); + it('should click on the Clients button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/index'); - }); + expect(url.hash).toEqual('#!/client/index'); + }); - it(`should search for the user Carol Danvers to confirm it exists`, async () => { - const result = await nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); + it(`should search for the user Carol Danvers to confirm it exists`, async () => { + const result = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countElement(selectors.clientsIndex.searchResult); - expect(result).toEqual(1); - }); + expect(result).toEqual(1); }); }); diff --git a/e2e/paths/client-module/02_edit_basic_data.spec.js b/e2e/paths/client-module/02_edit_basic_data.spec.js index 6ead9f6ee..16d65ec90 100644 --- a/e2e/paths/client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/client-module/02_edit_basic_data.spec.js @@ -5,7 +5,7 @@ describe('Client Edit basicData path', () => { const nightmare = createNightmare(); describe('as employee', () => { beforeAll(() => { - return nightmare + nightmare .waitForLogin('employee'); }); @@ -121,7 +121,7 @@ describe('Client Edit basicData path', () => { describe('as salesAssistanrt', () => { beforeAll(() => { - return nightmare + nightmare .waitToClick(selectors.globalItems.logOutButton) .waitForLogin('salesAssistant'); }); diff --git a/e2e/paths/client-module/05_add_address.spec.js b/e2e/paths/client-module/05_add_address.spec.js index db4e46aac..c4b7eab39 100644 --- a/e2e/paths/client-module/05_add_address.spec.js +++ b/e2e/paths/client-module/05_add_address.spec.js @@ -1,138 +1,136 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Client', () => { - describe('Add address path', () => { - const nightmare = createNightmare(); +describe('Client Add address path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare - .waitForLogin('employee'); - }); + beforeAll(() => { + nightmare + .waitForLogin('employee'); + }); - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); + it('should click on the Clients button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/index'); - }); + expect(url.hash).toEqual('#!/client/index'); + }); - it('should search for the user Bruce Banner', async () => { - const resultCount = await nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); + it('should search for the user Bruce Banner', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countElement(selectors.clientsIndex.searchResult); - expect(resultCount).toEqual(1); - }); + expect(resultCount).toEqual(1); + }); - it(`should click on the search result to access to the client addresses`, async () => { - const url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientAddresses.addressesButton) - .waitForURL('address/index') - .url(); + it(`should click on the search result to access to the client addresses`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientAddresses.addressesButton) + .waitForURL('address/index') + .url(); - expect(url).toContain('address/index'); - }); + expect(url).toContain('address/index'); + }); - it(`should click on the add new address button to access to the new address form`, async () => { - const url =await nightmare - .waitToClick(selectors.clientAddresses.createAddress) - .waitForURL('address/create') - .url(); + it(`should click on the add new address button to access to the new address form`, async () => { + const url = await nightmare + .waitToClick(selectors.clientAddresses.createAddress) + .waitForURL('address/create') + .url(); - expect(url).toContain('address/create'); - }); + expect(url).toContain('address/create'); + }); - it(`should return to the addreses section by clicking the cancel button`, async () => { - const url = await nightmare - .waitToClick(selectors.clientAddresses.cancelButton) - .waitForURL('address/index') - .url(); + it(`should return to the addreses section by clicking the cancel button`, async () => { + const url = await nightmare + .waitToClick(selectors.clientAddresses.cancelButton) + .waitForURL('address/index') + .url(); - expect(url).toContain('address/index'); - }); + expect(url).toContain('address/index'); + }); - it(`should now click on the add new address button to access to the new address form`, async () => { - const url = await nightmare - .waitToClick(selectors.clientAddresses.createAddress) - .waitForURL('address/create') - .url(); + it(`should now click on the add new address button to access to the new address form`, async () => { + const url = await nightmare + .waitToClick(selectors.clientAddresses.createAddress) + .waitForURL('address/create') + .url(); - expect(url).toContain('address/create'); - }); + expect(url).toContain('address/create'); + }); - it('should receive an error after clicking save button as consignee, street and town fields are empty', async () => { - const result = await nightmare - .waitToClick(selectors.clientAddresses.defaultCheckboxInput) - .clearInput(selectors.clientAddresses.streetAddressInput) - .type(selectors.clientAddresses.postcodeInput, '10022') - .waitToClick(selectors.clientAddresses.provinceInput) - .waitToClick(selectors.clientAddresses.provinceSecondOption) - .waitToClick(selectors.clientAddresses.agencyInput) - .waitToClick(selectors.clientAddresses.agenctySecondOption) - .type(selectors.clientAddresses.phoneInput, '999887744') - .type(selectors.clientAddresses.mobileInput, '999887744') - .waitToClick(selectors.clientFiscalData.saveButton) - .waitForLastSnackbar(); + it('should receive an error after clicking save button as consignee, street and town fields are empty', async () => { + const result = await nightmare + .waitToClick(selectors.clientAddresses.defaultCheckboxInput) + .clearInput(selectors.clientAddresses.streetAddressInput) + .type(selectors.clientAddresses.postcodeInput, '10022') + .waitToClick(selectors.clientAddresses.provinceInput) + .waitToClick(selectors.clientAddresses.provinceSecondOption) + .waitToClick(selectors.clientAddresses.agencyInput) + .waitToClick(selectors.clientAddresses.agenctySecondOption) + .type(selectors.clientAddresses.phoneInput, '999887744') + .type(selectors.clientAddresses.mobileInput, '999887744') + .waitToClick(selectors.clientFiscalData.saveButton) + .waitForLastSnackbar(); - expect(result).toEqual('Some fields are invalid'); - }); + expect(result).toEqual('Some fields are invalid'); + }); - it(`should create a new address with all it's data`, async () => { - const result = await nightmare - .type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner') - .type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York') - .type(selectors.clientAddresses.cityInput, 'New York') - .click(selectors.clientAddresses.saveButton) - .waitForLastSnackbar(); + it(`should create a new address with all it's data`, async () => { + const result = await nightmare + .type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner') + .type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York') + .type(selectors.clientAddresses.cityInput, 'New York') + .click(selectors.clientAddresses.saveButton) + .waitForLastSnackbar(); - expect(result).toEqual('Data saved!'); - }); + expect(result).toEqual('Data saved!'); + }); - it(`should click on the addresses button confirm the new address exists and it's the default one`, async () => { - const result = await nightmare - .waitToClick(selectors.clientAddresses.addressesButton) - .wait(selectors.clientAddresses.defaultAddress) - .getInnerText(selectors.clientAddresses.defaultAddress); + it(`should click on the addresses button confirm the new address exists and it's the default one`, async () => { + const result = await nightmare + .waitToClick(selectors.clientAddresses.addressesButton) + .wait(selectors.clientAddresses.defaultAddress) + .getInnerText(selectors.clientAddresses.defaultAddress); - expect(result).toContain('320 Park Avenue New York'); - }); + expect(result).toContain('320 Park Avenue New York'); + }); - it(`should click on the make default icon of the second address then confirm it is the default one now`, async () => { - const result = await nightmare - .waitToClick(selectors.clientAddresses.secondMakeDefaultStar) - .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') - .getInnerText(selectors.clientAddresses.defaultAddress); + it(`should click on the make default icon of the second address then confirm it is the default one now`, async () => { + const result = await nightmare + .waitToClick(selectors.clientAddresses.secondMakeDefaultStar) + .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') + .getInnerText(selectors.clientAddresses.defaultAddress); - expect(result).toContain('Somewhere in Thailand'); - }); + expect(result).toContain('Somewhere in Thailand'); + }); - it(`should click on the edit icon of the default address`, async () => { - const url = await nightmare - .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') - .waitToClick(selectors.clientAddresses.firstEditButton) - .waitForURL('/edit') - .url(); + it(`should click on the edit icon of the default address`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') + .waitToClick(selectors.clientAddresses.firstEditButton) + .waitForURL('/edit') + .url(); - expect(url).toContain('/edit'); - }); + expect(url).toContain('/edit'); + }); - it(`should click on the active checkbox and receive an error to save it because it is the default address`, async () => { - const result = await nightmare - .waitToClick(selectors.clientAddresses.activeCheckbox) - .waitToClick(selectors.clientAddresses.saveButton) - .waitForLastSnackbar(); + it(`should click on the active checkbox and receive an error to save it because it is the default address`, async () => { + const result = await nightmare + .waitToClick(selectors.clientAddresses.activeCheckbox) + .waitToClick(selectors.clientAddresses.saveButton) + .waitForLastSnackbar(); - expect(result).toEqual('The default consignee can not be unchecked'); - }); + expect(result).toEqual('The default consignee can not be unchecked'); }); }); diff --git a/e2e/paths/client-module/06_add_address_notes.spec.js b/e2e/paths/client-module/06_add_address_notes.spec.js index 3e915c7a4..857f77e80 100644 --- a/e2e/paths/client-module/06_add_address_notes.spec.js +++ b/e2e/paths/client-module/06_add_address_notes.spec.js @@ -5,7 +5,7 @@ describe('Client add address notes path', () => { const nightmare = createNightmare(); beforeAll(() => { - return nightmare + nightmare .waitForLogin('employee'); }); diff --git a/e2e/paths/client-module/07_edit_web_access.spec.js b/e2e/paths/client-module/07_edit_web_access.spec.js index 764220f81..3cb5c8b90 100644 --- a/e2e/paths/client-module/07_edit_web_access.spec.js +++ b/e2e/paths/client-module/07_edit_web_access.spec.js @@ -1,79 +1,77 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Client', () => { - describe('Edit web access path', () => { - const nightmare = createNightmare(); +describe('Client Edit web access path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare - .waitForLogin('employee'); - }); + beforeAll(() => { + nightmare + .waitForLogin('employee'); + }); - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); + it('should click on the Clients button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/index'); - }); + expect(url.hash).toEqual('#!/client/index'); + }); - it('should search for the user Bruce Banner', async () => { - const resultCount = await nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); + it('should search for the user Bruce Banner', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countElement(selectors.clientsIndex.searchResult); - expect(resultCount).toEqual(1); - }); + expect(resultCount).toEqual(1); + }); - it(`should click on the search result to access to the client's web access`, async () => { - const url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientsIndex.othersButton) - .waitToClick(selectors.clientWebAccess.webAccessButton) - .waitForURL('web-access') - .url(); + it(`should click on the search result to access to the client's web access`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientsIndex.othersButton) + .waitToClick(selectors.clientWebAccess.webAccessButton) + .waitForURL('web-access') + .url(); - expect(url).toContain('web-access'); - }); + expect(url).toContain('web-access'); + }); - it(`should uncheck the Enable web access checkbox and update the name`, async () => { - const result = await nightmare - .waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox) - .clearInput(selectors.clientWebAccess.userNameInput) - .type(selectors.clientWebAccess.userNameInput, 'Hulk') - .waitToClick(selectors.clientWebAccess.saveButton) - .waitForLastSnackbar(); + it(`should uncheck the Enable web access checkbox and update the name`, async () => { + const result = await nightmare + .waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox) + .clearInput(selectors.clientWebAccess.userNameInput) + .type(selectors.clientWebAccess.userNameInput, 'Hulk') + .waitToClick(selectors.clientWebAccess.saveButton) + .waitForLastSnackbar(); - expect(result).toEqual('Data saved!'); - }); + expect(result).toEqual('Data saved!'); + }); - it('should confirm web access is now unchecked', async () => { - const result = await nightmare - .waitToClick(selectors.clientBasicData.basicDataButton) - .wait(selectors.clientBasicData.nameInput) - .waitToClick(selectors.clientsIndex.othersButton) - .waitToClick(selectors.clientWebAccess.webAccessButton) - .wait(selectors.clientWebAccess.enableWebAccessCheckbox) - .evaluate((selector) => { - return document.querySelector(selector).checked; - }, selectors.clientWebAccess.enableWebAccessCheckbox); + it('should confirm web access is now unchecked', async () => { + const result = await nightmare + .waitToClick(selectors.clientBasicData.basicDataButton) + .wait(selectors.clientBasicData.nameInput) + .waitToClick(selectors.clientsIndex.othersButton) + .waitToClick(selectors.clientWebAccess.webAccessButton) + .wait(selectors.clientWebAccess.enableWebAccessCheckbox) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientWebAccess.enableWebAccessCheckbox); - expect(result).toBeFalsy(); - }); + expect(result).toBeFalsy(); + }); - it('should confirm web access name have been updated', async () => { - const result = await nightmare - .getInputValue(selectors.clientWebAccess.userNameInput); + it('should confirm web access name have been updated', async () => { + const result = await nightmare + .getInputValue(selectors.clientWebAccess.userNameInput); - expect(result).toEqual('Hulk'); - }); + expect(result).toEqual('Hulk'); }); }); diff --git a/e2e/paths/client-module/08_add_notes.spec.js b/e2e/paths/client-module/08_add_notes.spec.js index 2c0fceaa0..a6721906e 100644 --- a/e2e/paths/client-module/08_add_notes.spec.js +++ b/e2e/paths/client-module/08_add_notes.spec.js @@ -1,72 +1,70 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Client', () => { - describe('Add notes path', () => { - const nightmare = createNightmare(); +describe('Client Add notes path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare - .waitForLogin('employee'); - }); + beforeAll(() => { + nightmare + .waitForLogin('employee'); + }); - it('should click on the Clients button of the top bar menu', async ()=> { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); + it('should click on the Clients button of the top bar menu', async ()=> { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/index'); - }); + expect(url.hash).toEqual('#!/client/index'); + }); - it('should search for the user Bruce Banner', async () => { - const resultCount = await nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); + it('should search for the user Bruce Banner', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countElement(selectors.clientsIndex.searchResult); - expect(resultCount).toEqual(1); - }); + expect(resultCount).toEqual(1); + }); - it(`should click on the search result to access to the client's notes`, async () => { - const url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientNotes.notesButton) - .waitForURL('note/index') - .url(); + it(`should click on the search result to access to the client's notes`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientNotes.notesButton) + .waitForURL('note/index') + .url(); - expect(url).toContain('note/index'); - }); + expect(url).toContain('note/index'); + }); - it(`should click on the add note button`, async () => { - const url = await nightmare - .waitToClick(selectors.clientNotes.addNoteFloatButton) - .waitForURL('/note/create') - .url(); + it(`should click on the add note button`, async () => { + const url = await nightmare + .waitToClick(selectors.clientNotes.addNoteFloatButton) + .waitForURL('/note/create') + .url(); - expect(url).toContain('/note/create'); - }); + expect(url).toContain('/note/create'); + }); - it(`should create a note`, async () => { - const result = await nightmare - .type(selectors.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am') - .click(selectors.clientNotes.saveButton) - .waitForLastSnackbar(); + it(`should create a note`, async () => { + const result = await nightmare + .type(selectors.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am') + .click(selectors.clientNotes.saveButton) + .waitForLastSnackbar(); - expect(result).toEqual('Data saved!'); - }); + expect(result).toEqual('Data saved!'); + }); - it('should confirm the note was created', async () => { - const result = await nightmare - .wait(selectors.clientNotes.firstNoteText) - .getInnerText(selectors.clientNotes.firstNoteText); + it('should confirm the note was created', async () => { + const result = await nightmare + .wait(selectors.clientNotes.firstNoteText) + .getInnerText(selectors.clientNotes.firstNoteText); - expect(result).toEqual('Meeting with Black Widow 21st 9am'); - }); + expect(result).toEqual('Meeting with Black Widow 21st 9am'); }); }); diff --git a/e2e/paths/client-module/09_add_credit.spec.js b/e2e/paths/client-module/09_add_credit.spec.js index e9518525f..17a321ece 100644 --- a/e2e/paths/client-module/09_add_credit.spec.js +++ b/e2e/paths/client-module/09_add_credit.spec.js @@ -1,74 +1,72 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Client', () => { - describe('Add credit path', () => { - const nightmare = createNightmare(); +describe('Client Add credit path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare - .waitForLogin('salesAssistant'); - }); + beforeAll(() => { + nightmare + .waitForLogin('salesAssistant'); + }); - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); + it('should click on the Clients button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/index'); - }); + expect(url.hash).toEqual('#!/client/index'); + }); - it('should search for the user Hank Pym', async () => { - const resultCount = await nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Hank Pym') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); + it('should search for the user Hank Pym', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Hank Pym') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countElement(selectors.clientsIndex.searchResult); - expect(resultCount).toEqual(1); - }); + expect(resultCount).toEqual(1); + }); - it(`should click on the search result to access to the client's credit`, async () => { - const url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Hank Pym') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientCredit.creditButton) - .waitForURL('credit/index') - .url(); + it(`should click on the search result to access to the client's credit`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Hank Pym') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientCredit.creditButton) + .waitForURL('credit/index') + .url(); - expect(url).toContain('credit/index'); - }); + expect(url).toContain('credit/index'); + }); - it(`should click on the add credit button`, async () => { - const url = await nightmare - .waitToClick(selectors.clientCredit.addCreditFloatButton) - .waitForURL('/credit/create') - .url(); + it(`should click on the add credit button`, async () => { + const url = await nightmare + .waitToClick(selectors.clientCredit.addCreditFloatButton) + .waitForURL('/credit/create') + .url(); - expect(url).toContain('/credit/create'); - }); + expect(url).toContain('/credit/create'); + }); - it(`should edit the credit`, async () => { - const result = await nightmare - .clearInput(selectors.clientCredit.creditInput) - .type(selectors.clientCredit.creditInput, 999) - .click(selectors.clientCredit.saveButton) - .waitForLastSnackbar(); + it(`should edit the credit`, async () => { + const result = await nightmare + .clearInput(selectors.clientCredit.creditInput) + .type(selectors.clientCredit.creditInput, 999) + .click(selectors.clientCredit.saveButton) + .waitForLastSnackbar(); - expect(result).toEqual('Data saved!'); - }); + expect(result).toEqual('Data saved!'); + }); - it('should confirm the credit was updated', async () => { - const result = await nightmare - .wait(selectors.clientCredit.firstCreditText) - .getInnerText(selectors.clientCredit.firstCreditText); + it('should confirm the credit was updated', async () => { + const result = await nightmare + .wait(selectors.clientCredit.firstCreditText) + .getInnerText(selectors.clientCredit.firstCreditText); - expect(result).toContain(999); - expect(result).toContain('salesAssistant'); - }); + expect(result).toContain(999); + expect(result).toContain('salesAssistant'); }); }); diff --git a/e2e/paths/client-module/10_add_greuge.spec.js b/e2e/paths/client-module/10_add_greuge.spec.js index 430dd38c2..1ba67afa0 100644 --- a/e2e/paths/client-module/10_add_greuge.spec.js +++ b/e2e/paths/client-module/10_add_greuge.spec.js @@ -1,86 +1,84 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Client', () => { - describe('Add greuge path', () => { - const nightmare = createNightmare(); +describe('Client Add greuge path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare - .waitForLogin('salesAssistant'); - }); + beforeAll(() => { + nightmare + .waitForLogin('salesAssistant'); + }); - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); + it('should click on the Clients button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/index'); - }); + expect(url.hash).toEqual('#!/client/index'); + }); - it('should search for the user Petter Parker', async () => { - const resultCount = await nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); + it('should search for the user Petter Parker', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countElement(selectors.clientsIndex.searchResult); - expect(resultCount).toEqual(1); - }); + expect(resultCount).toEqual(1); + }); - it(`should click on the search result to access to the client's greuge`, async () => { - const url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientGreuge.greugeButton) - .waitForURL('greuge/index') - .url(); + it(`should click on the search result to access to the client's greuge`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientGreuge.greugeButton) + .waitForURL('greuge/index') + .url(); - expect(url).toContain('greuge/index'); - }); + expect(url).toContain('greuge/index'); + }); - it(`should click on the add greuge button`, async () => { - const url = await nightmare - .waitToClick(selectors.clientGreuge.addGreugeFloatButton) - .waitForURL('greuge/create') - .url(); + it(`should click on the add greuge button`, async () => { + const url = await nightmare + .waitToClick(selectors.clientGreuge.addGreugeFloatButton) + .waitForURL('greuge/create') + .url(); - expect(url).toContain('greuge/create'); - }); + expect(url).toContain('greuge/create'); + }); - it(`should receive an error if all fields are empty but date and type on submit`, async () => { - const result = await nightmare - .waitToClick(selectors.clientGreuge.typeInput) - .waitToClick(selectors.clientGreuge.typeSecondOption) - .click(selectors.clientGreuge.saveButton) - .waitForLastSnackbar(); + it(`should receive an error if all fields are empty but date and type on submit`, async () => { + const result = await nightmare + .waitToClick(selectors.clientGreuge.typeInput) + .waitToClick(selectors.clientGreuge.typeSecondOption) + .click(selectors.clientGreuge.saveButton) + .waitForLastSnackbar(); - expect(result).toEqual('Some fields are invalid'); - }); + expect(result).toEqual('Some fields are invalid'); + }); - it(`should create a new greuge with all its data`, async () => { - const result = await nightmare - .type(selectors.clientGreuge.amountInput, 999) - .waitForTextInInput(selectors.clientGreuge.amountInput, '999') - .type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!') - .click(selectors.clientGreuge.saveButton) - .waitForLastSnackbar(); + it(`should create a new greuge with all its data`, async () => { + const result = await nightmare + .type(selectors.clientGreuge.amountInput, 999) + .waitForTextInInput(selectors.clientGreuge.amountInput, '999') + .type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!') + .click(selectors.clientGreuge.saveButton) + .waitForLastSnackbar(); - expect(result).toEqual('Data saved!'); - }); + expect(result).toEqual('Data saved!'); + }); - it('should confirm the greuge was added to the list', async () => { - const result = await nightmare - .wait(selectors.clientGreuge.firstGreugeText) - .getInnerText(selectors.clientGreuge.firstGreugeText); + it('should confirm the greuge was added to the list', async () => { + const result = await nightmare + .wait(selectors.clientGreuge.firstGreugeText) + .getInnerText(selectors.clientGreuge.firstGreugeText); - expect(result).toContain(999); - expect(result).toContain('new armor for Batman!'); - expect(result).toContain('Diff'); - }); + expect(result).toContain(999); + expect(result).toContain('new armor for Batman!'); + expect(result).toContain('Diff'); }); }); diff --git a/e2e/paths/client-module/11_mandate.spec.js b/e2e/paths/client-module/11_mandate.spec.js index 2852a130a..dc48abb1c 100644 --- a/e2e/paths/client-module/11_mandate.spec.js +++ b/e2e/paths/client-module/11_mandate.spec.js @@ -1,57 +1,55 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Client', () => { - describe('mandate path', () => { - const nightmare = createNightmare(); +describe('Client mandate path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare - .waitForLogin('salesPerson'); - }); + beforeAll(() => { + nightmare + .waitForLogin('salesPerson'); + }); - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); + it('should click on the Clients button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/index'); - }); + expect(url.hash).toEqual('#!/client/index'); + }); - it('should search for the user Petter Parker', async () => { - const resultCount = await nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); + it('should search for the user Petter Parker', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countElement(selectors.clientsIndex.searchResult); - expect(resultCount).toEqual(1); - }); + expect(resultCount).toEqual(1); + }); - it(`should click on the search result to access to the client's mandate`, async () => { - const url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientsIndex.othersButton) - .waitToClick(selectors.clientMandate.mandateButton) - .waitForURL('mandate') - .url(); + it(`should click on the search result to access to the client's mandate`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientsIndex.othersButton) + .waitToClick(selectors.clientMandate.mandateButton) + .waitForURL('mandate') + .url(); - expect(url).toContain('mandate'); - }); + expect(url).toContain('mandate'); + }); - it('should confirm the client has a mandate of the CORE type', async () => { - const result = await nightmare - .wait(selectors.clientMandate.firstMandateText) - .getInnerText(selectors.clientMandate.firstMandateText); + it('should confirm the client has a mandate of the CORE type', async () => { + const result = await nightmare + .wait(selectors.clientMandate.firstMandateText) + .getInnerText(selectors.clientMandate.firstMandateText); - expect(result).toContain('1'); - expect(result).toContain('VNL'); - expect(result).toContain('CORE'); - }); + expect(result).toContain('1'); + expect(result).toContain('VNL'); + expect(result).toContain('CORE'); }); }); diff --git a/e2e/paths/client-module/12_lock_of_verified_data.spec.js b/e2e/paths/client-module/12_lock_of_verified_data.spec.js index ebc1e5226..706795f00 100644 --- a/e2e/paths/client-module/12_lock_of_verified_data.spec.js +++ b/e2e/paths/client-module/12_lock_of_verified_data.spec.js @@ -6,7 +6,7 @@ describe('Client lock verified data path', () => { describe('as salesPerson', () => { beforeAll(() => { - return nightmare + nightmare .waitForLogin('salesPerson'); }); @@ -87,7 +87,7 @@ describe('Client lock verified data path', () => { describe('as administrative', () => { beforeAll(() => { - return nightmare + nightmare .waitToClick(selectors.globalItems.logOutButton) .waitForLogin('administrative'); }); @@ -191,7 +191,7 @@ describe('Client lock verified data path', () => { describe('as salesPerson second run', () => { beforeAll(() => { - return nightmare + nightmare .waitToClick(selectors.globalItems.logOutButton) .waitForLogin('salesPerson'); }); @@ -262,7 +262,7 @@ describe('Client lock verified data path', () => { describe('as salesAssistant', () => { beforeAll(() => { - return nightmare + nightmare .waitToClick(selectors.globalItems.logOutButton) .waitForLogin('salesAssistant'); }); @@ -344,7 +344,7 @@ describe('Client lock verified data path', () => { describe('as salesPerson third run', () => { beforeAll(() => { - return nightmare + nightmare .waitToClick(selectors.globalItems.logOutButton) .waitForLogin('salesPerson'); }); diff --git a/e2e/paths/client-module/13_log.spec.js b/e2e/paths/client-module/13_log.spec.js index 2aa919390..c694a9c39 100644 --- a/e2e/paths/client-module/13_log.spec.js +++ b/e2e/paths/client-module/13_log.spec.js @@ -5,7 +5,7 @@ describe('Client log path', () => { const nightmare = createNightmare(); beforeAll(() => { - return nightmare + nightmare .waitForLogin('employee'); }); diff --git a/e2e/paths/client-module/14_risk.spec.js b/e2e/paths/client-module/14_risk.spec.js index 1f46e771a..04a7b5652 100644 --- a/e2e/paths/client-module/14_risk.spec.js +++ b/e2e/paths/client-module/14_risk.spec.js @@ -5,7 +5,7 @@ describe('Client risk path', () => { const nightmare = createNightmare(); beforeAll(() => { - return nightmare + nightmare .waitForLogin('administrative'); }); diff --git a/e2e/paths/item-module/01_item_summary.spec.js b/e2e/paths/item-module/01_item_summary.spec.js index 561c47712..309343ece 100644 --- a/e2e/paths/item-module/01_item_summary.spec.js +++ b/e2e/paths/item-module/01_item_summary.spec.js @@ -30,17 +30,16 @@ describe('Item summary path', () => { }); it(`should click on the search result summary button to open the item summary popup`, async () => { - const result = await nightmare + const isVisibleBefore = await nightmare .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') - .isVisible(selectors.itemSummary.basicData) - .then(result => { - expect(result).toBeFalsy(); - return nightmare - .waitToClick(selectors.itemsIndex.searchResultPreviewButton) - .isVisible(selectors.itemSummary.basicData); - }); + .isVisible(selectors.itemSummary.basicData); - expect(result).toBeTruthy(); + const isVisibleAfter = await nightmare + .waitToClick(selectors.itemsIndex.searchResultPreviewButton) + .isVisible(selectors.itemSummary.basicData); + + expect(isVisibleBefore).toBeFalsy(); + expect(isVisibleAfter).toBeTruthy(); }); it(`should check the item summary preview shows fields from basic data`, async () => { @@ -104,17 +103,17 @@ describe('Item summary path', () => { }); it(`should now click on the search result summary button to open the item summary popup`, async () => { - const result = await nightmare + const isVisibleBefore = await nightmare .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Mind') - .isVisible(selectors.itemSummary.basicData) - .then(result => { - expect(result).toBeFalsy(); - return nightmare - .waitToClick(selectors.itemsIndex.searchResultPreviewButton) - .isVisible(selectors.itemSummary.basicData); - }); + .isVisible(selectors.itemSummary.basicData); - expect(result).toBeTruthy(); + const isVisibleAfter = await nightmare + .waitToClick(selectors.itemsIndex.searchResultPreviewButton) + .isVisible(selectors.itemSummary.basicData); + + + expect(isVisibleBefore).toBeFalsy(); + expect(isVisibleAfter).toBeTruthy(); }); it(`should now check the item summary preview shows fields from basic data`, async () => { diff --git a/e2e/paths/item-module/02_edit_item_basic_data.spec.js b/e2e/paths/item-module/02_edit_item_basic_data.spec.js index 967a54d7d..1d375c296 100644 --- a/e2e/paths/item-module/02_edit_item_basic_data.spec.js +++ b/e2e/paths/item-module/02_edit_item_basic_data.spec.js @@ -1,130 +1,133 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Item', () => { - describe('Edit basic data path', () => { - const nightmare = createNightmare(); +describe('Item Edit basic data path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare - .waitForLogin('buyer'); - }); + beforeAll(() => { + nightmare + .waitForLogin('buyer'); + }); - it('should access to the items index by clicking the items button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); + it('should access to the items index by clicking the items button', async () => { + const url = await nightmare + .click(selectors.moduleAccessView.itemsSectionButton) + .wait(selectors.itemsIndex.createItemButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/item/index'); - }); + expect(url.hash).toEqual('#!/item/index'); + }); - it('should search for the item Gem of Mind', async () => { - const resultCount = await nightmare - .wait(selectors.itemsIndex.searchResult) - .type(selectors.itemsIndex.searchItemInput, 'Gem of Mind') - .click(selectors.itemsIndex.searchButton) - .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) - .countElement(selectors.itemsIndex.searchResult); + it('should search for the item Gem of Mind', async () => { + const resultCount = await nightmare + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Gem of Mind') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) + .countElement(selectors.itemsIndex.searchResult); - expect(resultCount).toEqual(1); - }); + expect(resultCount).toEqual(1); + }); - it(`should click on the search result to access to the item basic data`, async () => { - const url = await nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Mind') - .waitToClick(selectors.itemsIndex.searchResult) - .waitToClick(selectors.itemBasicData.basicDataButton) - .waitForURL('data') - .url(); + it(`should click on the search result to access to the item basic data`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Mind') + .waitToClick(selectors.itemsIndex.searchResult) + .waitToClick(selectors.itemBasicData.basicDataButton) + .waitForURL('data') + .url(); - expect(url).toContain('data'); - }); + expect(url).toContain('data'); + }); - it(`should edit the item basic data`, async () => { - const result = await nightmare - .clearInput(selectors.itemBasicData.nameInput) - .type(selectors.itemBasicData.nameInput, 'Rose of Purity') - .waitToClick(selectors.itemBasicData.typeSelect) - .waitToClick(selectors.itemBasicData.typeSelectOptionThree) - .waitToClick(selectors.itemBasicData.intrastatSelect) - .waitToClick(selectors.itemBasicData.intrastatSelectOptionOne) - .clearInput(selectors.itemBasicData.relevancyInput) - .type(selectors.itemBasicData.relevancyInput, '1') - .waitToClick(selectors.itemBasicData.originSelect) - .waitToClick(selectors.itemBasicData.originSelectOptionTwo) - .waitToClick(selectors.itemBasicData.expenceSelect) - .waitToClick(selectors.itemBasicData.expenceSelectOptionThree) - .clearInput(selectors.itemBasicData.longNameInput) - .type(selectors.itemBasicData.longNameInput, 'RS Rose of Purity') - .waitToClick(selectors.itemBasicData.isActiveCheckbox) - .click(selectors.itemBasicData.submitBasicDataButton) - .waitForLastSnackbar(); + it(`should edit the item basic data`, async () => { + const result = await nightmare + .clearInput(selectors.itemBasicData.nameInput) + .type(selectors.itemBasicData.nameInput, 'Rose of Purity') + .waitToClick(selectors.itemBasicData.typeSelect) + .waitToClick(selectors.itemBasicData.typeSelectOptionThree) + .waitToClick(selectors.itemBasicData.intrastatSelect) + .waitToClick(selectors.itemBasicData.intrastatSelectOptionOne) + .clearInput(selectors.itemBasicData.relevancyInput) + .type(selectors.itemBasicData.relevancyInput, '1') + .waitToClick(selectors.itemBasicData.originSelect) + .waitToClick(selectors.itemBasicData.originSelectOptionTwo) + .waitToClick(selectors.itemBasicData.expenceSelect) + .waitToClick(selectors.itemBasicData.expenceSelectOptionThree) + .clearInput(selectors.itemBasicData.longNameInput) + .type(selectors.itemBasicData.longNameInput, 'RS Rose of Purity') + .waitToClick(selectors.itemBasicData.isActiveCheckbox) + .click(selectors.itemBasicData.submitBasicDataButton) + .waitForLastSnackbar(); - expect(result).toEqual('Data saved!'); - }); + expect(result).toEqual('Data saved!'); + }); - it(`should confirm the item name was edited`, async () => { - const result = await nightmare - .click(selectors.itemNiches.nicheButton) - .wait(selectors.itemNiches.firstWarehouseDisabled) - .waitToClick(selectors.itemBasicData.basicDataButton) - .waitForTextInInput(selectors.itemBasicData.nameInput, 'Rose of Purity') - .getInputValue(selectors.itemBasicData.nameInput); + it(`should confirm the item name was edited`, async () => { + const result = await nightmare + .click(selectors.itemNiches.nicheButton) + .wait(selectors.itemNiches.firstWarehouseDisabled) + .waitToClick(selectors.itemBasicData.basicDataButton) + .waitProperty(selectors.itemBasicData.nameInput, 'value') + .getProperty(selectors.itemBasicData.nameInput, 'value'); - expect(result).toEqual('Rose of Purity'); - }); + expect(result).toEqual('Rose of Purity'); + }); - it(`should confirm the item type was edited`, async () => { - const result = await nightmare - .getInputValue(selectors.itemBasicData.typeSelect); + it(`should confirm the item type was edited`, async () => { + const result = await nightmare + .waitProperty(selectors.itemBasicData.typeSelect, 'value') + .getProperty(selectors.itemBasicData.typeSelect, 'value'); - expect(result).toEqual('Crisantemo'); - }); + expect(result).toEqual('Crisantemo'); + }); - it(`should confirm the item intrastad was edited`, async () => { - const result = await nightmare - .waitProperty(selectors.itemBasicData.intrastatSelect, 'value') - .getProperty(selectors.itemBasicData.intrastatSelect, 'value'); + it(`should confirm the item intrastad was edited`, async () => { + const result = await nightmare + .waitProperty(selectors.itemBasicData.intrastatSelect, 'value') + .getProperty(selectors.itemBasicData.intrastatSelect, 'value'); - expect(result).toEqual('5080000 Coral y materiales similares'); - }); + expect(result).toEqual('5080000 Coral y materiales similares'); + }); - it(`should confirm the item relevancy was edited`, async () => { - const result = await nightmare - .getInputValue(selectors.itemBasicData.relevancyInput); + it(`should confirm the item relevancy was edited`, async () => { + const result = await nightmare + .waitProperty(selectors.itemBasicData.relevancyInput, 'value') + .getProperty(selectors.itemBasicData.relevancyInput, 'value'); - expect(result).toEqual('1'); - }); + expect(result).toEqual('1'); + }); - it(`should confirm the item origin was edited`, async () => { - const result = await nightmare - .getInputValue(selectors.itemBasicData.originSelect); + it(`should confirm the item origin was edited`, async () => { + const result = await nightmare + .waitProperty(selectors.itemBasicData.originSelect, 'value') + .getProperty(selectors.itemBasicData.originSelect, 'value'); - expect(result).toEqual('Spain'); - }); + expect(result).toEqual('Spain'); + }); - it(`should confirm the item expence was edited`, async () => { - const result = await nightmare - .getInputValue(selectors.itemBasicData.expenceSelect); + it(`should confirm the item expence was edited`, async () => { + const result = await nightmare + .waitProperty(selectors.itemBasicData.expenceSelect, 'value') + .getProperty(selectors.itemBasicData.expenceSelect, 'value'); - expect(result).toEqual('Adquisición mercancia Extracomunitaria'); - }); + expect(result).toEqual('Adquisición mercancia Extracomunitaria'); + }); - it(`should confirm the item long name was edited`, async () => { - const result = await nightmare - .getInputValue(selectors.itemBasicData.longNameInput); + it(`should confirm the item long name was edited`, async () => { + const result = await nightmare + .waitProperty(selectors.itemBasicData.longNameInput, 'value') + .getProperty(selectors.itemBasicData.longNameInput, 'value'); - expect(result).toEqual('RS Rose of Purity'); - }); + expect(result).toEqual('RS Rose of Purity'); + }); - it('should confirm isActive checkbox is unchecked', async () => { - const result = await nightmare - .evaluate((selector) => { - return document.querySelector(selector).checked; - }, selectors.itemBasicData.isActiveCheckbox); + it('should confirm isActive checkbox is unchecked', async () => { + const result = await nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.itemBasicData.isActiveCheckbox); - expect(result).toBeFalsy(); - }); + expect(result).toBeFalsy(); }); }); diff --git a/e2e/paths/item-module/03_edit_item_tax.spec.js b/e2e/paths/item-module/03_edit_item_tax.spec.js index 2e15ebbca..5ad0cb39b 100644 --- a/e2e/paths/item-module/03_edit_item_tax.spec.js +++ b/e2e/paths/item-module/03_edit_item_tax.spec.js @@ -5,7 +5,7 @@ describe('Item edit tax path', () => { const nightmare = createNightmare(); beforeAll(() => { - return nightmare + nightmare .waitForLogin('buyer'); }); diff --git a/e2e/paths/item-module/04_create_item_tags.spec.js b/e2e/paths/item-module/04_create_item_tags.spec.js index 89bf10c38..541bb543b 100644 --- a/e2e/paths/item-module/04_create_item_tags.spec.js +++ b/e2e/paths/item-module/04_create_item_tags.spec.js @@ -5,7 +5,7 @@ describe('Item create tags path', () => { const nightmare = createNightmare(); beforeAll(() => { - return nightmare + nightmare .waitForLogin('buyer'); }); diff --git a/e2e/paths/item-module/05_create_item_niche.spec.js b/e2e/paths/item-module/05_create_item_niche.spec.js index 04fa0f3db..b659a464f 100644 --- a/e2e/paths/item-module/05_create_item_niche.spec.js +++ b/e2e/paths/item-module/05_create_item_niche.spec.js @@ -5,7 +5,7 @@ describe('Item create niche path', () => { const nightmare = createNightmare(); beforeAll(() => { - return nightmare + nightmare .waitForLogin('buyer'); }); diff --git a/e2e/paths/item-module/06_create_item_botanical.spec.js b/e2e/paths/item-module/06_create_item_botanical.spec.js index 00a5743c1..cb1e3e498 100644 --- a/e2e/paths/item-module/06_create_item_botanical.spec.js +++ b/e2e/paths/item-module/06_create_item_botanical.spec.js @@ -1,101 +1,86 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Item', () => { - describe('Create botanical path', () => { - const nightmare = createNightmare(); +describe('Item Create botanical path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare + beforeAll(() => { + nightmare .waitForLogin('buyer'); - }); + }); - it('should access to the items index by clicking the items button', done => { - return nightmare + it('should access to the items index by clicking the items button', async () => { + const url = await nightmare .click(selectors.moduleAccessView.itemsSectionButton) .wait(selectors.itemsIndex.createItemButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/item/index'); - done(); - }).catch(done.fail); - }); + .parsedUrl(); - it('should search for the item Mjolnir', done => { - return nightmare + expect(url.hash).toEqual('#!/item/index'); + }); + + it('should search for the item Mjolnir', async () => { + const result = await nightmare .wait(selectors.itemsIndex.searchResult) .type(selectors.itemsIndex.searchItemInput, 'Mjolnir') .click(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) - .countElement(selectors.itemsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); - }); + .countElement(selectors.itemsIndex.searchResult); - it(`should click on the search result to access to the item botanical`, done => { - return nightmare + expect(result).toEqual(1); + }); + + it(`should click on the search result to access to the item botanical`, async () => { + const url = await nightmare .waitForTextInElement(selectors.itemsIndex.searchResult, 'Mjolnir') .waitToClick(selectors.itemsIndex.searchResult) .waitToClick(selectors.itemBotanical.botanicalButton) .waitForURL('botanical') - .url() - .then(url => { - expect(url).toContain('botanical'); - done(); - }).catch(done.fail); - }); + .url(); - it(`should create a new botanical for the item with id Mjolnir`, done => { - return nightmare + expect(url).toContain('botanical'); + }); + + it(`should create a new botanical for the item with id Mjolnir`, async () => { + const result = await nightmare .type(selectors.itemBotanical.botanicalInput, 'Cicuta maculata') .waitToClick(selectors.itemBotanical.genusSelect) .waitToClick(selectors.itemBotanical.genusSelectOptionOne) .waitToClick(selectors.itemBotanical.speciesSelect) .waitToClick(selectors.itemBotanical.speciesSelectOptionOne) .waitToClick(selectors.itemBotanical.submitBotanicalButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); - }); + .waitForLastSnackbar(); - it(`should confirm the botanical for item Mjolnir was created`, done => { - return nightmare + expect(result).toEqual('Data saved!'); + }); + + it(`should confirm the botanical for item Mjolnir was created`, async () => { + const result = await nightmare .click(selectors.itemBasicData.basicDataButton) .wait(selectors.itemBasicData.nameInput) .click(selectors.itemBotanical.botanicalButton) .waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Cicuta maculata') - .getInputValue(selectors.itemBotanical.botanicalInput) - .then(result => { - expect(result).toEqual('Cicuta maculata'); - done(); - }).catch(done.fail); - }); + .getInputValue(selectors.itemBotanical.botanicalInput); - it(`should confirm the Genus for item Mjolnir was created`, done => { - return nightmare + expect(result).toEqual('Cicuta maculata'); + }); + + it(`should confirm the Genus for item Mjolnir was created`, async () => { + const result = await nightmare .waitForTextInInput(selectors.itemBotanical.genusSelect, 'Abelia') - .getInputValue(selectors.itemBotanical.genusSelect) - .then(result => { - expect(result).toEqual('Abelia'); - done(); - }).catch(done.fail); - }); + .getInputValue(selectors.itemBotanical.genusSelect); - it(`should confirm the Species for item Mjolnir was created`, done => { - return nightmare - .getInputValue(selectors.itemBotanical.speciesSelect) - .then(result => { - expect(result).toEqual('dealbata'); - done(); - }).catch(done.fail); - }); + expect(result).toEqual('Abelia'); + }); - it(`should edit botanical for the item Mjolnir`, done => { - return nightmare + it(`should confirm the Species for item Mjolnir was created`, async () => { + const result = await nightmare + .getInputValue(selectors.itemBotanical.speciesSelect); + + expect(result).toEqual('dealbata'); + }); + + it(`should edit botanical for the item Mjolnir`, async () => { + const result = await nightmare .clearInput(selectors.itemBotanical.botanicalInput) .type(selectors.itemBotanical.botanicalInput, 'Herp Derp') .waitToClick(selectors.itemBotanical.genusSelect) @@ -103,43 +88,34 @@ describe('Item', () => { .waitToClick(selectors.itemBotanical.speciesSelect) .waitToClick(selectors.itemBotanical.speciesSelectOptionTwo) .waitToClick(selectors.itemBotanical.submitBotanicalButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); - }); + .waitForLastSnackbar(); - it(`should confirm the botanical for item Mjolnir was edited`, done => { - return nightmare + expect(result).toEqual('Data saved!'); + }); + + it(`should confirm the botanical for item Mjolnir was edited`, async () => { + const result = await nightmare .click(selectors.itemBasicData.basicDataButton) .wait(selectors.itemBasicData.nameInput) .click(selectors.itemBotanical.botanicalButton) .waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Herp Derp') - .getInputValue(selectors.itemBotanical.botanicalInput) - .then(result => { - expect(result).toEqual('Herp Derp'); - done(); - }).catch(done.fail); - }); + .getInputValue(selectors.itemBotanical.botanicalInput); - it(`should confirm the Genus for item Mjolnir was edited`, done => { - return nightmare + expect(result).toEqual('Herp Derp'); + }); + + it(`should confirm the Genus for item Mjolnir was edited`, async () => { + const result = await nightmare .waitForTextInInput(selectors.itemBotanical.genusSelect, 'Abies') - .getInputValue(selectors.itemBotanical.genusSelect) - .then(result => { - expect(result).toEqual('Abies'); - done(); - }).catch(done.fail); - }); + .getInputValue(selectors.itemBotanical.genusSelect); - it(`should confirm the Species for item Mjolnir was edited`, done => { - return nightmare - .getInputValue(selectors.itemBotanical.speciesSelect) - .then(result => { - expect(result).toEqual('decurrens'); - done(); - }).catch(done.fail); - }); + expect(result).toEqual('Abies'); + }); + + it(`should confirm the Species for item Mjolnir was edited`, async () => { + const result = await nightmare + .getInputValue(selectors.itemBotanical.speciesSelect); + + expect(result).toEqual('decurrens'); }); }); diff --git a/e2e/paths/item-module/07_create_item_barcode.spec.js b/e2e/paths/item-module/07_create_item_barcode.spec.js index 224130adc..52432687e 100644 --- a/e2e/paths/item-module/07_create_item_barcode.spec.js +++ b/e2e/paths/item-module/07_create_item_barcode.spec.js @@ -1,77 +1,65 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Item', () => { - describe('Create barcodes path', () => { - const nightmare = createNightmare(); +describe('Item Create barcodes path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare + beforeAll(() => { + nightmare .waitForLogin('buyer'); - }); + }); - it('should access to the items index by clicking the items button', done => { - return nightmare + it('should access to the items index by clicking the items button', async () => { + const url = await nightmare .click(selectors.moduleAccessView.itemsSectionButton) .wait(selectors.itemsIndex.createItemButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/item/index'); - done(); - }).catch(done.fail); - }); + .parsedUrl(); - it('should search for the item Gem of Time', done => { - return nightmare + expect(url.hash).toEqual('#!/item/index'); + }); + + it('should search for the item Gem of Time', async () => { + const result = await nightmare .wait(selectors.itemsIndex.searchResult) .type(selectors.itemsIndex.searchItemInput, 'Gem of Time') .click(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) - .countElement(selectors.itemsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); - }); + .countElement(selectors.itemsIndex.searchResult); - it(`should click on the search result to access to the item barcodes`, done => { - return nightmare + expect(result).toEqual(1); + }); + + it(`should click on the search result to access to the item barcodes`, async () => { + const url = await nightmare .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') .waitToClick(selectors.itemsIndex.searchResult) .waitToClick(selectors.itemBarcodes.barcodeButton) .waitForURL('barcode') - .url() - .then(url => { - expect(url).toContain('barcode'); - done(); - }).catch(done.fail); - }); + .url(); - it(`should click create a new code and delete a former one`, done => { - return nightmare + expect(url).toContain('barcode'); + }); + + it(`should click create a new code and delete a former one`, async () => { + const result = await nightmare .waitToClick(selectors.itemBarcodes.firstCodeRemoveButton) .waitToClick(selectors.itemBarcodes.addBarcodeButton) .wait(selectors.itemBarcodes.thirdCodeInput) .type(selectors.itemBarcodes.thirdCodeInput, '5') .waitToClick(selectors.itemBarcodes.submitBarcodesButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); - }); + .waitForLastSnackbar(); - it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, done => { - return nightmare + expect(result).toEqual('Data saved!'); + }); + + it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, async () => { + const result = await nightmare .click(selectors.itemBasicData.basicDataButton) .wait(selectors.itemBasicData.nameInput) .click(selectors.itemBarcodes.barcodeButton) .waitForTextInInput(selectors.itemBarcodes.thirdCodeInput, '5') - .getInputValue(selectors.itemBarcodes.thirdCodeInput) - .then(result => { - expect(result).toEqual('5'); - done(); - }).catch(done.fail); - }); + .getInputValue(selectors.itemBarcodes.thirdCodeInput); + + expect(result).toEqual('5'); }); }); diff --git a/e2e/paths/item-module/08_item_create_and_clone.spec.js b/e2e/paths/item-module/08_item_create_and_clone.spec.js index ab333dc86..ba3a2696b 100644 --- a/e2e/paths/item-module/08_item_create_and_clone.spec.js +++ b/e2e/paths/item-module/08_item_create_and_clone.spec.js @@ -1,145 +1,143 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Item', () => { +describe('Item Create path', () => { const nightmare = createNightmare(); - describe('Create path', () => { - beforeAll(() => { - return nightmare - .waitForLogin('buyer'); - }); - - it('should access to the items index by clicking the items button', async () => { - const url = await nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/index'); - }); - - it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async () => { - const result = await nightmare - .wait(selectors.itemsIndex.searchResult) - .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') - .click(selectors.itemsIndex.searchButton) - .waitForNumberOfElements(selectors.itemsIndex.searchResult, 0) - .countElement(selectors.itemsIndex.searchResult); - - expect(result).toEqual(0); - }); - - it('should access to the create item view by clicking the create floating button', async () => { - const url = await nightmare - .click(selectors.itemsIndex.createItemButton) - .wait(selectors.itemCreateView.createButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/create'); - }); - - it('should return to the item index by clickig the cancel button', async () => { - const url = await nightmare - .click(selectors.itemCreateView.cancelButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/index'); - }); - - it('should now access to the create item view by clicking the create floating button', async () => { - const url = await nightmare - .click(selectors.itemsIndex.createItemButton) - .wait(selectors.itemCreateView.createButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/item/create'); - }); - - it('should create the Infinity Gauntlet item', async () => { - const result = await nightmare - .type(selectors.itemCreateView.name, 'Infinity Gauntlet') - .waitToClick(selectors.itemCreateView.typeSelect) - .waitToClick(selectors.itemCreateView.typeSelectOptionThree) - .waitToClick(selectors.itemCreateView.intrastatSelect) - .waitToClick(selectors.itemCreateView.intrastatSelectOptionOne) - .waitToClick(selectors.itemCreateView.originSelect) - .waitToClick(selectors.itemCreateView.originSelectOptionOne) - .click(selectors.itemCreateView.createButton) - .waitForLastSnackbar(); - - expect(result).toEqual('Data saved!'); - }); - - it('should confirm Infinity Gauntlet item was created', async () => { - let result = await nightmare - .wait(selectors.itemBasicData.nameInput) - .getInputValue(selectors.itemBasicData.nameInput); - - expect(result).toEqual('Infinity Gauntlet'); - - - result = await nightmare - .getInputValue(selectors.itemBasicData.typeSelect); - - expect(result).toEqual('Crisantemo'); - - result = await nightmare - .waitProperty(selectors.itemBasicData.intrastatSelect, 'value') - .getProperty(selectors.itemBasicData.intrastatSelect, 'value'); - - expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid'); - - result = await nightmare - .getInputValue(selectors.itemBasicData.originSelect); - - expect(result).toEqual('Spain'); - }); + beforeAll(() => { + nightmare + .waitForLogin('buyer'); }); - describe('Clone path', () => { - it('should return to the items index by clicking the return to items button', async () => { - const url = await nightmare - .click(selectors.itemBasicData.goToItemIndexButton) - .wait(selectors.itemsIndex.createItemButton) - .waitForURL('#!/item/index') - .parsedUrl(); + it('should access to the items index by clicking the items button', async () => { + const url = await nightmare + .click(selectors.moduleAccessView.itemsSectionButton) + .wait(selectors.itemsIndex.createItemButton) + .parsedUrl(); - expect(url.hash).toContain('#!/item/index'); - }); + expect(url.hash).toEqual('#!/item/index'); + }); - it(`should search for the item Infinity Gauntlet`, async () => { - const result = await nightmare - .wait(selectors.itemsIndex.searchResult) - .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') - .click(selectors.itemsIndex.searchButton) - .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) - .countElement(selectors.itemsIndex.searchResult); + it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async () => { + const result = await nightmare + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 0) + .countElement(selectors.itemsIndex.searchResult); - expect(result).toEqual(1); - }); + expect(result).toEqual(0); + }); - it(`should clone the Infinity Gauntlet`, async () => { - const url = await nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet') - .click(selectors.itemsIndex.searchResultCloneButton) - .waitToClick(selectors.itemsIndex.acceptClonationAlertButton) - .waitForURL('tags') - .parsedUrl(); + it('should access to the create item view by clicking the create floating button', async () => { + const url = await nightmare + .click(selectors.itemsIndex.createItemButton) + .wait(selectors.itemCreateView.createButton) + .parsedUrl(); - expect(url.hash).toContain('tags'); - }); + expect(url.hash).toEqual('#!/item/create'); + }); - it('should search for the item Infinity Gauntlet and find two', async () => { - const result = await nightmare - .waitToClick(selectors.itemTags.goToItemIndexButton) - .wait(selectors.itemsIndex.searchResult) - .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') - .click(selectors.itemsIndex.searchButton) - .waitForNumberOfElements(selectors.itemsIndex.searchResult, 2) - .countElement(selectors.itemsIndex.searchResult); + it('should return to the item index by clickig the cancel button', async () => { + const url = await nightmare + .click(selectors.itemCreateView.cancelButton) + .wait(selectors.itemsIndex.createItemButton) + .parsedUrl(); - expect(result).toEqual(2); - }); + expect(url.hash).toEqual('#!/item/index'); + }); + + it('should now access to the create item view by clicking the create floating button', async () => { + const url = await nightmare + .click(selectors.itemsIndex.createItemButton) + .wait(selectors.itemCreateView.createButton) + .parsedUrl(); + + expect(url.hash).toEqual('#!/item/create'); + }); + + it('should create the Infinity Gauntlet item', async () => { + const result = await nightmare + .type(selectors.itemCreateView.name, 'Infinity Gauntlet') + .waitToClick(selectors.itemCreateView.typeSelect) + .waitToClick(selectors.itemCreateView.typeSelectOptionThree) + .waitToClick(selectors.itemCreateView.intrastatSelect) + .waitToClick(selectors.itemCreateView.intrastatSelectOptionOne) + .waitToClick(selectors.itemCreateView.originSelect) + .waitToClick(selectors.itemCreateView.originSelectOptionOne) + .click(selectors.itemCreateView.createButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should confirm Infinity Gauntlet item was created', async () => { + let result = await nightmare + .wait(selectors.itemBasicData.nameInput) + .getInputValue(selectors.itemBasicData.nameInput); + + expect(result).toEqual('Infinity Gauntlet'); + + + result = await nightmare + .getInputValue(selectors.itemBasicData.typeSelect); + + expect(result).toEqual('Crisantemo'); + + result = await nightmare + .waitProperty(selectors.itemBasicData.intrastatSelect, 'value') + .getProperty(selectors.itemBasicData.intrastatSelect, 'value'); + + expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid'); + + result = await nightmare + .getInputValue(selectors.itemBasicData.originSelect); + + expect(result).toEqual('Spain'); + }); +}); + +describe('Clone path', () => { + it('should return to the items index by clicking the return to items button', async () => { + const url = await nightmare + .click(selectors.itemBasicData.goToItemIndexButton) + .wait(selectors.itemsIndex.createItemButton) + .waitForURL('#!/item/index') + .parsedUrl(); + + expect(url.hash).toContain('#!/item/index'); + }); + + it(`should search for the item Infinity Gauntlet`, async () => { + const result = await nightmare + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) + .countElement(selectors.itemsIndex.searchResult); + + expect(result).toEqual(1); + }); + + it(`should clone the Infinity Gauntlet`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchResultCloneButton) + .waitToClick(selectors.itemsIndex.acceptClonationAlertButton) + .waitForURL('tags') + .parsedUrl(); + + expect(url.hash).toContain('tags'); + }); + + it('should search for the item Infinity Gauntlet and find two', async () => { + const result = await nightmare + .waitToClick(selectors.itemTags.goToItemIndexButton) + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 2) + .countElement(selectors.itemsIndex.searchResult); + + expect(result).toEqual(2); }); }); diff --git a/e2e/paths/item-module/09_regularize_item.spec.js b/e2e/paths/item-module/09_regularize_item.spec.js index cc1bbd1c4..bb0f3ba2d 100644 --- a/e2e/paths/item-module/09_regularize_item.spec.js +++ b/e2e/paths/item-module/09_regularize_item.spec.js @@ -4,7 +4,7 @@ import createNightmare from '../../helpers/nightmare'; describe('Item regularize path', () => { const nightmare = createNightmare(); beforeAll(() => { - return nightmare + nightmare .waitForLogin('developer'); });