From eb4e29fb4824931f59bea90698dd8fd63a1388ea Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 7 Feb 2019 09:07:00 +0100 Subject: [PATCH] #1051 --- e2e/helpers/extensions.js | 18 ++++++++++++++++-- e2e/helpers/selectors.js | 1 + e2e/paths/ticket-module/07_edit_sale.spec.js | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 1ba440d31..864e3171d 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -191,6 +191,18 @@ let actions = { }, done, selector); }, + waitImgLoad: function(selector, done) { + this.wait(selector) + .wait(selector => { + const imageReady = document.querySelector(selector).complete; + return imageReady; + }, selector) + .then(done) + .catch(() => { + done(new Error(`image ${selector}, load timed out`)); + }); + }, + clickIfVisible: function(selector, done) { this.wait(selector) .isVisible(selector) @@ -215,7 +227,7 @@ let actions = { return document.querySelectorAll(selector).length === count; }, selector, count) .then(done) - .catch(err => { + .catch(() => { done(new Error(`.waitForNumberOfElements() for ${selector}, count ${count} timed out`)); }); }, @@ -239,7 +251,9 @@ let actions = { return true; }, selector, className) .then(done) - .catch(done); + .catch(() => { + done(new Error(`.waitForClassPresent() for ${selector}, class ${className} timed out`)); + }); }, waitForTextInElement: function(selector, name, done) { diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index c3f09c88e..3216e76a8 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -335,6 +335,7 @@ export default { saleDescriptorPopoverSummaryButton: 'vn-item-descriptor-popover a[href="#!/item/1/summary"]', descriptorItemDiaryButton: `vn-item-descriptor .quicklinks.ng-scope > vn-horizontal > a > vn-icon > i`, newItemButton: 'vn-float-button[icon="add"]', + firstSaleDescriptorImage: 'vn-ticket-sale vn-item-descriptor-popover > vn-popover vn-item-descriptor img', firstSaleText: `vn-table div > vn-tbody > vn-tr:nth-child(1)`, firstSaleThumbnailImage: 'vn-ticket-sale:nth-child(1) vn-tr:nth-child(1) vn-td:nth-child(3) > img', firstSaleZoomedImage: 'body > div > div > img', diff --git a/e2e/paths/ticket-module/07_edit_sale.spec.js b/e2e/paths/ticket-module/07_edit_sale.spec.js index bc7889be0..dca585605 100644 --- a/e2e/paths/ticket-module/07_edit_sale.spec.js +++ b/e2e/paths/ticket-module/07_edit_sale.spec.js @@ -87,7 +87,7 @@ describe('Ticket Edit sale path', () => { it(`should click on the first sale ID making the item descriptor visible`, async() => { const visible = await nightmare .waitToClick(selectors.ticketSales.firstSaleID) - .wait(1000) + .waitImgLoad(selectors.ticketSales.firstSaleDescriptorImage) .isVisible(selectors.ticketSales.saleDescriptorPopover); expect(visible).toBeTruthy();