From 4ee656e4aaecdaad86f1a0b972dd6d7f0e04146c Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Fri, 28 Feb 2020 16:49:39 +0100 Subject: [PATCH 1/2] travel basic data and log e2e --- e2e/helpers/selectors.js | 15 +++ e2e/paths/02-client/08_add_notes.spec.js | 6 + .../10-travel/02_basic_data_and_log.spec.js | 103 ++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 e2e/paths/10-travel/02_basic_data_and_log.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 7e3e726e4..28263f2eb 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -783,6 +783,21 @@ export default { ticketOne: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-auto > vn-table > div > vn-tbody > vn-tr:nth-child(1)', ticketTwo: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-auto > vn-table > div > vn-tbody > vn-tr:nth-child(2)' }, + travelBasicDada: { + reference: 'vn-travel-basic-data vn-textfield[ng-model="$ctrl.travel.ref"]', + agency: 'vn-travel-basic-data vn-autocomplete[ng-model="$ctrl.travel.agencyModeFk"]', + shippingDate: 'vn-travel-basic-data vn-date-picker[ng-model="$ctrl.travel.shipped"]', + deliveryDate: 'vn-travel-basic-data vn-date-picker[ng-model="$ctrl.travel.landed"]', + outputWarehouse: 'vn-travel-basic-data vn-autocomplete[ng-model="$ctrl.travel.warehouseOutFk"]', + inputWarehouse: 'vn-travel-basic-data vn-autocomplete[ng-model="$ctrl.travel.warehouseInFk"]', + delivered: 'vn-travel-basic-data vn-check[ng-model="$ctrl.travel.isDelivered"]', + received: 'vn-travel-basic-data vn-check[ng-model="$ctrl.travel.isReceived"]', + save: 'vn-travel-basic-data vn-submit[label="Save"]', + undoChanges: 'vn-travel-basic-data vn-button[label="Undo changes"]' + }, + travelLog: { + firstLogFistTD: 'vn-travel-log vn-tbody > vn-tr > vn-td:nth-child(1) > div' + }, travelThermograph: { add: 'vn-travel-thermograph-index vn-float-button[icon="add"]', thermographID: 'vn-travel-thermograph-create vn-autocomplete[ng-model="$ctrl.dms.thermographId"]', diff --git a/e2e/paths/02-client/08_add_notes.spec.js b/e2e/paths/02-client/08_add_notes.spec.js index 8f1a9244d..b759cbd07 100644 --- a/e2e/paths/02-client/08_add_notes.spec.js +++ b/e2e/paths/02-client/08_add_notes.spec.js @@ -16,6 +16,12 @@ describe('Client Add notes path', () => { await browser.close(); }); + it(`should reach the notes index`, async() => { + let url = await page.expectURL('/note'); + + expect(url).toBe(true); + }); + it(`should click on the add note button`, async() => { await page.waitToClick(selectors.clientNotes.addNoteFloatButton); let url = await page.expectURL('/note/create'); diff --git a/e2e/paths/10-travel/02_basic_data_and_log.spec.js b/e2e/paths/10-travel/02_basic_data_and_log.spec.js new file mode 100644 index 000000000..491882f5e --- /dev/null +++ b/e2e/paths/10-travel/02_basic_data_and_log.spec.js @@ -0,0 +1,103 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Travel basic data path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('buyer', 'travel'); + await page.accessToSearchResult('3'); + await page.accessToSection('travel.card.basicData'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the thermograph section', async() => { + const result = await page.expectURL('/basic-data'); + + expect(result).toBe(true); + }); + + it('should set a wrong delivery date then receive an error on submit', async() => { + await page.datePicker(selectors.travelBasicDada.deliveryDate, -1, null); + await page.waitToClick(selectors.travelBasicDada.save); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('Landing cannot be lesser than shipment'); + }); + + it('should undo the changes', async() => { + await page.waitToClick(selectors.travelBasicDada.undoChanges); + await page.waitToClick(selectors.travelBasicDada.save); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('No changes to save'); + }); + + it('should now edit the whole form then save', async() => { + await page.clearInput(selectors.travelBasicDada.reference); + await page.write(selectors.travelBasicDada.reference, 'new reference!'); + await page.autocompleteSearch(selectors.travelBasicDada.agency, 'Quantum break device'); + await page.datePicker(selectors.travelBasicDada.shippingDate, -1, null); + await page.datePicker(selectors.travelBasicDada.deliveryDate, 1, null); + await page.autocompleteSearch(selectors.travelBasicDada.outputWarehouse, 'Warehouse Three'); + await page.autocompleteSearch(selectors.travelBasicDada.inputWarehouse, 'Warehouse Four'); + await page.waitToClick(selectors.travelBasicDada.delivered); + await page.waitToClick(selectors.travelBasicDada.received); + await page.waitToClick(selectors.travelBasicDada.save); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should reload the section and check the reference was saved', async() => { + await page.reloadSection('travel.card.basicData'); + const result = await page.waitToGetProperty(selectors.travelBasicDada.reference, 'value'); + + expect(result).toEqual('new reference!'); + }); + + it('should check the agency was saved', async() => { + const result = await page.waitToGetProperty(selectors.travelBasicDada.agency, 'value'); + + expect(result).toEqual('Quantum break device'); + }); + + it('should check the output warehouse date was saved', async() => { + const result = await page.waitToGetProperty(selectors.travelBasicDada.outputWarehouse, 'value'); + + expect(result).toEqual('Warehouse Three'); + }); + + it('should check the input warehouse date was saved', async() => { + const result = await page.waitToGetProperty(selectors.travelBasicDada.inputWarehouse, 'value'); + + expect(result).toEqual('Warehouse Four'); + }); + + it(`should check the delivered checkbox was saved even tho it doesn't make sense`, async() => { + await page.waitForClassPresent(selectors.travelBasicDada.delivered, 'checked'); + }); + + it(`should check the received checkbox was saved even tho it doesn't make sense`, async() => { + await page.waitForClassPresent(selectors.travelBasicDada.received, 'checked'); + }); + + it('should navigate to the travel logs', async() => { + await page.accessToSection('travel.card.log'); + const result = await page.expectURL('/log'); + + expect(result).toBe(true); + }); + + it('should check the 1st log contains details from the changes made', async() => { + const result = await page.waitToGetProperty(selectors.travelLog.firstLogFistTD, 'innerText'); + + expect(result).toContain('new reference!'); + }); +}); From 5ba602f5eb0b9cb8d3e2378ac414d3c4acbeaa5c Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Fri, 28 Feb 2020 16:58:21 +0100 Subject: [PATCH 2/2] small corrections --- e2e/helpers/selectors.js | 2 +- e2e/paths/10-travel/02_basic_data_and_log.spec.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 28263f2eb..46292a170 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -796,7 +796,7 @@ export default { undoChanges: 'vn-travel-basic-data vn-button[label="Undo changes"]' }, travelLog: { - firstLogFistTD: 'vn-travel-log vn-tbody > vn-tr > vn-td:nth-child(1) > div' + firstLogFirstTD: 'vn-travel-log vn-tbody > vn-tr > vn-td:nth-child(1) > div' }, travelThermograph: { add: 'vn-travel-thermograph-index vn-float-button[icon="add"]', diff --git a/e2e/paths/10-travel/02_basic_data_and_log.spec.js b/e2e/paths/10-travel/02_basic_data_and_log.spec.js index 491882f5e..20e0c0ac5 100644 --- a/e2e/paths/10-travel/02_basic_data_and_log.spec.js +++ b/e2e/paths/10-travel/02_basic_data_and_log.spec.js @@ -42,9 +42,7 @@ describe('Travel basic data path', () => { it('should now edit the whole form then save', async() => { await page.clearInput(selectors.travelBasicDada.reference); await page.write(selectors.travelBasicDada.reference, 'new reference!'); - await page.autocompleteSearch(selectors.travelBasicDada.agency, 'Quantum break device'); - await page.datePicker(selectors.travelBasicDada.shippingDate, -1, null); - await page.datePicker(selectors.travelBasicDada.deliveryDate, 1, null); + await page.autocompleteSearch(selectors.travelBasicDada.agency, 'Entanglement'); await page.autocompleteSearch(selectors.travelBasicDada.outputWarehouse, 'Warehouse Three'); await page.autocompleteSearch(selectors.travelBasicDada.inputWarehouse, 'Warehouse Four'); await page.waitToClick(selectors.travelBasicDada.delivered); @@ -65,7 +63,7 @@ describe('Travel basic data path', () => { it('should check the agency was saved', async() => { const result = await page.waitToGetProperty(selectors.travelBasicDada.agency, 'value'); - expect(result).toEqual('Quantum break device'); + expect(result).toEqual('Entanglement'); }); it('should check the output warehouse date was saved', async() => { @@ -96,7 +94,7 @@ describe('Travel basic data path', () => { }); it('should check the 1st log contains details from the changes made', async() => { - const result = await page.waitToGetProperty(selectors.travelLog.firstLogFistTD, 'innerText'); + const result = await page.waitToGetProperty(selectors.travelLog.firstLogFirstTD, 'innerText'); expect(result).toContain('new reference!'); });