From 7dc8ae9dbcb81d6422baac4668fea527dbbdea7a Mon Sep 17 00:00:00 2001 From: carlosjr Date: Tue, 17 Nov 2020 16:52:19 +0100 Subject: [PATCH] e2e path for travel descriptor --- e2e/helpers/selectors.js | 9 ++++ e2e/paths/10-travel/03_descriptor.spec.js | 45 +++++++++++++++++++ .../travel/front/descriptor-menu/index.html | 1 + 3 files changed, 55 insertions(+) create mode 100644 e2e/paths/10-travel/03_descriptor.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 95ffca91e..f5f2c4050 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -815,6 +815,10 @@ 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)' }, + travelIndex: { + anySearchResult: 'vn-travel-index vn-tbody > a', + firstSearchResult: 'vn-travel-index vn-tbody > a:nth-child(1)' + }, 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"]', @@ -841,6 +845,11 @@ export default { createdThermograph: 'vn-travel-thermograph-index vn-tbody > vn-tr', upload: 'vn-travel-thermograph-create button[type=submit]' }, + travelDescriptor: { + filterByAgencyButton: 'vn-descriptor-content .quicklinks > div:nth-child(1) > vn-quick-link > a[vn-tooltip="All travels with current agency"]', + dotMenu: 'vn-travel-descriptor vn-icon-button[icon="more_vert"]', + dotMenuClone: '#clone' + }, zoneIndex: { searchResult: 'vn-zone-index a.vn-tr', }, diff --git a/e2e/paths/10-travel/03_descriptor.spec.js b/e2e/paths/10-travel/03_descriptor.spec.js new file mode 100644 index 000000000..13b2dfe7a --- /dev/null +++ b/e2e/paths/10-travel/03_descriptor.spec.js @@ -0,0 +1,45 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Travel descriptor path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('buyer', 'travel'); + await page.accessToSearchResult('3'); + await page.waitForState('travel.card.summary'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should click the descriptor button to navigate to the travel index showing all travels with current agency', async() => { + await page.waitToClick(selectors.travelDescriptor.filterByAgencyButton); + await page.waitForState('travel.index'); + const result = await page.countElement(selectors.travelIndex.anySearchResult); + + expect(result).toEqual(8); + }); + + it('should navigate to the first search result', async() => { + await page.waitToClick(selectors.travelIndex.firstSearchResult); + await page.waitForState('travel.card.summary'); + const state = await page.getState(); + + expect(state).toBe('travel.card.summary'); + }); + + it('should be redirected to the create travel when using the clone option of the dot menu', async() => { + await page.waitToClick(selectors.travelDescriptor.dotMenu); + await page.waitToClick(selectors.travelDescriptor.dotMenuClone); + await page.respondToDialog('accept'); + await page.waitForState('travel.create'); + const state = await page.getState(); + + expect(state).toBe('travel.create'); + }); +}); diff --git a/modules/travel/front/descriptor-menu/index.html b/modules/travel/front/descriptor-menu/index.html index 45c745688..1eb558008 100644 --- a/modules/travel/front/descriptor-menu/index.html +++ b/modules/travel/front/descriptor-menu/index.html @@ -5,6 +5,7 @@ Clone travel