From b3a58a6dd39c06746ea4d5d1d0a426c03cc6fa10 Mon Sep 17 00:00:00 2001 From: WMDE-Fisch Date: Tue, 2 Apr 2019 12:41:22 +0200 Subject: [PATCH] Move browser tests loading steps to beforeEach - test page loading and waiting for the scripts moved to beforeEach - removed unnecessary abondonLink call - removed unnecessary browser.pause() Change-Id: I28eb7b9b48f105315bf41f7a41e5a1e6ec21cb2b --- tests/selenium/pageobjects/popups.page.js | 7 +------ tests/selenium/specs/page_previews.js | 7 +++++-- tests/selenium/specs/reference_previews.js | 9 +++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/selenium/pageobjects/popups.page.js b/tests/selenium/pageobjects/popups.page.js index c773a3ff8..6c582fa7a 100644 --- a/tests/selenium/pageobjects/popups.page.js +++ b/tests/selenium/pageobjects/popups.page.js @@ -50,10 +50,10 @@ class PopupsPage extends Page { ready() { this.resourceLoaderModuleStatus( POPUPS_MODULE_NAME, 'ready', 'Popups did not load' ); + browser.pause( 1000 ); } hasReferencePopupsEnabled() { - this.open(); return browser.execute( function () { return mediaWiki.config.get( 'wgPopupsReferencePreviews' ); } ).value; @@ -64,11 +64,6 @@ class PopupsPage extends Page { } dwellLink( selector ) { - const PAUSE = 1000; - this.ready(); - browser.pause( PAUSE ); - this.abandonLink(); - browser.pause( PAUSE ); browser.moveToObject( selector ); browser.waitForExist( POPUPS_SELECTOR ); } diff --git a/tests/selenium/specs/page_previews.js b/tests/selenium/specs/page_previews.js index 9d8abd410..406cc4b72 100644 --- a/tests/selenium/specs/page_previews.js +++ b/tests/selenium/specs/page_previews.js @@ -6,14 +6,17 @@ describe( 'Dwelling on a valid page link', function () { page.setup(); } ); - it( 'I should see a page preview', function () { + beforeEach( function () { page.open(); + page.ready(); + } ); + + it( 'I should see a page preview', function () { page.dwellPageLink(); assert( page.seePagePreview(), 'Page preview is shown.' ); } ); it( 'Abandoning link hides page preview', function () { - page.open(); page.dwellPageLink(); page.abandonLink(); assert( page.doNotSeePagePreview(), 'Page preview is kept hidden.' ); diff --git a/tests/selenium/specs/reference_previews.js b/tests/selenium/specs/reference_previews.js index 4a3058cf2..7810c8496 100644 --- a/tests/selenium/specs/reference_previews.js +++ b/tests/selenium/specs/reference_previews.js @@ -6,11 +6,15 @@ describe( 'Dwelling on a valid reference link', function () { page.setup(); } ); + beforeEach( function () { + page.open(); + page.ready(); + } ); + it( 'I should see a reference preview', function () { if ( !page.hasReferencePopupsEnabled() ) { this.skip(); } - page.open(); page.dwellReferenceLink( 1 ); assert( page.seeReferencePreview(), 'Reference preview is shown.' ); assert( !page.seeScrollableReferencePreview(), 'Reference preview is not scrollable.' ); @@ -21,7 +25,6 @@ describe( 'Dwelling on a valid reference link', function () { if ( !page.hasReferencePopupsEnabled() ) { this.skip(); } - page.open(); page.dwellReferenceLink( 1 ); page.abandonLink(); assert( page.doNotSeeReferencePreview(), 'Reference preview is kept hidden.' ); @@ -31,7 +34,6 @@ describe( 'Dwelling on a valid reference link', function () { if ( !page.hasReferencePopupsEnabled() ) { this.skip(); } - page.open(); page.dwellReferenceLink( 2 ); assert( page.seeScrollableReferencePreview(), 'Reference preview has a fading effect' ); assert( page.seeFadeoutOnReferenceText(), 'Reference preview has a fading effect' ); @@ -41,7 +43,6 @@ describe( 'Dwelling on a valid reference link', function () { if ( !page.hasReferencePopupsEnabled() ) { this.skip(); } - page.open(); page.dwellReferenceLink( 3 ); page.dwellReferenceInceptionLink(); assert( page.seeReferenceInceptionPreview(), 'The reference preview is still showing.' );