diff --git a/e2e/paths/client-module/03_edit_fiscal_data.spec.js b/e2e/paths/client-module/03_edit_fiscal_data.spec.js index 5992589d2d..51116186d8 100644 --- a/e2e/paths/client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/client-module/03_edit_fiscal_data.spec.js @@ -6,409 +6,356 @@ describe('Client Edit fiscalData 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 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); }); // Confirms all addresses have EQtax false for future propagation test step 1 - it(`should click on the search result to access to the client's addresses`, () => { - 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'); - }); + it(`should click on the search result to access to the client's 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'); }); // Confirms all addresses have EQtax false for future propagation test step 2 - it(`should click on the 1st edit icon to check EQtax isnt checked`, () => { - return nightmare - .waitToClick(selectors.clientAddresses.firstEditButton) - .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientAddresses.equalizationTaxCheckboxLabel) - .then(value => { - expect(value).toBeFalsy(); - }); + it(`should click on the 1st edit icon to check EQtax isnt checked`, async () => { + const result = await nightmare + .waitToClick(selectors.clientAddresses.firstEditButton) + .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientAddresses.equalizationTaxCheckboxLabel); + + expect(result).toBeFalsy(); }); // Confirms all addresses have EQtax false for future propagation test step 3 - it(`should go back to addresses then select the second one and confirm the EQtax isnt checked`, () => { - return nightmare - .waitToClick(selectors.clientAddresses.addressesButton) - .waitToClick(selectors.clientAddresses.secondEditButton) - .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientAddresses.equalizationTaxCheckboxLabel) - .then(value => { - expect(value).toBeFalsy(); - }); + it(`should go back to addresses then select the second one and confirm the EQtax isnt checked`, async () => { + const result = await nightmare + .waitToClick(selectors.clientAddresses.addressesButton) + .waitToClick(selectors.clientAddresses.secondEditButton) + .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientAddresses.equalizationTaxCheckboxLabel); + + expect(result).toBeFalsy(); }); - it(`should click on the fiscal data button`, () => { - return nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .url() - .then(url => { - expect(url).toContain('fiscal-data'); - }); + it(`should click on the fiscal data button`, async () => { + const url = await nightmare + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .url(); + + expect(url).toContain('fiscal-data'); }); - it('should not be able to edit the verified data checkbox', done => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).disabled; - }, selectors.clientFiscalData.verifiedDataCheckboxInput) - .then(value => { - expect(value).toBeTruthy(); - done(); - }).catch(done.fail); + it('should not be able to edit the verified data checkbox', async () => { + const result = await nightmare + .evaluate(selector => { + return document.querySelector(selector).disabled; + }, selectors.clientFiscalData.verifiedDataCheckboxInput); + + expect(result).toBeTruthy(); }); }); describe('as administrative', () => { beforeAll(() => { return nightmare - .waitForLogin('administrative'); + .waitForLogin('administrative'); }); - 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 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 now 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 access to the client fiscal data`, () => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .url() - .then(url => { - expect(url).toContain('fiscal-data'); - }); + it(`should access to the client fiscal data`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .url(); + + expect(url).toContain('fiscal-data'); }); - it('should edit the clients fiscal data', done => { - return nightmare - .wait(selectors.clientFiscalData.socialNameInput) - .clearInput(selectors.clientFiscalData.socialNameInput) - .type(selectors.clientFiscalData.socialNameInput, 'SMASH!') - .waitForTextInInput(selectors.clientFiscalData.socialNameInput, 'SMASH!') - .clearInput(selectors.clientFiscalData.fiscalIdInput) - .type(selectors.clientFiscalData.fiscalIdInput, '94980061C') - .clearInput(selectors.clientFiscalData.addressInput) - .type(selectors.clientFiscalData.addressInput, 'Somewhere edited') - .clearInput(selectors.clientFiscalData.postcodeInput) - .type(selectors.clientFiscalData.postcodeInput, '12345') - .clearInput(selectors.clientFiscalData.cityInput) - .type(selectors.clientFiscalData.cityInput, 'N/A') - .waitToClick(selectors.clientFiscalData.countryInput) - .waitToClick(selectors.clientFiscalData.countryThirdOption) - .waitToClick(selectors.clientFiscalData.provinceInput) - .waitToClick(selectors.clientFiscalData.provinceFifthOption) - .waitToClick(selectors.clientFiscalData.activeCheckboxLabel) - .waitToClick(selectors.clientFiscalData.frozenCheckboxLabel) - .waitToClick(selectors.clientFiscalData.hasToInvoiceCheckboxLabel) - .waitToClick(selectors.clientFiscalData.viesCheckboxInput) - .waitToClick(selectors.clientFiscalData.invoiceByMailCheckboxLabel) - .waitToClick(selectors.clientFiscalData.invoiceByAddressCheckboxInput) - .waitToClick(selectors.clientFiscalData.equalizationTaxCheckboxLabel) - .waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput) - .click(selectors.clientFiscalData.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + it('should edit the clients fiscal data', async () => { + const result = await nightmare + .wait(selectors.clientFiscalData.socialNameInput) + .clearInput(selectors.clientFiscalData.socialNameInput) + .type(selectors.clientFiscalData.socialNameInput, 'SMASH!') + .waitForTextInInput(selectors.clientFiscalData.socialNameInput, 'SMASH!') + .clearInput(selectors.clientFiscalData.fiscalIdInput) + .type(selectors.clientFiscalData.fiscalIdInput, '94980061C') + .clearInput(selectors.clientFiscalData.addressInput) + .type(selectors.clientFiscalData.addressInput, 'Somewhere edited') + .clearInput(selectors.clientFiscalData.postcodeInput) + .type(selectors.clientFiscalData.postcodeInput, '12345') + .clearInput(selectors.clientFiscalData.cityInput) + .type(selectors.clientFiscalData.cityInput, 'N/A') + .waitToClick(selectors.clientFiscalData.countryInput) + .waitToClick(selectors.clientFiscalData.countryThirdOption) + .waitToClick(selectors.clientFiscalData.provinceInput) + .waitToClick(selectors.clientFiscalData.provinceFifthOption) + .waitToClick(selectors.clientFiscalData.activeCheckboxLabel) + .waitToClick(selectors.clientFiscalData.frozenCheckboxLabel) + .waitToClick(selectors.clientFiscalData.hasToInvoiceCheckboxLabel) + .waitToClick(selectors.clientFiscalData.viesCheckboxInput) + .waitToClick(selectors.clientFiscalData.invoiceByMailCheckboxLabel) + .waitToClick(selectors.clientFiscalData.invoiceByAddressCheckboxInput) + .waitToClick(selectors.clientFiscalData.equalizationTaxCheckboxLabel) + .waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput) + .click(selectors.clientFiscalData.saveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it('should propagate the Equalization tax', done => { - return nightmare - .waitToClick(selectors.clientFiscalData.acceptPropagationButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Equivalent tax spreaded'); - done(); - }).catch(done.fail); + it('should propagate the Equalization tax', async () => { + const result = await nightmare + .waitToClick(selectors.clientFiscalData.acceptPropagationButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Equivalent tax spreaded'); }); // confirm all addresses have now EQtax checked step 1 - it(`should click on the addresses button to access to the client's addresses`, () => { - return nightmare - .waitToClick(selectors.clientAddresses.addressesButton) - .waitForURL('/address/index') - .url() - .then(url => { - expect(url).toContain('/address/index'); - }); + it(`should click on the addresses button to access to the client's addresses`, async () => { + const url = await nightmare + .waitToClick(selectors.clientAddresses.addressesButton) + .waitForURL('/address/index') + .url(); + + expect(url).toContain('/address/index'); }); // confirm all addresses have now EQtax checked step 2 - it(`should click on the 1st edit icon to confirm EQtax is checked`, () => { - return nightmare - .waitToClick(selectors.clientAddresses.firstEditButton) - .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientAddresses.equalizationTaxCheckboxLabel) - .then(value => { - expect(value).toBeTruthy(); - }); + it(`should click on the 1st edit icon to confirm EQtax is checked`, async () => { + const result = await nightmare + .waitToClick(selectors.clientAddresses.firstEditButton) + .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientAddresses.equalizationTaxCheckboxLabel); + + expect(result).toBeTruthy(); }); // confirm all addresses have now EQtax checked step 3 - it(`should go back to addresses then select the second one and confirm the EQtax is checked`, () => { - return nightmare - .waitToClick(selectors.clientAddresses.addressesButton) - .waitToClick(selectors.clientAddresses.secondEditButton) - .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientAddresses.equalizationTaxCheckboxLabel) - .then(value => { - expect(value).toBeTruthy(); - }); + it(`should go back to addresses then select the second one and confirm the EQtax is checked`, async () => { + const result = await nightmare + .waitToClick(selectors.clientAddresses.addressesButton) + .waitToClick(selectors.clientAddresses.secondEditButton) + .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientAddresses.equalizationTaxCheckboxLabel); + + expect(result).toBeTruthy(); }); - it('should navigate back to fiscal data to confirm its name have been edited', done => { - return nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .wait(selectors.clientFiscalData.socialNameInput) - .getInputValue(selectors.clientFiscalData.socialNameInput) - .then(result => { - expect(result).toEqual('SMASH!'); - done(); - }).catch(done.fail); + it('should navigate back to fiscal data to confirm its name have been edited', async () => { + const result = await nightmare + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .wait(selectors.clientFiscalData.socialNameInput) + .getInputValue(selectors.clientFiscalData.socialNameInput); + + expect(result).toEqual('SMASH!'); }); - it('should confirm the fiscal id have been edited', done => { - return nightmare - .getInputValue(selectors.clientFiscalData.fiscalIdInput) - .then(result => { - expect(result).toEqual('94980061C'); - done(); - }).catch(done.fail); + it('should confirm the fiscal id have been edited', async () => { + const result = await nightmare + .getInputValue(selectors.clientFiscalData.fiscalIdInput); + + expect(result).toEqual('94980061C'); }); - it('should confirm the address have been edited', done => { - return nightmare - .getInputValue(selectors.clientFiscalData.addressInput) - .then(result => { - expect(result).toEqual('Somewhere edited'); - done(); - }).catch(done.fail); + it('should confirm the address have been edited', async () => { + const result = await nightmare + .getInputValue(selectors.clientFiscalData.addressInput); + + expect(result).toEqual('Somewhere edited'); }); - it('should confirm the postcode have been edited', done => { - return nightmare - .getInputValue(selectors.clientFiscalData.postcodeInput) - .then(result => { - expect(result).toEqual('12345'); - done(); - }).catch(done.fail); + it('should confirm the postcode have been edited', async () => { + const result = await nightmare + .getInputValue(selectors.clientFiscalData.postcodeInput); + + expect(result).toEqual('12345'); }); - it('should confirm the city have been edited', done => { - return nightmare - .getInputValue(selectors.clientFiscalData.cityInput) - .then(result => { - expect(result).toEqual('N/A'); - done(); - }).catch(done.fail); + it('should confirm the city have been edited', async () => { + const result = await nightmare + .getInputValue(selectors.clientFiscalData.cityInput); + + expect(result).toEqual('N/A'); }); - it(`should confirm the country have been selected`, () => { - return nightmare - .getInputValue(selectors.clientFiscalData.countryInput) - .then(result => { - expect(result).toEqual('Francia'); - }); + it(`should confirm the country have been selected`, async () => { + const result = await nightmare + .getInputValue(selectors.clientFiscalData.countryInput); + + expect(result).toEqual('Francia'); }); - it(`should confirm the province have been selected`, () => { - return nightmare - .getInputValue(selectors.clientFiscalData.provinceInput) - .then(result => { - expect(result).toEqual('Province two'); - }); + it(`should confirm the province have been selected`, async () => { + const result = await nightmare + .getInputValue(selectors.clientFiscalData.provinceInput); + + expect(result).toEqual('Province two'); }); - it('should confirm active checkbox is unchecked', done => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.activeCheckboxLabel) - .then(value => { - expect(value).toBeFalsy(); - done(); - }).catch(done.fail); + it('should confirm active checkbox is unchecked', async () => { + const result = await nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.activeCheckboxLabel); + + expect(result).toBeFalsy(); }); - it('should confirm frozen checkbox is unchecked', done => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.frozenCheckboxLabel) - .then(value => { - expect(value).toBeFalsy(); - done(); - }).catch(done.fail); + it('should confirm frozen checkbox is unchecked', async () => { + const result = await nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.frozenCheckboxLabel); + + expect(result).toBeFalsy(); }); - it('should confirm Has to invoice checkbox is unchecked', done => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.hasToInvoiceCheckboxLabel) - .then(value => { - expect(value).toBeFalsy(); - done(); - }).catch(done.fail); + it('should confirm Has to invoice checkbox is unchecked', async () => { + const result = await nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.hasToInvoiceCheckboxLabel); + + expect(result).toBeFalsy(); }); - it('should confirm Vies checkbox is checked', done => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.viesCheckboxInput) - .then(value => { - expect(value).toBeTruthy(); - done(); - }).catch(done.fail); + it('should confirm Vies checkbox is checked', async () => { + const result = await nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.viesCheckboxInput); + + expect(result).toBeTruthy(); }); - it('should confirm Invoice by mail checkbox is unchecked', done => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.invoiceByMailCheckboxLabel) - .then(value => { - expect(value).toBeFalsy(); - done(); - }).catch(done.fail); + it('should confirm Invoice by mail checkbox is unchecked', async () => { + const result = await nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.invoiceByMailCheckboxLabel); + + expect(result).toBeFalsy(); }); - it('should confirm invoice by address checkbox is unchecked', done => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.invoiceByAddressCheckboxInput) - .then(value => { - expect(value).toBeFalsy(); - done(); - }).catch(done.fail); + it('should confirm invoice by address checkbox is unchecked', async () => { + const result = await nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.invoiceByAddressCheckboxInput); + + expect(result).toBeFalsy(); }); - it('should confirm Equalization tax checkbox is checked', done => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.equalizationTaxCheckboxLabel) - .then(value => { - expect(value).toBeTruthy(); - done(); - }).catch(done.fail); + it('should confirm Equalization tax checkbox is checked', async () => { + const result = await nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.equalizationTaxCheckboxLabel); + + expect(result).toBeTruthy(); }); - it('should confirm Verified data checkbox is checked', done => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.verifiedDataCheckboxInput) - .then(value => { - expect(value).toBeTruthy(); - done(); - }).catch(done.fail); + it('should confirm Verified data checkbox is checked', async () => { + const result = await nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.verifiedDataCheckboxInput); + + expect(result).toBeTruthy(); }); // confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 1 - it(`should click on the addresses button to access to the client's addresses`, () => { - return nightmare - .waitToClick(selectors.clientAddresses.addressesButton) - .waitForURL('/address/index') - .url() - .then(url => { - expect(url).toContain('/address/index'); - }); + it(`should click on the addresses button to access to the client's addresses`, async () => { + const url = await nightmare + .waitToClick(selectors.clientAddresses.addressesButton) + .waitForURL('/address/index') + .url(); + + expect(url).toContain('/address/index'); }); // confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 2 - it(`should click on the 1st edit icon to access the address details and uncheck EQtax checkbox`, () => { - return nightmare - .waitToClick(selectors.clientAddresses.firstEditButton) - .waitToClick(selectors.clientAddresses.equalizationTaxCheckboxLabel) - .click(selectors.clientAddresses.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - }); + it(`should click on the 1st edit icon to access the address details and uncheck EQtax checkbox`, async () => { + const result = await nightmare + .waitToClick(selectors.clientAddresses.firstEditButton) + .waitToClick(selectors.clientAddresses.equalizationTaxCheckboxLabel) + .click(selectors.clientAddresses.saveButton) + .waitForLastSnackbar() + .then(result => { + expect(result).toEqual('Data saved!'); + }); }); // confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 3 - it('should navigate back to fiscal data to confirm invoice by address is now checked', done => { - return nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .wait(selectors.clientFiscalData.invoiceByAddressCheckboxInput) - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.invoiceByAddressCheckboxInput) - .then(value => { - expect(value).toBeTruthy(); - done(); - }).catch(done.fail); + it('should navigate back to fiscal data to confirm invoice by address is now checked', async () => { + const result = await nightmare + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .wait(selectors.clientFiscalData.invoiceByAddressCheckboxInput) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.invoiceByAddressCheckboxInput); + + expect(result).toBeTruthy(); }); }); }); diff --git a/e2e/paths/item-module/01_item_summary.spec.js b/e2e/paths/item-module/01_item_summary.spec.js index 9032546cba..561c47712d 100644 --- a/e2e/paths/item-module/01_item_summary.spec.js +++ b/e2e/paths/item-module/01_item_summary.spec.js @@ -1,214 +1,212 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Item', () => { - describe('Summary path', () => { - const nightmare = createNightmare(); +describe('Item summary path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - nightmare - .waitForLogin('employee'); - }); + beforeAll(() => { + nightmare + .waitForLogin('employee'); + }); - 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 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); + 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); - expect(result).toEqual(1); - }); + expect(result).toEqual(1); + }); - it(`should click on the search result summary button to open the item summary popup`, async () => { - const result = 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); - }); + it(`should click on the search result summary button to open the item summary popup`, async () => { + const result = 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); + }); - expect(result).toBeTruthy(); - }); + expect(result).toBeTruthy(); + }); - it(`should check the item summary preview shows fields from basic data`, async () => { - const result = await nightmare - .waitForTextInElement(selectors.itemSummary.basicData, 'Name: Gem of Time') - .getInnerText(selectors.itemSummary.basicData); + it(`should check the item summary preview shows fields from basic data`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.itemSummary.basicData, 'Name: Gem of Time') + .getInnerText(selectors.itemSummary.basicData); - expect(result).toContain('Name: Gem of Time'); - }); + expect(result).toContain('Name: Gem of Time'); + }); - it(`should check the item summary preview shows fields from tags`, async () => { - const result = await nightmare - .waitForTextInElement(selectors.itemSummary.tags, 'Color: Yellow') - .getInnerText(selectors.itemSummary.tags); + it(`should check the item summary preview shows fields from tags`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.itemSummary.tags, 'Color: Yellow') + .getInnerText(selectors.itemSummary.tags); - expect(result).toContain('Color: Yellow'); - }); + expect(result).toContain('Color: Yellow'); + }); - it(`should check the item summary preview shows fields from niche`, async () => { - const result = await nightmare - .waitForTextInElement(selectors.itemSummary.niche, 'Warehouse One: A1') - .getInnerText(selectors.itemSummary.niche); + it(`should check the item summary preview shows fields from niche`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.itemSummary.niche, 'Warehouse One: A1') + .getInnerText(selectors.itemSummary.niche); - expect(result).toContain('Warehouse One: A1'); - }); + expect(result).toContain('Warehouse One: A1'); + }); - it(`should check the item summary preview shows fields from botanical`, async () => { - const result = await nightmare - .waitForTextInElement(selectors.itemSummary.botanical, 'Botanical: Hedera helix') - .getInnerText(selectors.itemSummary.botanical); + it(`should check the item summary preview shows fields from botanical`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.itemSummary.botanical, 'Botanical: Hedera helix') + .getInnerText(selectors.itemSummary.botanical); - expect(result).toContain('Botanical: Hedera helix'); - }); + expect(result).toContain('Botanical: Hedera helix'); + }); - it(`should check the item summary preview shows fields from barcode`, async () => { - const result = await nightmare - .waitForTextInElement(selectors.itemSummary.barcode, '1') - .getInnerText(selectors.itemSummary.barcode); + it(`should check the item summary preview shows fields from barcode`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.itemSummary.barcode, '1') + .getInnerText(selectors.itemSummary.barcode); - expect(result).toContain('1'); - }); + expect(result).toContain('1'); + }); - it(`should close the summary popup`, async () => { - const result = await nightmare - .waitToClick(selectors.itemsIndex.closeItemSummaryPreview) - .isVisible(selectors.itemSummary.basicData); + it(`should close the summary popup`, async () => { + const result = await nightmare + .waitToClick(selectors.itemsIndex.closeItemSummaryPreview) + .isVisible(selectors.itemSummary.basicData); - expect(result).toBeFalsy(); - }); + expect(result).toBeFalsy(); + }); - it('should search for the item Gem of Mind', async () => { - const result = await nightmare - .clearInput('body > vn-app > vn-vertical > vn-vertical > ui-view > vn-item-index > div > div > vn-card:nth-child(1) > div > vn-searchbar > form > vn-horizontal > vn-textfield > div > div > div.infix > input') - .click(selectors.itemsIndex.searchButton) - .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 result = await nightmare + .clearInput('body > vn-app > vn-vertical > vn-vertical > ui-view > vn-item-index > div > div > vn-card:nth-child(1) > div > vn-searchbar > form > vn-horizontal > vn-textfield > div > div > div.infix > input') + .click(selectors.itemsIndex.searchButton) + .type(selectors.itemsIndex.searchItemInput, 'Gem of Mind') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) + .countElement(selectors.itemsIndex.searchResult); - expect(result).toEqual(1); - }); + expect(result).toEqual(1); + }); - it(`should now click on the search result summary button to open the item summary popup`, async () => { - const result = 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); - }); + it(`should now click on the search result summary button to open the item summary popup`, async () => { + const result = 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); + }); - expect(result).toBeTruthy(); - }); + expect(result).toBeTruthy(); + }); - it(`should now check the item summary preview shows fields from basic data`, async () => { - const result = await nightmare - .waitForTextInElement(selectors.itemSummary.basicData, 'Name: Gem of Mind') - .getInnerText(selectors.itemSummary.basicData); + it(`should now check the item summary preview shows fields from basic data`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.itemSummary.basicData, 'Name: Gem of Mind') + .getInnerText(selectors.itemSummary.basicData); - expect(result).toContain('Name: Gem of Mind'); - }); + expect(result).toContain('Name: Gem of Mind'); + }); - it(`should now check the item summary preview shows fields from tags`, async () => { - const result = await nightmare - .waitForTextInElement(selectors.itemSummary.tags, 'Color: Red') - .getInnerText(selectors.itemSummary.tags); + it(`should now check the item summary preview shows fields from tags`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.itemSummary.tags, 'Color: Red') + .getInnerText(selectors.itemSummary.tags); - expect(result).toContain('Color: Red'); - }); + expect(result).toContain('Color: Red'); + }); - it(`should now check the item summary preview shows fields from niche`, async () => { - const result = await nightmare - .waitForTextInElement(selectors.itemSummary.niche, 'Warehouse One: A4') - .getInnerText(selectors.itemSummary.niche); + it(`should now check the item summary preview shows fields from niche`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.itemSummary.niche, 'Warehouse One: A4') + .getInnerText(selectors.itemSummary.niche); - expect(result).toContain('Warehouse One: A4'); - }); + expect(result).toContain('Warehouse One: A4'); + }); - it(`should now check the item summary preview shows fields from botanical`, async () => { - const result = await nightmare - .waitForTextInElement(selectors.itemSummary.botanical, 'Botanical: -') - .getInnerText(selectors.itemSummary.botanical); + it(`should now check the item summary preview shows fields from botanical`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.itemSummary.botanical, 'Botanical: -') + .getInnerText(selectors.itemSummary.botanical); - expect(result).toContain('Botanical: -'); - }); + expect(result).toContain('Botanical: -'); + }); - it(`should now check the item summary preview shows fields from barcode`, async () => { - const result = await nightmare - .waitForTextInElement(selectors.itemSummary.barcode, '4') - .getInnerText(selectors.itemSummary.barcode); + it(`should now check the item summary preview shows fields from barcode`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.itemSummary.barcode, '4') + .getInnerText(selectors.itemSummary.barcode); - expect(result).toContain('4'); - }); + expect(result).toContain('4'); + }); - it(`should now close the summary popup`, async () => { - const result = await nightmare - .waitToClick(selectors.itemsIndex.closeItemSummaryPreview) - .isVisible(selectors.itemSummary.basicData); + it(`should now close the summary popup`, async () => { + const result = await nightmare + .waitToClick(selectors.itemsIndex.closeItemSummaryPreview) + .isVisible(selectors.itemSummary.basicData); - expect(result).toBeFalsy(); - }); + expect(result).toBeFalsy(); + }); - it(`should navigate to the one of the items detailed section`, async () => { - const url = await nightmare - .waitToClick(selectors.itemsIndex.searchResult) - .waitForURL('summary') - .parsedUrl(); + it(`should navigate to the one of the items detailed section`, async () => { + const url = await nightmare + .waitToClick(selectors.itemsIndex.searchResult) + .waitForURL('summary') + .parsedUrl(); - expect(url.hash).toContain('summary'); - }); + expect(url.hash).toContain('summary'); + }); - it(`should check the item summary shows fields from basic data section`, async () => { - const result = await nightmare - .waitForTextInElement(selectors.itemSummary.basicData, 'Name: Gem of Mind') - .getInnerText(selectors.itemSummary.basicData); + it(`should check the item summary shows fields from basic data section`, async () => { + const result = await nightmare + .waitForTextInElement(selectors.itemSummary.basicData, 'Name: Gem of Mind') + .getInnerText(selectors.itemSummary.basicData); - expect(result).toContain('Name: Gem of Mind'); - }); + expect(result).toContain('Name: Gem of Mind'); + }); - it(`should check the item summary shows fields from tags section`, async () => { - const result = await nightmare - .getInnerText(selectors.itemSummary.tags); + it(`should check the item summary shows fields from tags section`, async () => { + const result = await nightmare + .getInnerText(selectors.itemSummary.tags); - expect(result).toContain('Color: Red'); - }); + expect(result).toContain('Color: Red'); + }); - it(`should check the item summary shows fields from niches section`, async () => { - const result = await nightmare - .getInnerText(selectors.itemSummary.niche); + it(`should check the item summary shows fields from niches section`, async () => { + const result = await nightmare + .getInnerText(selectors.itemSummary.niche); - expect(result).toContain('Warehouse One: A4'); - }); + expect(result).toContain('Warehouse One: A4'); + }); - it(`should check the item summary shows fields from botanical section`, async () => { - const result = await nightmare - .getInnerText(selectors.itemSummary.botanical); + it(`should check the item summary shows fields from botanical section`, async () => { + const result = await nightmare + .getInnerText(selectors.itemSummary.botanical); - expect(result).toContain('Botanical: -'); - }); + expect(result).toContain('Botanical: -'); + }); - it(`should check the item summary shows fields from barcodes section`, async () => { - const result = await nightmare - .getInnerText(selectors.itemSummary.barcode); + it(`should check the item summary shows fields from barcodes section`, async () => { + const result = await nightmare + .getInnerText(selectors.itemSummary.barcode); - expect(result).toContain('4'); - }); + expect(result).toContain('4'); }); }); 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 7f603de172..2e15ebbca0 100644 --- a/e2e/paths/item-module/03_edit_item_tax.spec.js +++ b/e2e/paths/item-module/03_edit_item_tax.spec.js @@ -1,84 +1,82 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Item', () => { - describe('Edit tax path', () => { - const nightmare = createNightmare(); +describe('Item edit tax path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare - .waitForLogin('buyer'); - }); + 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(); + 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 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); + 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); - }); + expect(resultCount).toEqual(1); + }); - 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(); + 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'); - }); + expect(url).toContain('tax'); + }); - 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(); + 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!'); - }); + expect(result).toEqual('Data saved!'); + }); - 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); + 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'); - }); + expect(firstVatType).toEqual('Reduced VAT'); + }); - it(`should confirm the second item tax class was edited`, async () => { - const secondVatType = await nightmare - .getInputValue(selectors.itemTax.secondClassSelect); + it(`should confirm the second item tax class was edited`, async () => { + const secondVatType = await nightmare + .getInputValue(selectors.itemTax.secondClassSelect); - expect(secondVatType).toEqual('General VAT'); - }); + expect(secondVatType).toEqual('General VAT'); + }); - it(`should confirm the third item tax class was edited`, async () => { - const thirdVatType = await nightmare - .getInputValue(selectors.itemTax.thirdClassSelect); + it(`should confirm the third item tax class was edited`, async () => { + const thirdVatType = await nightmare + .getInputValue(selectors.itemTax.thirdClassSelect); - expect(thirdVatType).toEqual('Reduced VAT'); - }); + expect(thirdVatType).toEqual('Reduced VAT'); }); }); 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 1128a114ae..89bf10c388 100644 --- a/e2e/paths/item-module/04_create_item_tags.spec.js +++ b/e2e/paths/item-module/04_create_item_tags.spec.js @@ -1,54 +1,47 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Item', () => { - describe('Create tags path', () => { - const nightmare = createNightmare(); +describe('Item create tags path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare + beforeAll(() => { + return 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 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) - .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 tags`, done => { - return nightmare + expect(resultCount).toEqual(1); + }); + + it(`should click on the search result to access to the item tags`, async () => { + const url = await nightmare .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') .waitToClick(selectors.itemsIndex.searchResult) .waitToClick(selectors.itemTags.tagsButton) .waitForURL('tags') - .url() - .then(url => { - expect(url).toContain('tags'); - done(); - }).catch(done.fail); - }); + .url(); - it(`should create a new tag and delete a former one`, done => { - return nightmare + expect(url).toContain('tags'); + }); + + it(`should create a new tag and delete a former one`, async () => { + const result = await nightmare .waitToClick(selectors.itemTags.firstRemoveTagButton) .waitToClick(selectors.itemTags.addItemTagButton) .waitToClick(selectors.itemTags.seventhTagSelect) @@ -57,69 +50,65 @@ describe('Item', () => { .clearInput(selectors.itemTags.seventhRelevancyInput) .type(selectors.itemTags.seventhRelevancyInput, '1') .click(selectors.itemTags.submitItemTagsButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); - }); + .waitForLastSnackbar(); - it(`should reload tags form to check that the changes are saved`, () => { - return nightmare + expect(result).toEqual('Data saved!'); + }); + + it(`should confirm the first row data is the expected one`, async () => { + let result = await nightmare .click(selectors.itemBasicData.basicDataButton) .wait(selectors.itemBasicData.nameInput) .click(selectors.itemTags.tagsButton) - .wait('vn-item-tags'); - }); + .wait('vn-item-tags') + .getProperty(selectors.itemTags.firstTagSelect, 'value'); - it(`should confirm the first row data is the expected one`, async() => { - let tag = await nightmare.getProperty(selectors.itemTags.firstTagSelect, 'value'); - let value = await nightmare.getProperty(selectors.itemTags.firstValueInput, 'value'); - let relevancy = await nightmare.getProperty(selectors.itemTags.firstRelevancyInput, 'value'); + expect(result).toEqual('Ancho de la base'); + result = await nightmare.getProperty(selectors.itemTags.firstValueInput, 'value'); - expect(tag).toEqual('Ancho de la base'); - expect(value).toEqual('50'); - expect(relevancy).toEqual('1'); - }); + expect(result).toEqual('50'); + result = await nightmare.getProperty(selectors.itemTags.firstRelevancyInput, 'value'); - it(`should confirm the second row data is the expected one`, async() => { - let tag = await nightmare.getProperty(selectors.itemTags.secondTagSelect, 'value'); - let value = await nightmare.getProperty(selectors.itemTags.secondValueInput, 'value'); - let relevancy = await nightmare.getProperty(selectors.itemTags.secondRelevancyInput, 'value'); + expect(result).toEqual('1'); + }); - expect(tag).toEqual('Variedad'); - expect(value).toEqual('Gem1'); - expect(relevancy).toEqual('2'); - }); + it(`should confirm the second row data is the expected one`, async () => { + let tag = await nightmare.getProperty(selectors.itemTags.secondTagSelect, 'value'); + let value = await nightmare.getProperty(selectors.itemTags.secondValueInput, 'value'); + let relevancy = await nightmare.getProperty(selectors.itemTags.secondRelevancyInput, 'value'); - it(`should confirm the second row data is the expected one`, async() => { - let tag = await nightmare.getProperty(selectors.itemTags.thirdTagSelect, 'value'); - let value = await nightmare.getProperty(selectors.itemTags.thirdValueInput, 'value'); - let relevancy = await nightmare.getProperty(selectors.itemTags.thirdRelevancyInput, 'value'); + expect(tag).toEqual('Variedad'); + expect(value).toEqual('Gem1'); + expect(relevancy).toEqual('2'); + }); - expect(tag).toEqual('Longitud(cm)'); - expect(value).toEqual('5'); - expect(relevancy).toEqual('3'); - }); + it(`should confirm the third row data is the expected one`, async () => { + let tag = await nightmare.getProperty(selectors.itemTags.thirdTagSelect, 'value'); + let value = await nightmare.getProperty(selectors.itemTags.thirdValueInput, 'value'); + let relevancy = await nightmare.getProperty(selectors.itemTags.thirdRelevancyInput, 'value'); - it(`should confirm the fourth row data is the expected one`, async() => { - let tag = await nightmare.getProperty(selectors.itemTags.fourthTagSelect, 'value'); - let value = await nightmare.getProperty(selectors.itemTags.fourthValueInput, 'value'); - let relevancy = await nightmare.getProperty(selectors.itemTags.fourthRelevancyInput, 'value'); + expect(tag).toEqual('Longitud(cm)'); + expect(value).toEqual('5'); + expect(relevancy).toEqual('3'); + }); - expect(tag).toEqual('Proveedor'); - expect(value).toEqual('Marvel1'); - expect(relevancy).toEqual('4'); - }); + it(`should confirm the fourth row data is the expected one`, async () => { + let tag = await nightmare.getProperty(selectors.itemTags.fourthTagSelect, 'value'); + let value = await nightmare.getProperty(selectors.itemTags.fourthValueInput, 'value'); + let relevancy = await nightmare.getProperty(selectors.itemTags.fourthRelevancyInput, 'value'); - it(`should confirm the fifth row data is the expected one`, async() => { - let tag = await nightmare.getProperty(selectors.itemTags.fifthTagSelect, 'value'); - let value = await nightmare.getProperty(selectors.itemTags.fifthValueInput, 'value'); - let relevancy = await nightmare.getProperty(selectors.itemTags.fifthRelevancyInput, 'value'); + expect(tag).toEqual('Proveedor'); + expect(value).toEqual('Marvel1'); + expect(relevancy).toEqual('4'); + }); - expect(tag).toEqual('Color'); - expect(value).toEqual('Yellow'); - expect(relevancy).toEqual('5'); - }); + it(`should confirm the fifth row data is the expected one`, async () => { + let tag = await nightmare.getProperty(selectors.itemTags.fifthTagSelect, 'value'); + let value = await nightmare.getProperty(selectors.itemTags.fifthValueInput, 'value'); + let relevancy = await nightmare.getProperty(selectors.itemTags.fifthRelevancyInput, 'value'); + + expect(tag).toEqual('Color'); + expect(value).toEqual('Yellow'); + expect(relevancy).toEqual('5'); }); }); 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 737550e05b..04fa0f3dbc 100644 --- a/e2e/paths/item-module/05_create_item_niche.spec.js +++ b/e2e/paths/item-module/05_create_item_niche.spec.js @@ -1,111 +1,93 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Item', () => { - describe('Create niche path', () => { - const nightmare = createNightmare(); +describe('Item create niche path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - return nightmare + beforeAll(() => { + return 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 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) - .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 niches`, done => { - return nightmare + expect(resultCount).toEqual(1); + }); + + it(`should click on the search result to access to the item niches`, async () => { + const url = await nightmare .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') .waitToClick(selectors.itemsIndex.searchResult) .waitToClick(selectors.itemNiches.nicheButton) .waitForURL('niche') - .url() - .then(url => { - expect(url).toContain('niche'); - done(); - }).catch(done.fail); - }); + .url(); - it(`should click create a new niche and delete a former one`, done => { - return nightmare + expect(url).toContain('niche'); + }); + + it(`should click create a new niche and delete a former one`, async () => { + const result = await nightmare .waitToClick(selectors.itemNiches.addNicheButton) .waitToClick(selectors.itemNiches.secondNicheRemoveButton) .waitToClick(selectors.itemNiches.thirdWarehouseSelect) .waitToClick(selectors.itemNiches.thirdWarehouseSelectFourthOption) .type(selectors.itemNiches.thirdCodeInput, 'A4') .click(selectors.itemNiches.submitNichesButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); - }); + .waitForLastSnackbar(); - it(`should confirm the first niche is the expected one`, done => { - return nightmare + expect(result).toEqual('Data saved!'); + }); + + it(`should confirm the first niche is the expected one`, async () => { + let result = await nightmare .click(selectors.itemBasicData.basicDataButton) .wait(selectors.itemBasicData.nameInput) .click(selectors.itemNiches.nicheButton) .waitForTextInInput(selectors.itemNiches.firstWarehouseSelect, 'Warehouse One') - .getInputValue(selectors.itemNiches.firstWarehouseSelect) - .then(result => { - expect(result).toEqual('Warehouse One'); - return nightmare - .getInputValue(selectors.itemNiches.firstCodeInput); - }) - .then(result => { - expect(result).toEqual('A1'); - done(); - }).catch(done.fail); - }); + .getInputValue(selectors.itemNiches.firstWarehouseSelect); - it(`should confirm the second niche is the expected one`, done => { - return nightmare - .getInputValue(selectors.itemNiches.secondWarehouseSelect) - .then(result => { - expect(result).toEqual('Warehouse Three'); - return nightmare - .getInputValue(selectors.itemNiches.secondCodeInput); - }) - .then(result => { - expect(result).toEqual('A3'); - done(); - }).catch(done.fail); - }); + expect(result).toEqual('Warehouse One'); + result = await nightmare + .getInputValue(selectors.itemNiches.firstCodeInput); - it(`should confirm the third niche is the expected one`, done => { - return nightmare - .getInputValue(selectors.itemNiches.thirdWarehouseSelect) - .then(result => { - expect(result).toEqual('Warehouse Two'); - return nightmare - .getInputValue(selectors.itemNiches.thirdCodeInput); - }) - .then(result => { - expect(result).toEqual('A4'); - done(); - }).catch(done.fail); - }); + expect(result).toEqual('A1'); + }); + + it(`should confirm the second niche is the expected one`, async () => { + let result = await nightmare + .getInputValue(selectors.itemNiches.secondWarehouseSelect); + + expect(result).toEqual('Warehouse Three'); + result = await nightmare + .getInputValue(selectors.itemNiches.secondCodeInput); + + + expect(result).toEqual('A3'); + }); + + it(`should confirm the third niche is the expected one`, async () => { + let result = await nightmare + .getInputValue(selectors.itemNiches.thirdWarehouseSelect); + + expect(result).toEqual('Warehouse Two'); + result = await nightmare + .getInputValue(selectors.itemNiches.thirdCodeInput); + + expect(result).toEqual('A4'); }); });