From 326c92b23fef7822c1542e1bf4ebb532fa9b3909 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 31 Mar 2020 18:33:48 +0200 Subject: [PATCH] E2E fixes: doSearch extension, item clone intermittence --- e2e/helpers/extensions.js | 13 +++++++-- e2e/paths/02-client/01_create_client.spec.js | 4 +-- e2e/paths/04-item/01_summary.spec.js | 17 +++++------ e2e/paths/04-item/08_create_and_clone.spec.js | 28 ++++++------------- e2e/paths/04-item/11_item_log.spec.js | 8 ++---- e2e/paths/05-ticket/09_weekly.spec.js | 18 ++++-------- e2e/paths/05-ticket/13_services.spec.js | 5 ++-- e2e/paths/06-claim/06_descriptor.spec.js | 8 ++---- .../09-invoice-out/02_descriptor.spec.js | 19 ++++--------- 9 files changed, 49 insertions(+), 71 deletions(-) diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 1d0073999..59e98e217 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -125,7 +125,7 @@ let actions = { let $state = angular.element(document.body).injector().get('$state'); return !$state.transition && $state.is(state); }, {}, state); - await this.waitForSpinnerLoad(state); + await this.waitForSpinnerLoad(); }, waitForTransition: async function() { @@ -133,6 +133,7 @@ let actions = { const $state = angular.element(document.body).injector().get('$state'); return !$state.transition; }); + await this.waitForSpinnerLoad(); }, accessToSection: async function(state) { @@ -167,11 +168,17 @@ let actions = { await this.waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`); }, - accessToSearchResult: async function(searchValue) { + doSearch: async function(searchValue) { await this.clearInput('vn-searchbar'); - await this.write('vn-searchbar', searchValue); + if (searchValue) + await this.write('vn-searchbar', searchValue); + await this.waitToClick('vn-searchbar vn-icon[icon="search"]'); await this.waitForTransition(); + }, + + accessToSearchResult: async function(searchValue) { + await this.doSearch(searchValue); await this.waitFor('.vn-descriptor'); }, diff --git a/e2e/paths/02-client/01_create_client.spec.js b/e2e/paths/02-client/01_create_client.spec.js index 0b8c96c16..2efd10d2b 100644 --- a/e2e/paths/02-client/01_create_client.spec.js +++ b/e2e/paths/02-client/01_create_client.spec.js @@ -15,9 +15,7 @@ describe('Client create path', async() => { }); it(`should search for the user Carol Danvers to confirm it isn't created yet`, async() => { - await page.write(selectors.clientsIndex.topbarSearch, 'Carol Danvers'); - await page.waitToClick(selectors.clientsIndex.searchButton); - await page.waitForNumberOfElements(selectors.clientsIndex.searchResult, 0); + await page.doSearch('Carol Danvers'); const result = await page.countElement(selectors.clientsIndex.searchResult); expect(result).toEqual(0); diff --git a/e2e/paths/04-item/01_summary.spec.js b/e2e/paths/04-item/01_summary.spec.js index 6f2c2c926..7658cb752 100644 --- a/e2e/paths/04-item/01_summary.spec.js +++ b/e2e/paths/04-item/01_summary.spec.js @@ -15,14 +15,14 @@ describe('Item summary path', () => { }); it('should search for an item', async() => { - await page.clearInput(selectors.itemsIndex.topbarSearch); - await page.write(selectors.itemsIndex.topbarSearch, 'Ranged weapon'); - await page.waitToClick(selectors.itemsIndex.searchButton); - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3); + await page.doSearch('Ranged weapon'); + const nResults = await page.countElement(selectors.itemsIndex.searchResult); + await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon'); await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); const isVisible = await page.isVisible(selectors.itemSummary.basicData); + expect(nResults).toBe(3); expect(isVisible).toBeTruthy(); }); @@ -67,12 +67,13 @@ describe('Item summary path', () => { }); it('should search for other item', async() => { - await page.clearInput('vn-searchbar'); - await page.write(selectors.itemsIndex.topbarSearch, 'Melee Reinforced'); - await page.keyboard.press('Enter'); - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2); + await page.doSearch('Melee Reinforced'); + const nResults = await page.countElement(selectors.itemsIndex.searchResult); + await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); await page.waitForSelector(selectors.itemSummary.basicData, {visible: true}); + + expect(nResults).toBe(2); }); it(`should now check the item summary preview shows fields from basic data`, async() => { diff --git a/e2e/paths/04-item/08_create_and_clone.spec.js b/e2e/paths/04-item/08_create_and_clone.spec.js index 73249a0b9..8fa40ed82 100644 --- a/e2e/paths/04-item/08_create_and_clone.spec.js +++ b/e2e/paths/04-item/08_create_and_clone.spec.js @@ -16,13 +16,10 @@ describe('Item Create/Clone path', () => { describe('create', () => { it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => { - await page.clearInput(selectors.itemsIndex.topbarSearch); - await page.write(selectors.itemsIndex.topbarSearch, 'Infinity Gauntlet'); - await page.waitToClick(selectors.itemsIndex.searchButton); - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0); - const result = await page.countElement(selectors.itemsIndex.searchResult); + await page.doSearch('Infinity Gauntlet'); + const nResults = await page.countElement(selectors.itemsIndex.searchResult); - expect(result).toEqual(0); + expect(nResults).toEqual(0); }); it('should access to the create item view by clicking the create floating button', async() => { @@ -85,13 +82,10 @@ describe('Item Create/Clone path', () => { }); it(`should search for the item Infinity Gauntlet`, async() => { - await page.clearInput(selectors.itemsIndex.topbarSearch); - await page.write(selectors.itemsIndex.topbarSearch, 'Infinity Gauntlet'); - await page.waitToClick(selectors.itemsIndex.searchButton); - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1); - const result = await page.countElement(selectors.itemsIndex.searchResult); + await page.doSearch('Infinity Gauntlet'); + const nResults = await page.countElement(selectors.itemsIndex.searchResult); - expect(result).toEqual(1); + expect(nResults).toEqual(1); }); it(`should clone the Infinity Gauntlet`, async() => { @@ -102,14 +96,10 @@ describe('Item Create/Clone path', () => { }); it('should search for the item Infinity Gauntlet and find two', async() => { - await page.waitToClick(selectors.itemTags.goToItemIndexButton); - await page.clearInput(selectors.itemsIndex.topbarSearch); - await page.write(selectors.itemsIndex.topbarSearch, 'Infinity Gauntlet'); - await page.waitToClick(selectors.itemsIndex.searchButton); - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2); - const result = await page.countElement(selectors.itemsIndex.searchResult); + await page.doSearch('Infinity Gauntlet'); + const nResults = await page.countElement(selectors.itemsIndex.searchResult); - expect(result).toEqual(2); + expect(nResults).toEqual(2); }); }); }); diff --git a/e2e/paths/04-item/11_item_log.spec.js b/e2e/paths/04-item/11_item_log.spec.js index 82800b9b8..40025de74 100644 --- a/e2e/paths/04-item/11_item_log.spec.js +++ b/e2e/paths/04-item/11_item_log.spec.js @@ -15,12 +15,10 @@ describe('Item log path', () => { }); it(`should search for the Knowledge artifact to confirm it isn't created yet`, async() => { - await page.write(selectors.itemsIndex.topbarSearch, 'Knowledge artifact'); - await page.waitToClick(selectors.itemsIndex.searchButton); - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0); - const result = await page.countElement(selectors.itemsIndex.searchResult); + await page.doSearch('Knowledge artifact'); + const nResults = await page.countElement(selectors.itemsIndex.searchResult); - expect(result).toEqual(0); + expect(nResults).toEqual(0); }); it('should access to the create item view by clicking the create floating button', async() => { diff --git a/e2e/paths/05-ticket/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js index 1629107fb..f0b814dd8 100644 --- a/e2e/paths/05-ticket/09_weekly.spec.js +++ b/e2e/paths/05-ticket/09_weekly.spec.js @@ -17,7 +17,6 @@ describe('Ticket descriptor path', () => { }); it('should count the amount of tickets in the turns section', async() => { - await page.waitForNumberOfElements(selectors.ticketsIndex.weeklyTicket, 5); const result = await page.countElement(selectors.ticketsIndex.weeklyTicket); expect(result).toEqual(5); @@ -87,12 +86,10 @@ describe('Ticket descriptor path', () => { }); it('should now search for the weekly ticket 11', async() => { - await page.write(selectors.ticketsIndex.topbarSearch, '11'); - await page.waitToClick(selectors.ticketsIndex.searchButton); - await page.waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 1); - const result = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); + await page.doSearch('11'); + const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); - expect(result).toEqual(1); + expect(nResults).toEqual(1); }); it('should delete the weekly ticket 11', async() => { @@ -104,12 +101,9 @@ describe('Ticket descriptor path', () => { }); it('should confirm the sixth weekly ticket was deleted', async() => { - await page.waitForContentLoaded(); - await page.clearInput('vn-searchbar'); - await page.waitToClick(selectors.ticketsIndex.searchWeeklyButton); - await page.waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 5); - const result = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); + await page.doSearch(); + const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); - expect(result).toEqual(5); + expect(nResults).toEqual(5); }); }); diff --git a/e2e/paths/05-ticket/13_services.spec.js b/e2e/paths/05-ticket/13_services.spec.js index 170841fda..aaab0791b 100644 --- a/e2e/paths/05-ticket/13_services.spec.js +++ b/e2e/paths/05-ticket/13_services.spec.js @@ -127,10 +127,9 @@ describe('Ticket services path', () => { it(`should confirm the service was removed`, async() => { await page.reloadSection('ticket.card.service'); - await page.waitForNumberOfElements(selectors.ticketService.serviceLine, 0); - const result = await page.countElement(selectors.ticketService.serviceLine); + const nResults = await page.countElement(selectors.ticketService.serviceLine); - expect(result).toEqual(0); + expect(nResults).toEqual(0); }); }); }); diff --git a/e2e/paths/06-claim/06_descriptor.spec.js b/e2e/paths/06-claim/06_descriptor.spec.js index ee49fe245..ea18e223b 100644 --- a/e2e/paths/06-claim/06_descriptor.spec.js +++ b/e2e/paths/06-claim/06_descriptor.spec.js @@ -50,11 +50,9 @@ describe('claim Descriptor path', () => { }); it(`should search for the deleted claim to find no results`, async() => { - await page.write(selectors.claimsIndex.searchClaimInput, claimId); - await page.waitToClick(selectors.claimsIndex.searchButton); - await page.waitForNumberOfElements(selectors.claimsIndex.searchResult, 0); - const result = await page.countElement(selectors.claimsIndex.searchResult); + await page.doSearch(claimId); + const nResults = await page.countElement(selectors.claimsIndex.searchResult); - expect(result).toEqual(0); + expect(nResults).toEqual(0); }); }); diff --git a/e2e/paths/09-invoice-out/02_descriptor.spec.js b/e2e/paths/09-invoice-out/02_descriptor.spec.js index 605106abf..9f378bf3e 100644 --- a/e2e/paths/09-invoice-out/02_descriptor.spec.js +++ b/e2e/paths/09-invoice-out/02_descriptor.spec.js @@ -50,13 +50,10 @@ describe('InvoiceOut descriptor path', () => { }); it(`should search for the deleted invouceOut to find no results`, async() => { - await page.write(selectors.invoiceOutIndex.topbarSearch, 'T2222222'); - await page.waitToClick(selectors.invoiceOutIndex.searchButton); - await page.waitForSpinnerLoad(); - await page.waitForNumberOfElements(selectors.invoiceOutIndex.searchResult, 0); - const result = await page.countElement(selectors.invoiceOutIndex.searchResult); + await page.doSearch('T2222222'); + const nResults = await page.countElement(selectors.invoiceOutIndex.searchResult); - expect(result).toEqual(0); + expect(nResults).toEqual(0); }); it('should navigate to the ticket index', async() => { @@ -67,14 +64,10 @@ describe('InvoiceOut descriptor path', () => { }); it('should search for tickets with an specific invoiceOut to find no results', async() => { - await page.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton); - await page.write(selectors.ticketsIndex.advancedSearchInvoiceOut, 'T2222222'); - await page.waitToClick(selectors.ticketsIndex.advancedSearchButton); - await page.waitForSpinnerLoad(); - await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 0); - const result = await page.countElement(selectors.ticketsIndex.searchResult); + await page.doSearch('T2222222'); + const nResults = await page.countElement(selectors.ticketsIndex.searchResult); - expect(result).toEqual(0); + expect(nResults).toEqual(0); }); it('should now navigate to the invoiceOut index', async() => {