diff --git a/e2e/paths/claim-module/01_edit_basic_data.spec.js b/e2e/paths/claim-module/01_edit_basic_data.spec.js index 90dafa4da9..b39873169e 100644 --- a/e2e/paths/claim-module/01_edit_basic_data.spec.js +++ b/e2e/paths/claim-module/01_edit_basic_data.spec.js @@ -6,90 +6,90 @@ describe('Claim edit basic data path', () => { beforeAll(() => { nightmare - .waitForLogin('salesAssistant'); + .waitForLogin('salesAssistant'); }); - it('should click on the Claims button of the top bar menu', async() => { - let url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.claimsButton) - .wait(selectors.claimsIndex.searchClaimInput) - .parsedUrl(); - + it('should click on the Claims button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.claimsButton) + .wait(selectors.claimsIndex.searchClaimInput) + .parsedUrl(); + expect(url.hash).toEqual('#!/claim/index'); }); - it('should search for the claim with id 1', async() => { - let resultCount = await nightmare - .wait(selectors.claimsIndex.searchResult) - .type(selectors.claimsIndex.searchClaimInput, '1') - .click(selectors.claimsIndex.searchButton) - .waitForNumberOfElements(selectors.claimsIndex.searchResult, 1) - .countElement(selectors.claimsIndex.searchResult); - + it('should search for the claim with id 1', async () => { + const resultCount = await nightmare + .wait(selectors.claimsIndex.searchResult) + .type(selectors.claimsIndex.searchClaimInput, '1') + .click(selectors.claimsIndex.searchButton) + .waitForNumberOfElements(selectors.claimsIndex.searchResult, 1) + .countElement(selectors.claimsIndex.searchResult); + expect(resultCount).toEqual(1); }); - it(`should click on the search result to access to the claim Basic Data`, async() => { - let url = await nightmare - .waitToClick(selectors.claimsIndex.searchResult) - .waitToClick(selectors.claimBasicData.basicDataButton) - .waitForURL('basic-data') - .url(); - + it(`should click on the search result to access to the claim Basic Data`, async () => { + const url = await nightmare + .waitToClick(selectors.claimsIndex.searchResult) + .waitToClick(selectors.claimBasicData.basicDataButton) + .waitForURL('basic-data') + .url(); + expect(url).toContain('basic-data'); }); - it(`should edit claim state, is paid with mana and observation fields`, async() => { - let result = await nightmare - .waitToClick(selectors.claimBasicData.claimStateSelect) - .waitToClick(selectors.claimBasicData.claimStateSelectThirdOption) - .waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox) - .clearInput(selectors.claimBasicData.observationInput) - .type(selectors.claimBasicData.observationInput, 'edited observation') - .click(selectors.claimBasicData.saveButton) - .waitForSnackbar(); - + it(`should edit claim state, is paid with mana and observation fields`, async () => { + const result = await nightmare + .waitToClick(selectors.claimBasicData.claimStateSelect) + .waitToClick(selectors.claimBasicData.claimStateSelectThirdOption) + .waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox) + .clearInput(selectors.claimBasicData.observationInput) + .type(selectors.claimBasicData.observationInput, 'edited observation') + .click(selectors.claimBasicData.saveButton) + .waitForSnackbar(); + expect(result).toEqual(jasmine.arrayContaining(['Data saved!'])); }); - it('should confirm the claim state was edited', async() => { - let result = await nightmare - .click(selectors.claimDetails.detailsButton) - .wait(selectors.claimDetails.addItemButton) - .click(selectors.claimBasicData.basicDataButton) - .wait(selectors.claimBasicData.claimStateSelect) - .getInputValue(selectors.claimBasicData.claimStateSelect); - + it('should confirm the claim state was edited', async () => { + const result = await nightmare + .click(selectors.claimDetails.detailsButton) + .wait(selectors.claimDetails.addItemButton) + .click(selectors.claimBasicData.basicDataButton) + .wait(selectors.claimBasicData.claimStateSelect) + .getInputValue(selectors.claimBasicData.claimStateSelect); + expect(result).toEqual('Gestionado'); }); - it('should confirm the Is paid with mana checkbox is checked', async() => { - let value = await nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.claimBasicData.isPaidWithManaCheckbox); - + it('should confirm the Is paid with mana checkbox is checked', async () => { + const value = await nightmare + .evaluate((selector) => { + return document.querySelector(selector).checked; + }, selectors.claimBasicData.isPaidWithManaCheckbox); + expect(value).toBeTruthy(); }); - it('should confirm the claim observation was edited', async() => { - let result = await nightmare - .getInputValue(selectors.claimBasicData.observationInput); - + it('should confirm the claim observation was edited', async () => { + const result = await nightmare + .getInputValue(selectors.claimBasicData.observationInput); + expect(result).toEqual('edited observation'); }); - it(`should edit the claim to leave it untainted`, async() => { - let result = await nightmare - .waitToClick(selectors.claimBasicData.claimStateSelect) - .waitToClick(selectors.claimBasicData.claimStateSelectFourthOption) - .waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox) - .clearInput(selectors.claimBasicData.observationInput) - .type(selectors.claimBasicData.observationInput, 'Observation one') - .click(selectors.claimBasicData.saveButton) - .waitForSnackbar(); + it(`should edit the claim to leave it untainted`, async () => { + const result = await nightmare + .waitToClick(selectors.claimBasicData.claimStateSelect) + .waitToClick(selectors.claimBasicData.claimStateSelectFourthOption) + .waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox) + .clearInput(selectors.claimBasicData.observationInput) + .type(selectors.claimBasicData.observationInput, 'Observation one') + .click(selectors.claimBasicData.saveButton) + .waitForSnackbar(); expect(result).toEqual(jasmine.arrayContaining(['Data saved!'])); }); 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 78588d140f..345c455ac6 100644 --- a/e2e/paths/client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/client-module/02_edit_basic_data.spec.js @@ -6,288 +6,242 @@ describe('Client Edit basicData path', () => { describe('as employee', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); + .waitForLogin('employee'); }); - it('should click on the Clients button of the top bar menu', done => { - return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/index'); - done(); - }).catch(done.fail); + 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'); }); - it('should search for the user Bruce Wayne', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Bruce Wayne') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + it('should search for the user Bruce Wayne', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Bruce Wayne') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countElement(selectors.clientsIndex.searchResult); + + expect(resultCount).toEqual(1); }); - it('should click on the search result to access to the client summary', done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Wayne') - .waitToClick(selectors.clientsIndex.searchResult) - .waitForURL('summary') - .url() - .then(url => { - expect(url).toContain('summary'); - done(); - }).catch(done.fail); + it('should click on the search result to access to the client summary', async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Wayne') + .waitToClick(selectors.clientsIndex.searchResult) + .waitForURL('summary') + .url(); + + expect(url).toContain('summary'); }); - it('should not be able to change the salesPerson', done => { - return nightmare - .click(selectors.clientBasicData.basicDataButton) - .wait(selectors.clientBasicData.nameInput) - .evaluate(selector => { - return document.querySelector(selector).disabled; - }, selectors.clientBasicData.salesPersonInput) - .then(value => { - expect(value).toBeTruthy(); - done(); - }).catch(done.fail); + it('should not be able to change the salesPerson', async () => { + const result = await nightmare + .click(selectors.clientBasicData.basicDataButton) + .wait(selectors.clientBasicData.nameInput) + .evaluate((selector) => { + return document.querySelector(selector).disabled; + }, selectors.clientBasicData.salesPersonInput); + + expect(result).toBeTruthy(); }); - it('should edit the client basic data but leave salesPerson untainted', done => { - return nightmare - .clearInput(selectors.clientBasicData.nameInput) - .type(selectors.clientBasicData.nameInput, 'Ptonomy Wallace') - .clearInput(selectors.clientBasicData.contactInput) - .type(selectors.clientBasicData.contactInput, 'David Haller') - .clearInput(selectors.clientBasicData.phoneInput) - .type(selectors.clientBasicData.phoneInput, '987654321') - .clearInput(selectors.clientBasicData.mobileInput) - .type(selectors.clientBasicData.mobileInput, '123456789') - .clearInput(selectors.clientBasicData.emailInput) - .type(selectors.clientBasicData.emailInput, 'PWallace@verdnatura.es') - .waitToClick(selectors.clientBasicData.channelInput) - .waitToClick(selectors.clientBasicData.channelRumorsOption) - .click(selectors.clientBasicData.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + it('should edit the client basic data but leave salesPerson untainted', async () => { + const result = await nightmare + .clearInput(selectors.clientBasicData.nameInput) + .type(selectors.clientBasicData.nameInput, 'Ptonomy Wallace') + .clearInput(selectors.clientBasicData.contactInput) + .type(selectors.clientBasicData.contactInput, 'David Haller') + .clearInput(selectors.clientBasicData.phoneInput) + .type(selectors.clientBasicData.phoneInput, '987654321') + .clearInput(selectors.clientBasicData.mobileInput) + .type(selectors.clientBasicData.mobileInput, '123456789') + .clearInput(selectors.clientBasicData.emailInput) + .type(selectors.clientBasicData.emailInput, 'PWallace@verdnatura.es') + .waitToClick(selectors.clientBasicData.channelInput) + .waitToClick(selectors.clientBasicData.channelRumorsOption) + .click(selectors.clientBasicData.saveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it('should confirm the name have been edited', done => { - return nightmare - .click(selectors.clientFiscalData.fiscalDataButton) - .wait(selectors.clientFiscalData.addressInput) - .click(selectors.clientBasicData.basicDataButton) - .wait(selectors.clientBasicData.nameInput) - .getInputValue(selectors.clientBasicData.nameInput) - .then(result => { - expect(result).toEqual('Ptonomy Wallace'); - done(); - }).catch(done.fail); + it('should confirm the name have been edited', async () => { + const result = await nightmare + .click(selectors.clientFiscalData.fiscalDataButton) + .wait(selectors.clientFiscalData.addressInput) + .click(selectors.clientBasicData.basicDataButton) + .wait(selectors.clientBasicData.nameInput) + .getInputValue(selectors.clientBasicData.nameInput); + + expect(result).toEqual('Ptonomy Wallace'); }); - it('should confirm the contact name have been edited', done => { - return nightmare - .getInputValue(selectors.clientBasicData.contactInput) - .then(result => { - expect(result).toEqual('David Haller'); - done(); - }).catch(done.fail); + it('should confirm the contact name have been edited', async () => { + const result = await nightmare + .getInputValue(selectors.clientBasicData.contactInput); + + expect(result).toEqual('David Haller'); }); - it('should confirm the landline phone number have been added', done => { - return nightmare - .getInputValue(selectors.clientBasicData.phoneInput) - .then(result => { - expect(result).toEqual('987654321'); - done(); - }).catch(done.fail); + it('should confirm the landline phone number have been added', async () => { + const result = await nightmare + .getInputValue(selectors.clientBasicData.phoneInput); + + expect(result).toEqual('987654321'); }); - it('should confirm the mobile phone number have been added', done => { - return nightmare - .getInputValue(selectors.clientBasicData.mobileInput) - .then(result => { - expect(result).toEqual('123456789'); - done(); - }).catch(done.fail); + it('should confirm the mobile phone number have been added', async () => { + const result = await nightmare + .getInputValue(selectors.clientBasicData.mobileInput); + + expect(result).toEqual('123456789'); }); - it('should confirm the email have been edited', done => { - return nightmare - .getInputValue(selectors.clientBasicData.emailInput) - .then(result => { - expect(result).toEqual('PWallace@verdnatura.es'); - done(); - }).catch(done.fail); + it('should confirm the email have been edited', async () => { + const result = await nightmare + .getInputValue(selectors.clientBasicData.emailInput); + + expect(result).toEqual('PWallace@verdnatura.es'); }); - it('should confirm the channel have been selected', done => { - return nightmare - .getInputValue(selectors.clientBasicData.channelInput) - .then(result => { - expect(result).toEqual('Rumors on the streets'); - done(); - }).catch(done.fail); + it('should confirm the channel have been selected', async () => { + const result = await nightmare + .getInputValue(selectors.clientBasicData.channelInput); + + expect(result).toEqual('Rumors on the streets'); }); }); describe('as salesAssistanrt', () => { beforeAll(() => { return nightmare - .waitToClick(selectors.globalItems.logOutButton) - .waitForLogin('salesAssistant'); + .waitToClick(selectors.globalItems.logOutButton) + .waitForLogin('salesAssistant'); }); - it('should now click on the Clients button of the top bar menu', done => { - return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/index'); - done(); - }).catch(done.fail); + it('should now 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'); }); - it('should now search for the user Ptonomy Wallace', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Ptonomy Wallace') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + it('should now search for the user Ptonomy Wallace', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Ptonomy Wallace') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countElement(selectors.clientsIndex.searchResult); + + expect(resultCount).toEqual(1); }); - it('should now click on the search result to access to the client summary', done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Ptonomy Wallace') - .waitToClick(selectors.clientsIndex.searchResult) - .waitForURL('summary') - .url() - .then(url => { - expect(url).toContain('summary'); - done(); - }).catch(done.fail); + it('should now click on the search result to access to the client summary', async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Ptonomy Wallace') + .waitToClick(selectors.clientsIndex.searchResult) + .waitForURL('summary') + .url(); + + expect(url).toContain('summary'); }); - it('should be able to change the salesPerson', done => { - return nightmare - .click(selectors.clientBasicData.basicDataButton) - .wait(selectors.clientBasicData.nameInput) - .evaluate(selector => { - return document.querySelector(selector).disabled; - }, selectors.clientBasicData.salesPersonInput) - .then(value => { - expect(value).toBeFalsy(); - done(); - }).catch(done.fail); + it('should be able to change the salesPerson', async () => { + const result = await nightmare + .click(selectors.clientBasicData.basicDataButton) + .wait(selectors.clientBasicData.nameInput) + .evaluate((selector) => { + return document.querySelector(selector).disabled; + }, selectors.clientBasicData.salesPersonInput); + + expect(result).toBeFalsy(); }); - it('should edit the client basic data including salesPerson', done => { - return nightmare - .clearInput(selectors.clientBasicData.nameInput) - .type(selectors.clientBasicData.nameInput, 'Ororo Munroe') - .clearInput(selectors.clientBasicData.contactInput) - .type(selectors.clientBasicData.contactInput, 'Black Panther') - .clearInput(selectors.clientBasicData.phoneInput) - .type(selectors.clientBasicData.phoneInput, '123456789') - .clearInput(selectors.clientBasicData.mobileInput) - .type(selectors.clientBasicData.mobileInput, '987654321') - .clearInput(selectors.clientBasicData.emailInput) - .type(selectors.clientBasicData.emailInput, 'Storm@verdnatura.es') - .waitToClick(selectors.clientBasicData.salesPersonInput) - .waitToClick(selectors.clientBasicData.salesPersonOptionOne) - .waitToClick(selectors.clientBasicData.channelInput) - .waitToClick(selectors.clientBasicData.channelMetropolisOption) - .click(selectors.clientBasicData.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + it('should edit the client basic data including salesPerson', async () => { + const result = await nightmare + .clearInput(selectors.clientBasicData.nameInput) + .type(selectors.clientBasicData.nameInput, 'Ororo Munroe') + .clearInput(selectors.clientBasicData.contactInput) + .type(selectors.clientBasicData.contactInput, 'Black Panther') + .clearInput(selectors.clientBasicData.phoneInput) + .type(selectors.clientBasicData.phoneInput, '123456789') + .clearInput(selectors.clientBasicData.mobileInput) + .type(selectors.clientBasicData.mobileInput, '987654321') + .clearInput(selectors.clientBasicData.emailInput) + .type(selectors.clientBasicData.emailInput, 'Storm@verdnatura.es') + .waitToClick(selectors.clientBasicData.salesPersonInput) + .waitToClick(selectors.clientBasicData.salesPersonOptionOne) + .waitToClick(selectors.clientBasicData.channelInput) + .waitToClick(selectors.clientBasicData.channelMetropolisOption) + .click(selectors.clientBasicData.saveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it('should now confirm the name have been edited', done => { - return nightmare - .click(selectors.clientFiscalData.fiscalDataButton) - .wait(selectors.clientFiscalData.addressInput) - .click(selectors.clientBasicData.basicDataButton) - .wait(selectors.clientBasicData.nameInput) - .getInputValue(selectors.clientBasicData.nameInput) - .then(result => { - expect(result).toEqual('Ororo Munroe'); - done(); - }).catch(done.fail); + it('should now confirm the name have been edited', async () => { + const result = await nightmare + .click(selectors.clientFiscalData.fiscalDataButton) + .wait(selectors.clientFiscalData.addressInput) + .click(selectors.clientBasicData.basicDataButton) + .wait(selectors.clientBasicData.nameInput) + .getInputValue(selectors.clientBasicData.nameInput); + + expect(result).toEqual('Ororo Munroe'); }); - it('should now confirm the contact name have been edited', done => { - return nightmare - .getInputValue(selectors.clientBasicData.contactInput) - .then(result => { - expect(result).toEqual('Black Panther'); - done(); - }).catch(done.fail); + it('should now confirm the contact name have been edited', async () => { + const result = await nightmare + .getInputValue(selectors.clientBasicData.contactInput); + + expect(result).toEqual('Black Panther'); }); - it('should now confirm the landline phone number have been added', done => { - return nightmare - .getInputValue(selectors.clientBasicData.phoneInput) - .then(result => { - expect(result).toEqual('123456789'); - done(); - }).catch(done.fail); + it('should now confirm the landline phone number have been added', async () => { + const result = await nightmare + .getInputValue(selectors.clientBasicData.phoneInput); + + expect(result).toEqual('123456789'); }); - it('should now confirm the mobile phone number have been added', done => { - return nightmare - .getInputValue(selectors.clientBasicData.mobileInput) - .then(result => { - expect(result).toEqual('987654321'); - done(); - }).catch(done.fail); + it('should now confirm the mobile phone number have been added', async () => { + const result = await nightmare + .getInputValue(selectors.clientBasicData.mobileInput); + + expect(result).toEqual('987654321'); }); - it('should now confirm the email have been edited', done => { - return nightmare - .getInputValue(selectors.clientBasicData.emailInput) - .then(result => { - expect(result).toEqual('Storm@verdnatura.es'); - done(); - }).catch(done.fail); + it('should now confirm the email have been edited', async () => { + const result = await nightmare + .getInputValue(selectors.clientBasicData.emailInput); + + expect(result).toEqual('Storm@verdnatura.es'); }); - it('should confirm the sales person have been selected', done => { - return nightmare - .getInputValue(selectors.clientBasicData.salesPersonInput) - .then(result => { - expect(result).toEqual('accessory'); - done(); - }).catch(done.fail); + it('should confirm the sales person have been selected', async () => { + const result = await nightmare + .getInputValue(selectors.clientBasicData.salesPersonInput); + + expect(result).toEqual('accessory'); }); - it('should now confirm the channel have been selected', done => { - return nightmare - .getInputValue(selectors.clientBasicData.channelInput) - .then(result => { - expect(result).toEqual('Metropolis newspaper'); - done(); - }).catch(done.fail); + it('should now confirm the channel have been selected', async () => { + const result = await nightmare + .getInputValue(selectors.clientBasicData.channelInput); + + expect(result).toEqual('Metropolis newspaper'); }); }); }); diff --git a/e2e/paths/client-module/04_edit_pay_method.spec.js b/e2e/paths/client-module/04_edit_pay_method.spec.js index a91d20bc30..2daeb70ab8 100644 --- a/e2e/paths/client-module/04_edit_pay_method.spec.js +++ b/e2e/paths/client-module/04_edit_pay_method.spec.js @@ -7,134 +7,134 @@ describe('Client', () => { beforeAll(() => { nightmare - .waitForLogin('administrative'); + .waitForLogin('administrative'); }); - it('should click on the Clients button of the top bar menu', async() => { - let 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'); }); - it('should search for the user Bruce Banner', async() => { - let 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); }); - it(`should click on the search result to access to the client's pay method`, async() => { - let url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientPayMethod.payMethodButton) - .waitForURL('billing-data') - .url(); + it(`should click on the search result to access to the client's pay method`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientPayMethod.payMethodButton) + .waitForURL('billing-data') + .url(); expect(url).toContain('billing-data'); }); - it(`should attempt to edit the Pay method without an IBAN but fail`, async() => { - let snackbarMessage = await nightmare - .waitToClick(selectors.clientPayMethod.payMethodInput) - .waitToClick(selectors.clientPayMethod.payMethodIBANOption) - .waitForTextInInput(selectors.clientPayMethod.payMethodInput, 'PayMethod with IBAN') - .clearInput(selectors.clientPayMethod.dueDayInput) - .type(selectors.clientPayMethod.dueDayInput, '60') - .waitForTextInInput(selectors.clientPayMethod.dueDayInput, '60') - .waitToClick(selectors.clientPayMethod.receivedCoreLCRCheckbox) - .waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox) - .waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox) - .waitToClick(selectors.clientPayMethod.saveButton) - .waitForLastSnackbar(); + it(`should attempt to edit the Pay method without an IBAN but fail`, async () => { + const snackbarMessage = await nightmare + .waitToClick(selectors.clientPayMethod.payMethodInput) + .waitToClick(selectors.clientPayMethod.payMethodIBANOption) + .waitForTextInInput(selectors.clientPayMethod.payMethodInput, 'PayMethod with IBAN') + .clearInput(selectors.clientPayMethod.dueDayInput) + .type(selectors.clientPayMethod.dueDayInput, '60') + .waitForTextInInput(selectors.clientPayMethod.dueDayInput, '60') + .waitToClick(selectors.clientPayMethod.receivedCoreLCRCheckbox) + .waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox) + .waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox) + .waitToClick(selectors.clientPayMethod.saveButton) + .waitForLastSnackbar(); expect(snackbarMessage).toEqual('That payment method requires an IBAN'); }); - it(`should add the IBAN but fail as it requires a BIC code`, async() => { - let snackbarMessage = await nightmare - .clearInput(selectors.clientPayMethod.IBANInput) - .type(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') - .waitForTextInInput(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') - .waitToClick(selectors.clientPayMethod.saveButton) - .waitForLastSnackbar(); + it(`should add the IBAN but fail as it requires a BIC code`, async () => { + const snackbarMessage = await nightmare + .clearInput(selectors.clientPayMethod.IBANInput) + .type(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') + .waitForTextInInput(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') + .waitToClick(selectors.clientPayMethod.saveButton) + .waitForLastSnackbar(); expect(snackbarMessage).toEqual('That payment method requires a BIC'); }); - it(`should create a new BIC code`, async() => { - let newcode = await nightmare - .click(selectors.clientPayMethod.newBankEntityButton) - .type(selectors.clientPayMethod.newBankEntityName, 'Gotham City Banks') - .type(selectors.clientPayMethod.newBankEntityBIC, 'GTHMCT') - .click(selectors.clientPayMethod.acceptBankEntityButton) - .getInputValue(selectors.clientPayMethod.swiftBicInput); + it(`should create a new BIC code`, async () => { + const newcode = await nightmare + .click(selectors.clientPayMethod.newBankEntityButton) + .type(selectors.clientPayMethod.newBankEntityName, 'Gotham City Banks') + .type(selectors.clientPayMethod.newBankEntityBIC, 'GTHMCT') + .click(selectors.clientPayMethod.acceptBankEntityButton) + .getInputValue(selectors.clientPayMethod.swiftBicInput); expect(newcode).toEqual(''); }); - it(`should confirm the IBAN pay method is sucessfully saved`, async() => { - let payMethod = await nightmare - .getInputValue(selectors.clientPayMethod.payMethodInput); + it(`should confirm the IBAN pay method is sucessfully saved`, async () => { + const payMethod = await nightmare + .getInputValue(selectors.clientPayMethod.payMethodInput); expect(payMethod).toEqual('PayMethod with IBAN'); }); - it('should confirm the due day have been edited', async() => { - let dueDate = await nightmare - .getInputValue(selectors.clientPayMethod.dueDayInput); + it('should confirm the due day have been edited', async () => { + const dueDate = await nightmare + .getInputValue(selectors.clientPayMethod.dueDayInput); expect(dueDate).toEqual('60'); }); - it('should confirm the IBAN was saved', async() => { - let IBAN = await nightmare - .waitProperty(selectors.clientPayMethod.IBANInput, 'value') - .getProperty(selectors.clientPayMethod.IBANInput, 'value'); + it('should confirm the IBAN was saved', async () => { + const IBAN = await nightmare + .waitProperty(selectors.clientPayMethod.IBANInput, 'value') + .getProperty(selectors.clientPayMethod.IBANInput, 'value'); expect(IBAN).toEqual('ES91 2100 0418 4502 0005 1332'); }); - it('should confirm the swift / BIC code was saved', async() => { - let code = await nightmare - .waitProperty(selectors.clientPayMethod.swiftBicInput, 'value') - .getProperty(selectors.clientPayMethod.swiftBicInput, 'value'); + it('should confirm the swift / BIC code was saved', async () => { + const code = await nightmare + .waitProperty(selectors.clientPayMethod.swiftBicInput, 'value') + .getProperty(selectors.clientPayMethod.swiftBicInput, 'value'); expect(code).toEqual('GTHMCT'); }); - it('should confirm Received LCR checkbox is checked', async() => { - let checkedBox = await nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientPayMethod.receivedCoreLCRCheckbox); + it('should confirm Received LCR checkbox is checked', async () => { + const checkedBox = await nightmare + .evaluate((selector) => { + return document.querySelector(selector).checked; + }, selectors.clientPayMethod.receivedCoreLCRCheckbox); expect(checkedBox).toBeTruthy(); }); - it('should confirm Received core VNL checkbox is unchecked', async() => { - let checkedBox = await nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientPayMethod.receivedCoreVNLCheckbox); + it('should confirm Received core VNL checkbox is unchecked', async () => { + const checkedBox = await nightmare + .evaluate((selector) => { + return document.querySelector(selector).checked; + }, selectors.clientPayMethod.receivedCoreVNLCheckbox); expect(checkedBox).toBeFalsy(); }); - it('should confirm Received B2B VNL checkbox is unchecked', async() => { - let checkedBox = await nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientPayMethod.receivedB2BVNLCheckbox); + it('should confirm Received B2B VNL checkbox is unchecked', async () => { + const checkedBox = await nightmare + .evaluate((selector) => { + return document.querySelector(selector).checked; + }, selectors.clientPayMethod.receivedB2BVNLCheckbox); expect(checkedBox).toBeFalsy(); }); diff --git a/e2e/paths/client-module/05_add_address.spec.js b/e2e/paths/client-module/05_add_address.spec.js index 32b1e595a7..db4e46aac5 100644 --- a/e2e/paths/client-module/05_add_address.spec.js +++ b/e2e/paths/client-module/05_add_address.spec.js @@ -7,156 +7,132 @@ describe('Client', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); + .waitForLogin('employee'); }); - it('should click on the Clients button of the top bar menu', done => { - return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/index'); - done(); - }).catch(done.fail); + 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'); }); - it('should search for the user Bruce Banner', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + 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); }); - it(`should click on the search result to access to the client addresses`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientAddresses.addressesButton) - .waitForURL('address/index') - .url() - .then(url => { - expect(url).toContain('address/index'); - done(); - }).catch(done.fail); + 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'); }); - it(`should click on the add new address button to access to the new address form`, done => { - return nightmare - .waitToClick(selectors.clientAddresses.createAddress) - .waitForURL('address/create') - .url() - .then(url => { - expect(url).toContain('address/create'); - done(); - }).catch(done.fail); + 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'); }); - it(`should return to the addreses section by clicking the cancel button`, done => { - return nightmare - .waitToClick(selectors.clientAddresses.cancelButton) - .waitForURL('address/index') - .url() - .then(url => { - expect(url).toContain('address/index'); - done(); - }).catch(done.fail); + 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'); }); - it(`should now click on the add new address button to access to the new address form`, done => { - return nightmare - .waitToClick(selectors.clientAddresses.createAddress) - .waitForURL('address/create') - .url() - .then(url => { - expect(url).toContain('address/create'); - done(); - }).catch(done.fail); + 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'); }); - it('should receive an error after clicking save button as consignee, street and town fields are empty', done => { - return 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() - .then(result => { - expect(result).toEqual('Some fields are invalid'); - done(); - }).catch(done.fail); + 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'); }); - it(`should create a new address with all it's data`, done => { - return 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() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + 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!'); }); - it(`should click on the addresses button confirm the new address exists and it's the default one`, done => { - return nightmare - .waitToClick(selectors.clientAddresses.addressesButton) - .wait(selectors.clientAddresses.defaultAddress) - .getInnerText(selectors.clientAddresses.defaultAddress) - .then(result => { - expect(result).toContain('320 Park Avenue New York'); - done(); - }).catch(done.fail); + 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'); }); - it(`should click on the make default icon of the second address then confirm it is the default one now`, done => { - return nightmare - .waitToClick(selectors.clientAddresses.secondMakeDefaultStar) - .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') - .getInnerText(selectors.clientAddresses.defaultAddress) - .then(result => { - expect(result).toContain('Somewhere in Thailand'); - done(); - }).catch(done.fail); + 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'); }); - it(`should click on the edit icon of the default address`, done => { - return nightmare - .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') - .waitToClick(selectors.clientAddresses.firstEditButton) - .waitForURL('/edit') - .url() - .then(result => { - expect(result).toContain('/edit'); - done(); - }).catch(done.fail); + 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'); }); - it(`should click on the active checkbox and receive an error to save it because it is the default address`, done => { - return nightmare - .waitToClick(selectors.clientAddresses.activeCheckbox) - .waitToClick(selectors.clientAddresses.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('The default consignee can not be unchecked'); - done(); - }).catch(done.fail); + 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'); }); }); }); 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 e1f6a05dbf..3e915c7a43 100644 --- a/e2e/paths/client-module/06_add_address_notes.spec.js +++ b/e2e/paths/client-module/06_add_address_notes.spec.js @@ -6,98 +6,84 @@ describe('Client add address notes path', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); + .waitForLogin('employee'); }); - it('should click on the Clients button of the top bar menu', done => { - return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/index'); - done(); - }).catch(done.fail); + 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'); }); - it('should search for the user Petter Parker', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + 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); }); - it(`should click on the search result to access to the client addresses`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientAddresses.addressesButton) - .waitForURL('address/index') - .url() - .then(url => { - expect(url).toContain('address/index'); - done(); - }).catch(done.fail); + it(`should click on the search result to access to the client addresses`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientAddresses.addressesButton) + .waitForURL('address/index') + .url(); + + expect(url).toContain('address/index'); }); - it(`should click on the edit icon of the default address`, done => { - return nightmare - .waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street') - .waitToClick(selectors.clientAddresses.firstEditButton) - .waitForURL('/edit') - .url() - .then(result => { - expect(result).toContain('/edit'); - done(); - }).catch(done.fail); + it(`should click on the edit icon of the default address`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street') + .waitToClick(selectors.clientAddresses.firstEditButton) + .waitForURL('/edit') + .url(); + + expect(url).toContain('/edit'); }); - it('should not save a description without observation type', done => { - return nightmare - .waitToClick(selectors.clientAddresses.addObservationButton) - .wait(selectors.clientAddresses.firstObservationDescriptionInput) - .type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description') - .waitToClick(selectors.clientAddresses.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Observation type cannot be blank'); - done(); - }).catch(done.fail); + it('should not save a description without observation type', async () => { + const result = await nightmare + .waitToClick(selectors.clientAddresses.addObservationButton) + .wait(selectors.clientAddresses.firstObservationDescriptionInput) + .type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description') + .waitToClick(selectors.clientAddresses.saveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Observation type cannot be blank'); }); - it('should not save an observation type without description', done => { - return nightmare - .clearInput(selectors.clientAddresses.firstObservationDescriptionInput) - .waitToClick(selectors.clientAddresses.firstObservationTypeSelect) - .waitToClick(selectors.clientAddresses.firstObservationTypeSelectOptionOne) - .waitToClick(selectors.clientAddresses.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Some fields are invalid'); - done(); - }).catch(done.fail); + it('should not save an observation type without description', async () => { + const result = await nightmare + .clearInput(selectors.clientAddresses.firstObservationDescriptionInput) + .waitToClick(selectors.clientAddresses.firstObservationTypeSelect) + .waitToClick(selectors.clientAddresses.firstObservationTypeSelectOptionOne) + .waitToClick(selectors.clientAddresses.saveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Some fields are invalid'); }); - it('should create two new observations', done => { - return nightmare - .type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description') - .waitToClick(selectors.clientAddresses.addObservationButton) - .waitToClick(selectors.clientAddresses.secondObservationTypeSelect) - .waitToClick(selectors.clientAddresses.secondObservationTypeSelectOptionTwo) - .type(selectors.clientAddresses.secondObservationDescriptionInput, 'second description') - .waitToClick(selectors.clientAddresses.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + it('should create two new observations', async () => { + const result = await nightmare + .type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description') + .waitToClick(selectors.clientAddresses.addObservationButton) + .waitToClick(selectors.clientAddresses.secondObservationTypeSelect) + .waitToClick(selectors.clientAddresses.secondObservationTypeSelectOptionTwo) + .type(selectors.clientAddresses.secondObservationDescriptionInput, 'second description') + .waitToClick(selectors.clientAddresses.saveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); }); 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 325ab04230..5559cd5a24 100644 --- a/e2e/paths/client-module/07_edit_web_access.spec.js +++ b/e2e/paths/client-module/07_edit_web_access.spec.js @@ -7,83 +7,71 @@ describe('Client', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); + .waitForLogin('employee'); }); - it('should click on the Clients button of the top bar menu', done => { - return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/index'); - done(); - }).catch(done.fail); + 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'); }); - it('should search for the user Bruce Banner', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + 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); }); - it(`should click on the search result to access to the client's web access`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientWebAccess.webAccessButton) - .waitForURL('web-access') - .url() - .then(url => { - expect(url).toContain('web-access'); - done(); - }).catch(done.fail); + 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.clientWebAccess.webAccessButton) + .waitForURL('web-access') + .url(); + + expect(url).toContain('web-access'); }); - it(`should uncheck the Enable web access checkbox and update the name`, done => { - return nightmare - .waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox) - .clearInput(selectors.clientWebAccess.userNameInput) - .type(selectors.clientWebAccess.userNameInput, 'Hulk') - .waitToClick(selectors.clientWebAccess.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + 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!'); }); - it('should confirm web access is now unchecked', done => { - return nightmare - .waitToClick(selectors.clientBasicData.basicDataButton) - .wait(selectors.clientBasicData.nameInput) - .waitToClick(selectors.clientWebAccess.webAccessButton) - .wait(selectors.clientWebAccess.enableWebAccessCheckbox) - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientWebAccess.enableWebAccessCheckbox) - .then(value => { - expect(value).toBeFalsy(); - done(); - }).catch(done.fail); + it('should confirm web access is now unchecked', async () => { + const result = await nightmare + .waitToClick(selectors.clientBasicData.basicDataButton) + .wait(selectors.clientBasicData.nameInput) + .waitToClick(selectors.clientWebAccess.webAccessButton) + .wait(selectors.clientWebAccess.enableWebAccessCheckbox) + .evaluate((selector) => { + return document.querySelector(selector).checked; + }, selectors.clientWebAccess.enableWebAccessCheckbox); + + expect(result).toBeFalsy(); }); - it('should confirm web access name have been updated', done => { - return nightmare - .getInputValue(selectors.clientWebAccess.userNameInput) - .then(result => { - expect(result).toEqual('Hulk'); - done(); - }).catch(done.fail); + it('should confirm web access name have been updated', async () => { + const result = await nightmare + .getInputValue(selectors.clientWebAccess.userNameInput); + + 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 4c4466edaa..2c0fceaa00 100644 --- a/e2e/paths/client-module/08_add_notes.spec.js +++ b/e2e/paths/client-module/08_add_notes.spec.js @@ -7,78 +7,66 @@ describe('Client', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); + .waitForLogin('employee'); }); - it('should click on the Clients button of the top bar menu', done => { - return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/index'); - done(); - }).catch(done.fail); + 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'); }); - it('should search for the user Bruce Banner', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + 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); }); - it(`should click on the search result to access to the client's notes`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientNotes.notesButton) - .waitForURL('note/index') - .url() - .then(url => { - expect(url).toContain('note/index'); - done(); - }).catch(done.fail); + 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'); }); - it(`should click on the add note button`, done => { - return nightmare - .waitToClick(selectors.clientNotes.addNoteFloatButton) - .waitForURL('/note/create') - .url() - .then(url => { - expect(url).toContain('/note/create'); - done(); - }).catch(done.fail); + 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'); }); - it(`should create a note`, done => { - return nightmare - .type(selectors.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am') - .click(selectors.clientNotes.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + 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!'); }); - it('should confirm the note was created', done => { - return nightmare - .wait(selectors.clientNotes.firstNoteText) - .getInnerText(selectors.clientNotes.firstNoteText) - .then(value => { - expect(value).toEqual('Meeting with Black Widow 21st 9am'); - done(); - }).catch(done.fail); + 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'); }); }); }); diff --git a/e2e/paths/client-module/09_add_credit.spec.js b/e2e/paths/client-module/09_add_credit.spec.js index a672501200..e9518525f2 100644 --- a/e2e/paths/client-module/09_add_credit.spec.js +++ b/e2e/paths/client-module/09_add_credit.spec.js @@ -7,80 +7,68 @@ describe('Client', () => { beforeAll(() => { return nightmare - .waitForLogin('salesAssistant'); + .waitForLogin('salesAssistant'); }); - it('should click on the Clients button of the top bar menu', done => { - return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/index'); - done(); - }).catch(done.fail); + 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'); }); - it('should search for the user Ororo Munroe', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Ororo Munroe') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + 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); }); - it(`should click on the search result to access to the client's credit`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Ororo Munroe') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientCredit.creditButton) - .waitForURL('credit/index') - .url() - .then(url => { - expect(url).toContain('credit/index'); - done(); - }).catch(done.fail); + 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'); }); - it(`should click on the add credit button`, done => { - return nightmare - .waitToClick(selectors.clientCredit.addCreditFloatButton) - .waitForURL('/credit/create') - .url() - .then(url => { - expect(url).toContain('/credit/create'); - done(); - }).catch(done.fail); + 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'); }); - it(`should edit the credit`, done => { - return nightmare - .clearInput(selectors.clientCredit.creditInput) - .type(selectors.clientCredit.creditInput, 999) - .click(selectors.clientCredit.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + 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!'); }); - it('should confirm the credit was updated', done => { - return nightmare - .wait(selectors.clientCredit.firstCreditText) - .getInnerText(selectors.clientCredit.firstCreditText) - .then(value => { - expect(value).toContain(999); - expect(value).toContain('salesAssistant'); - done(); - }).catch(done.fail); + 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'); }); }); }); diff --git a/e2e/paths/client-module/10_add_greuge.spec.js b/e2e/paths/client-module/10_add_greuge.spec.js index a348008ce6..430dd38c27 100644 --- a/e2e/paths/client-module/10_add_greuge.spec.js +++ b/e2e/paths/client-module/10_add_greuge.spec.js @@ -7,94 +7,80 @@ describe('Client', () => { beforeAll(() => { return nightmare - .waitForLogin('salesAssistant'); + .waitForLogin('salesAssistant'); }); - it('should click on the Clients button of the top bar menu', done => { - return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/index'); - done(); - }).catch(done.fail); + 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'); }); - it('should search for the user Petter Parker', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + 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); }); - it(`should click on the search result to access to the client's greuge`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientGreuge.greugeButton) - .waitForURL('greuge/index') - .url() - .then(url => { - expect(url).toContain('greuge/index'); - done(); - }).catch(done.fail); + 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'); }); - it(`should click on the add greuge button`, done => { - return nightmare - .waitToClick(selectors.clientGreuge.addGreugeFloatButton) - .waitForURL('greuge/create') - .url() - .then(url => { - expect(url).toContain('greuge/create'); - done(); - }).catch(done.fail); + 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'); }); - it(`should receive an error if all fields are empty but date and type on submit`, done => { - return nightmare - .waitToClick(selectors.clientGreuge.typeInput) - .waitToClick(selectors.clientGreuge.typeSecondOption) - .click(selectors.clientGreuge.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Some fields are invalid'); - done(); - }).catch(done.fail); + 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'); }); - it(`should create a new greuge with all its data`, done => { - return nightmare - .type(selectors.clientGreuge.amountInput, 999) - .waitForTextInInput(selectors.clientGreuge.amountInput, '999') - .type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!') - .click(selectors.clientGreuge.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + 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!'); }); - it('should confirm the greuge was added to the list', done => { - return nightmare - .wait(selectors.clientGreuge.firstGreugeText) - .getInnerText(selectors.clientGreuge.firstGreugeText) - .then(value => { - expect(value).toContain(999); - expect(value).toContain('new armor for Batman!'); - expect(value).toContain('Diff'); - done(); - }).catch(done.fail); + 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'); }); }); }); diff --git a/e2e/paths/client-module/11_mandate.spec.js b/e2e/paths/client-module/11_mandate.spec.js index 1c1b3875ae..c036c0f473 100644 --- a/e2e/paths/client-module/11_mandate.spec.js +++ b/e2e/paths/client-module/11_mandate.spec.js @@ -7,58 +7,50 @@ describe('Client', () => { beforeAll(() => { return nightmare - .waitForLogin('salesPerson'); + .waitForLogin('salesPerson'); }); - it('should click on the Clients button of the top bar menu', done => { - return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/client/index'); - done(); - }).catch(done.fail); + 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'); }); - it('should search for the user Petter Parker', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + 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); }); - it(`should click on the search result to access to the client's mandate`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientMandate.mandateButton) - .waitForURL('mandate') - .url() - .then(url => { - expect(url).toContain('mandate'); - done(); - }).catch(done.fail); + 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.clientMandate.mandateButton) + .waitForURL('mandate') + .url(); + + expect(url).toContain('mandate'); }); - it('should confirm the client has a mandate of the CORE type', done => { - return nightmare - .wait(selectors.clientMandate.firstMandateText) - .getInnerText(selectors.clientMandate.firstMandateText) - .then(value => { - expect(value).toContain('1'); - expect(value).toContain('VNL'); - expect(value).toContain('CORE'); - done(); - }).catch(done.fail); + 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'); }); }); }); 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 15e87811a9..ecd5c95025 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 @@ -7,147 +7,123 @@ describe('Item', () => { beforeAll(() => { return nightmare - .waitForLogin('buyer'); + .waitForLogin('buyer'); }); - it('should access to the items index by clicking the items button', done => { - return nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/item/index'); - done(); - }).catch(done.fail); + 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 Gem of Mind', done => { - return 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) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + 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); }); - it(`should click on the search result to access to the item basic data`, done => { - return nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Mind') - .waitToClick(selectors.itemsIndex.searchResult) - .waitToClick(selectors.itemBasicData.basicDataButton) - .waitForURL('data') - .url() - .then(url => { - expect(url).toContain('data'); - done(); - }).catch(done.fail); + 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'); }); - it(`should edit the item basic data`, done => { - return 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() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + 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!'); }); - it(`should confirm the item name was edited`, done => { - return nightmare - .click(selectors.itemNiches.nicheButton) - .wait(selectors.itemNiches.firstWarehouseDisabled) - .waitToClick(selectors.itemBasicData.basicDataButton) - .waitForTextInInput(selectors.itemBasicData.nameInput, 'Rose of Purity') - .getInputValue(selectors.itemBasicData.nameInput) - .then(result => { - expect(result).toEqual('Rose of Purity'); - done(); - }).catch(done.fail); + 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); + + expect(result).toEqual('Rose of Purity'); }); - it(`should confirm the item type was edited`, done => { - return nightmare - .getInputValue(selectors.itemBasicData.typeSelect) - .then(result => { - expect(result).toEqual('Crisantemo'); - done(); - }).catch(done.fail); + it(`should confirm the item type was edited`, async () => { + const result = await nightmare + .getInputValue(selectors.itemBasicData.typeSelect); + + expect(result).toEqual('Crisantemo'); }); - it(`should confirm the item intrastad was edited`, done => { - return nightmare - .getInputValue(selectors.itemBasicData.intrastatSelect) - .then(result => { - expect(result).toEqual('Coral y materiales similares'); - done(); - }).catch(done.fail); + it(`should confirm the item intrastad was edited`, async () => { + const result = await nightmare + .getInputValue(selectors.itemBasicData.intrastatSelect); + + expect(result).toEqual('Coral y materiales similares'); }); - it(`should confirm the item relevancy was edited`, done => { - return nightmare - .getInputValue(selectors.itemBasicData.relevancyInput) - .then(result => { - expect(result).toEqual('1'); - done(); - }).catch(done.fail); + it(`should confirm the item relevancy was edited`, async () => { + const result = await nightmare + .getInputValue(selectors.itemBasicData.relevancyInput); + + expect(result).toEqual('1'); }); - it(`should confirm the item origin was edited`, done => { - return nightmare - .getInputValue(selectors.itemBasicData.originSelect) - .then(result => { - expect(result).toEqual('Spain'); - done(); - }).catch(done.fail); + it(`should confirm the item origin was edited`, async () => { + const result = await nightmare + .getInputValue(selectors.itemBasicData.originSelect); + + expect(result).toEqual('Spain'); }); - it(`should confirm the item expence was edited`, done => { - return nightmare - .getInputValue(selectors.itemBasicData.expenceSelect) - .then(result => { - expect(result).toEqual('Adquisición mercancia Extracomunitaria'); - done(); - }).catch(done.fail); + it(`should confirm the item expence was edited`, async () => { + const result = await nightmare + .getInputValue(selectors.itemBasicData.expenceSelect); + + expect(result).toEqual('Adquisición mercancia Extracomunitaria'); }); - it(`should confirm the item long name was edited`, done => { - return nightmare - .getInputValue(selectors.itemBasicData.longNameInput) - .then(result => { - expect(result).toEqual('RS Rose of Purity'); - done(); - }).catch(done.fail); + it(`should confirm the item long name was edited`, async () => { + const result = await nightmare + .getInputValue(selectors.itemBasicData.longNameInput); + + expect(result).toEqual('RS Rose of Purity'); }); - it('should confirm isActive checkbox is unchecked', done => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.itemBasicData.isActiveCheckbox) - .then(value => { - expect(value).toBeFalsy(); - done(); - }).catch(done.fail); + 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(); }); }); }); 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 347c1cc9a5..7f603de172 100644 --- a/e2e/paths/item-module/03_edit_item_tax.spec.js +++ b/e2e/paths/item-module/03_edit_item_tax.spec.js @@ -7,84 +7,78 @@ describe('Item', () => { beforeAll(() => { return nightmare - .waitForLogin('buyer'); + .waitForLogin('buyer'); }); - it('should access to the items index by clicking the items button', done => { - return nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/item/index'); - done(); - }).catch(done.fail); + 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 Gem of Time', done => { - return 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); + it('should search for the item Gem of Time', async () => { + const resultCount = 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); + + expect(resultCount).toEqual(1); }); - it(`should click on the search result to access to the item tax`, done => { - return nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') - .waitToClick(selectors.itemsIndex.searchResult) - .waitToClick(selectors.itemTax.taxButton) - .waitForURL('tax') - .url() - .then(url => { - expect(url).toContain('tax'); - done(); - }).catch(done.fail); + it(`should click on the search result to access to the item tax`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') + .waitToClick(selectors.itemsIndex.searchResult) + .waitToClick(selectors.itemTax.taxButton) + .waitForURL('tax') + .url(); + + expect(url).toContain('tax'); }); - it(`should add the item tax to all countries`, done => { - return nightmare - .waitToClick(selectors.itemTax.firstClassSelect) - .waitToClick(selectors.itemTax.firstClassSelectOptionTwo) - .waitToClick(selectors.itemTax.secondClassSelect) - .waitToClick(selectors.itemTax.secondClassSelectOptionOne) - .waitToClick(selectors.itemTax.thirdClassSelect) - .waitToClick(selectors.itemTax.thirdClassSelectOptionTwo) - .click(selectors.itemTax.submitTaxButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + it(`should add the item tax to all countries`, async () => { + const result = await nightmare + .waitToClick(selectors.itemTax.firstClassSelect) + .waitToClick(selectors.itemTax.firstClassSelectOptionTwo) + .waitToClick(selectors.itemTax.secondClassSelect) + .waitToClick(selectors.itemTax.secondClassSelectOptionOne) + .waitToClick(selectors.itemTax.thirdClassSelect) + .waitToClick(selectors.itemTax.thirdClassSelectOptionTwo) + .click(selectors.itemTax.submitTaxButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it(`should confirm the item tax class was edited`, done => { - return nightmare - .click(selectors.itemTags.tagsButton) - .wait(selectors.itemTags.firstTagDisabled) - .click(selectors.itemTax.taxButton) - .waitToClick(selectors.itemTax.taxButton) - .waitForTextInInput(selectors.itemTax.firstClassSelect, 'reduced') - .getInputValue(selectors.itemTax.firstClassSelect) - .then(result => { - expect(result).toEqual('Reduced VAT'); - return nightmare + it(`should confirm the first item tax class was edited`, async () => { + const firstVatType = await nightmare + .click(selectors.itemTags.tagsButton) + .wait(selectors.itemTags.firstTagDisabled) + .click(selectors.itemTax.taxButton) + .waitToClick(selectors.itemTax.taxButton) + .waitForTextInInput(selectors.itemTax.firstClassSelect, 'reduced') + .getInputValue(selectors.itemTax.firstClassSelect); + + expect(firstVatType).toEqual('Reduced VAT'); + }); + + it(`should confirm the second item tax class was edited`, async () => { + const secondVatType = await nightmare .getInputValue(selectors.itemTax.secondClassSelect); - }) - .then(result => { - expect(result).toEqual('General VAT'); - return nightmare + + expect(secondVatType).toEqual('General VAT'); + }); + + it(`should confirm the third item tax class was edited`, async () => { + const thirdVatType = await nightmare .getInputValue(selectors.itemTax.thirdClassSelect); - }) - .then(result => { - expect(result).toEqual('Reduced VAT'); - done(); - }).catch(done.fail); + + expect(thirdVatType).toEqual('Reduced VAT'); }); }); });