mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 16:30:12 +00:00
Increase stability of backlink browser tests
Adding a step to wait for loaded modules. This was manily taken from the Popups-extension browser test, but with a fixed chain for the results. Let's hope we do not need to pause with this. See as well I274bdee0b3c39c418a2b61881d56f89889c53485 Bug: T220318 Change-Id: I5bdc1951a23a51e9a4deea69af2bfc96843f5a1d
This commit is contained in:
parent
b6075be8ec
commit
7e8cf11648
|
@ -7,7 +7,8 @@
|
|||
"mocha": true
|
||||
},
|
||||
"globals": {
|
||||
"browser": false
|
||||
"browser": false,
|
||||
"mw": false
|
||||
},
|
||||
"rules": {
|
||||
"no-console": 0
|
||||
|
|
|
@ -6,6 +6,25 @@ class CitePage extends Page {
|
|||
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' ); }
|
||||
|
||||
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() {
|
||||
this.resourceLoaderModuleStatus( 'ext.cite.ux-enhancements', 'ready', 'Cite scripts did not load' );
|
||||
}
|
||||
|
||||
getFragmentFromLink( linkElement ) {
|
||||
// the href includes the full url so slice the fragment from it
|
||||
let href = linkElement.getAttribute( 'href' );
|
||||
|
|
|
@ -22,7 +22,7 @@ describe( 'Cite backlinks', function () {
|
|||
|
||||
beforeEach( function () {
|
||||
CitePage.openTitle( title );
|
||||
browser.pause( 300 ); // make sure JS is loaded
|
||||
CitePage.scriptsReady();
|
||||
} );
|
||||
|
||||
it( 'are highlighted in the reference list when there are multiple used references', function () {
|
||||
|
@ -78,6 +78,7 @@ describe( 'Cite backlinks', function () {
|
|||
|
||||
it( 'are not accidentally removed from unnamed references', function () {
|
||||
CitePage.getReference( 3 ).click();
|
||||
CitePage.getCiteSingleBacklink( 2 ).waitForVisible();
|
||||
CitePage.getCiteSingleBacklink( 2 ).click();
|
||||
// It doesn't matter what is focussed next, just needs to be something else
|
||||
CitePage.getReference( 1 ).click();
|
||||
|
|
Loading…
Reference in a new issue