mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-13 17:53:09 +00:00
Merge "Use waitForModuleState from Util class"
This commit is contained in:
commit
bc7738733c
|
@ -1,4 +1,5 @@
|
||||||
const Page = require( 'wdio-mediawiki/Page' );
|
const Page = require( 'wdio-mediawiki/Page' ),
|
||||||
|
Util = require( 'wdio-mediawiki/Util' );
|
||||||
|
|
||||||
class CitePage extends Page {
|
class CitePage extends Page {
|
||||||
getReference( num ) { return browser.elements( '#mw-content-text .reference' ).value[ num - 1 ]; }
|
getReference( num ) { return browser.elements( '#mw-content-text .reference' ).value[ num - 1 ]; }
|
||||||
|
@ -6,23 +7,8 @@ class CitePage extends Page {
|
||||||
getCiteSingleBacklink( num ) { return browser.element( '.references li:nth-of-type(' + num + ') .mw-cite-backlink a' ); }
|
getCiteSingleBacklink( num ) { return browser.element( '.references li:nth-of-type(' + num + ') .mw-cite-backlink a' ); }
|
||||||
getCiteSubBacklink( num ) { return browser.element( '.mw-cite-backlink sup:nth-of-type(' + num + ') a' ); }
|
getCiteSubBacklink( num ) { return browser.element( '.mw-cite-backlink sup:nth-of-type(' + num + ') a' ); }
|
||||||
|
|
||||||
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( () => {
|
|
||||||
const result = browser.execute( ( module ) => {
|
|
||||||
return typeof mw !== 'undefined' &&
|
|
||||||
mw.loader.getState( module.name ) === module.status;
|
|
||||||
}, { status: moduleStatus, name: moduleName } );
|
|
||||||
return result.value;
|
|
||||||
}, 10000, errMsg );
|
|
||||||
}
|
|
||||||
|
|
||||||
scriptsReady() {
|
scriptsReady() {
|
||||||
this.resourceLoaderModuleStatus( 'ext.cite.ux-enhancements', 'ready', 'Cite scripts did not load' );
|
Util.waitForModuleState( 'ext.cite.ux-enhancements' );
|
||||||
}
|
}
|
||||||
|
|
||||||
getFragmentFromLink( linkElement ) {
|
getFragmentFromLink( linkElement ) {
|
||||||
|
|
Loading…
Reference in a new issue