2018-03-15 16:30:11 +00:00
|
|
|
const
|
|
|
|
fs = require( 'fs' ),
|
|
|
|
EditPage = require( '../../../../../tests/selenium/pageobjects/edit.page' ),
|
|
|
|
Page = require( '../../../../../tests/selenium/pageobjects/page' ),
|
|
|
|
TEST_PAGE_TITLE = 'Popups test page',
|
|
|
|
POPUPS_SELECTOR = '.mwe-popups',
|
|
|
|
POPUPS_MODULE_NAME = 'ext.popups.main';
|
2017-09-01 14:35:04 +00:00
|
|
|
|
|
|
|
class PopupsPage extends Page {
|
|
|
|
setup() {
|
2018-03-14 23:50:09 +00:00
|
|
|
browser.call( () => {
|
|
|
|
return new Promise( ( resolve ) => {
|
2018-03-20 17:01:18 +00:00
|
|
|
fs.readFile( `${ __dirname }/../fixtures/test_page.wikitext`, 'utf-8', ( err, content ) => {
|
2017-09-01 14:35:04 +00:00
|
|
|
if ( err ) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
resolve( content );
|
|
|
|
} );
|
2018-03-14 23:50:09 +00:00
|
|
|
} ).then( ( content ) => {
|
2017-09-01 14:35:04 +00:00
|
|
|
return EditPage.apiEdit( TEST_PAGE_TITLE, content );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
resourceLoaderModuleStatus( moduleName, moduleStatus, errMsg ) {
|
2018-03-19 19:39:41 +00:00
|
|
|
// Word of caution: browser.waitUntil returns a Timer class NOT a Promise.
|
|
|
|
// Webdriver IO will run waitUntil synchronously so not returning it will
|
|
|
|
// block JavaScript execution while returning it will not.
|
|
|
|
// http://webdriver.io/api/utility/waitUntil.html
|
|
|
|
// https://github.com/webdriverio/webdriverio/blob/master/lib/utils/Timer.js
|
2018-03-14 23:50:09 +00:00
|
|
|
browser.waitUntil( () => {
|
|
|
|
return browser.execute( ( module ) => {
|
2018-03-19 19:39:41 +00:00
|
|
|
return mediaWiki &&
|
|
|
|
mediaWiki.loader &&
|
|
|
|
mediaWiki.loader.getState( module.name ) === module.status;
|
2017-09-01 14:35:04 +00:00
|
|
|
}, { status: moduleStatus, name: moduleName } );
|
|
|
|
}, 10000, errMsg );
|
|
|
|
}
|
|
|
|
|
2018-03-15 19:24:34 +00:00
|
|
|
ready() {
|
2018-03-20 20:20:43 +00:00
|
|
|
this.resourceLoaderModuleStatus( POPUPS_MODULE_NAME, 'ready', 'Popups did not load' );
|
2017-09-01 14:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
abandonLink() {
|
2018-03-15 19:24:34 +00:00
|
|
|
browser.moveToObject( '#content h1' );
|
2017-09-01 14:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dwellLink() {
|
2017-10-16 20:09:56 +00:00
|
|
|
const PAUSE = 1000;
|
2018-03-15 19:24:34 +00:00
|
|
|
this.ready();
|
2017-10-16 20:09:56 +00:00
|
|
|
browser.pause( PAUSE );
|
2018-03-15 16:30:11 +00:00
|
|
|
this.abandonLink();
|
2017-10-16 20:09:56 +00:00
|
|
|
browser.pause( PAUSE );
|
2017-09-01 14:35:04 +00:00
|
|
|
browser.moveToObject( '#content ul a' );
|
2018-03-15 19:24:34 +00:00
|
|
|
browser.waitForExist( POPUPS_SELECTOR );
|
2017-09-01 14:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
doNotSeePreview() {
|
2018-03-14 23:50:09 +00:00
|
|
|
return browser.waitUntil( () => !browser.isVisible( POPUPS_SELECTOR ) );
|
2017-09-01 14:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
seePreview() {
|
|
|
|
return browser.isVisible( POPUPS_SELECTOR );
|
|
|
|
}
|
|
|
|
|
|
|
|
open() {
|
|
|
|
super.open( TEST_PAGE_TITLE );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
module.exports = new PopupsPage();
|