mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-11 07:16:08 +00:00
c578de27d8
The script is needed to run the new Docker-based Jenkins job that runs daily and targets beta cluster. selenium-test script and NPM packages are dependencies. selenium-daily now just calls selenium-test. selenium-daily might seem redundant, but it provides flexibility. In case a repository does not want to run all tests daily, that's easily fixed by updating the selenium-daily script. Bug: T188742 Change-Id: I35c93ff1897afc4b9e66703a1acf765e3fe7b643
72 lines
1.9 KiB
JavaScript
72 lines
1.9 KiB
JavaScript
const
|
|
fs = require( 'fs' ),
|
|
Api = require( 'wdio-mediawiki/Api' ),
|
|
Page = require( 'wdio-mediawiki/Page' ),
|
|
TEST_PAGE_TITLE = 'Popups test page',
|
|
POPUPS_SELECTOR = '.mwe-popups',
|
|
POPUPS_MODULE_NAME = 'ext.popups.main';
|
|
|
|
class PopupsPage extends Page {
|
|
setup() {
|
|
browser.call( () => {
|
|
return new Promise( ( resolve ) => {
|
|
fs.readFile( `${ __dirname }/../fixtures/test_page.wikitext`, 'utf-8', ( err, content ) => {
|
|
if ( err ) {
|
|
throw err;
|
|
}
|
|
resolve( content );
|
|
} );
|
|
} ).then( ( content ) => {
|
|
return Api.edit( TEST_PAGE_TITLE, content );
|
|
} );
|
|
} );
|
|
}
|
|
|
|
resourceLoaderModuleStatus( moduleName, moduleStatus, errMsg ) {
|
|
// 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
|
|
browser.waitUntil( () => {
|
|
return browser.execute( ( module ) => {
|
|
return mediaWiki &&
|
|
mediaWiki.loader &&
|
|
mediaWiki.loader.getState( module.name ) === module.status;
|
|
}, { status: moduleStatus, name: moduleName } );
|
|
}, 10000, errMsg );
|
|
}
|
|
|
|
ready() {
|
|
this.resourceLoaderModuleStatus( POPUPS_MODULE_NAME, 'ready', 'Popups did not load' );
|
|
}
|
|
|
|
abandonLink() {
|
|
browser.moveToObject( '#content h1' );
|
|
}
|
|
|
|
dwellLink() {
|
|
const PAUSE = 1000;
|
|
this.ready();
|
|
browser.pause( PAUSE );
|
|
this.abandonLink();
|
|
browser.pause( PAUSE );
|
|
browser.moveToObject( '#content ul a' );
|
|
browser.waitForExist( POPUPS_SELECTOR );
|
|
}
|
|
|
|
doNotSeePreview() {
|
|
return browser.waitUntil( () => !browser.isVisible( POPUPS_SELECTOR ) );
|
|
}
|
|
|
|
seePreview() {
|
|
return browser.isVisible( POPUPS_SELECTOR );
|
|
}
|
|
|
|
open() {
|
|
super.openTitle( TEST_PAGE_TITLE );
|
|
}
|
|
|
|
}
|
|
module.exports = new PopupsPage();
|