// Requires user to log in again, handled by deleteCookie() call in beforeEach function
UserLoginPage.loginAdmin();
- browser.pause( 300 );
+ UserLoginPage.waitForScriptsToBeReady();
browser.execute( function () {
return ( new mw.Api() ).saveOption(
'showrollbackconfirmation',
assert.strictEqual( HistoryPage.rollbackConfirmableNo.getText(), 'Cancel' );
} );
- it.skip( 'should offer a way to cancel rollbacks', function () {
+ it( 'should offer a way to cancel rollbacks', function () {
HistoryPage.rollback.click();
- browser.pause( 300 );
+ HistoryPage.rollbackConfirmableNo.waitForVisible( 5000 );
HistoryPage.rollbackConfirmableNo.click();
- browser.pause( 500 );
+ browser.pause( 1000 ); // Waiting to ensure we are NOT redirected and stay on the same page
assert.strictEqual( HistoryPage.heading.getText(), 'Revision history of "' + name + '"' );
} );
- it.skip( 'should perform rollbacks after confirming intention', function () {
+ it( 'should perform rollbacks after confirming intention', function () {
HistoryPage.rollback.click();
- browser.pause( 300 );
+ HistoryPage.rollbackConfirmableYes.waitForVisible( 5000 );
HistoryPage.rollbackConfirmableYes.click();
// Requires user to log in again, handled by deleteCookie() call in beforeEach function
UserLoginPage.loginAdmin();
- browser.pause( 300 );
+ UserLoginPage.waitForScriptsToBeReady();
browser.execute( function () {
return ( new mw.Api() ).saveOption(
'showrollbackconfirmation',
-const Page = require( './Page' );
+const Page = require( './Page' ),
+ Util = require( 'wdio-mediawiki/Util' );
class LoginPage extends Page {
get username() { return browser.element( '#wpName1' ); }
loginAdmin() {
this.login( browser.options.username, browser.options.password );
}
+
+ waitForScriptsToBeReady() {
+ Util.waitForModuleState( 'mediawiki.api' );
+ }
}
module.exports = new LoginPage();
module.exports = {
getTestString( prefix = '' ) {
return prefix + Math.random().toString() + '-Iñtërnâtiônàlizætiøn';
+ },
+
+ /**
+ * Wait for a given module to reach a specific state
+ * @param {string} moduleName The name of the module to wait for
+ * @param {string} moduleStatus 'registered', 'loaded', 'loading', 'ready', 'error', 'missing'
+ * @param {int} timeout The wait time in milliseconds before the wait fails
+ */
+ waitForModuleState( moduleName, moduleStatus = 'ready', timeout = 2000 ) {
+ 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;
+ }, timeout, 'Failed to wait for ' + moduleName + ' to be ' + moduleStatus + ' after ' + timeout + ' ms.' );
}
};