$newTouched = $this->newTouchedTimestamp();
$dbw = wfGetDB( DB_MASTER );
- $dbw->doAtomicSection( __METHOD__, function ( $dbw, $fname ) use ( $newTouched ) {
+ $dbw->doAtomicSection( __METHOD__, function ( IDatabase $dbw, $fname ) use ( $newTouched ) {
global $wgActorTableSchemaMigrationStage;
$dbw->update( 'user',
$fields["user_$name"] = $value;
}
- return $dbw->doAtomicSection( __METHOD__, function ( $dbw, $fname ) use ( $fields ) {
+ return $dbw->doAtomicSection( __METHOD__, function ( IDatabase $dbw, $fname ) use ( $fields ) {
$dbw->insert( 'user', $fields, $fname, [ 'IGNORE' ] );
if ( $dbw->affectedRows() ) {
$newUser = self::newFromId( $dbw->insertId() );
$this->mTouched = $this->newTouchedTimestamp();
$dbw = wfGetDB( DB_MASTER );
- $status = $dbw->doAtomicSection( __METHOD__, function ( $dbw, $fname ) {
+ $status = $dbw->doAtomicSection( __METHOD__, function ( IDatabase $dbw, $fname ) {
$noPass = PasswordFactory::newInvalidPassword()->toString();
$dbw->insert( 'user',
[
$ok = false;
while ( !$ok ) {
try {
- $dbw->doAtomicSection( __METHOD__, function ( $dbw, $fname ) {
+ $dbw->doAtomicSection( __METHOD__, function ( IDatabase $dbw, $fname ) {
$dbw->insert( 'revision', self::$dummyRev, $fname );
$id = $dbw->insertId();
$toDelete[] = $id;
self::$dummyRev = self::makeDummyRevisionRow( $dbw );
}
- $updates = $dbw->doAtomicSection( __METHOD__, function ( $dbw, $fname ) use ( $arIds ) {
+ $updates = $dbw->doAtomicSection( __METHOD__, function ( IDatabase $dbw, $fname ) use ( $arIds ) {
// Create new rev_ids by inserting dummy rows into revision and then deleting them.
$dbw->insert( 'revision', array_fill( 0, count( $arIds ), self::$dummyRev ), $fname );
$revIds = $dbw->selectFieldValues(
if ( mw.Title && content instanceof mw.Title ) {
// Parse existing page
config.page = content.getPrefixedDb();
+ apiPromise = this.get( config );
} else {
// Parse wikitext from input
config.text = String( content );
+ apiPromise = this.post( config );
}
- apiPromise = this.get( config );
-
return apiPromise
.then( function ( data ) {
return data.parse.text;
} ) );
QUnit.test( '.parse( string )', function ( assert ) {
- this.server.respondWith( /action=parse.*&text='''Hello(\+|%20)world'''/, [ 200,
+ this.server.respondWith( 'POST', /api.php/, [ 200,
{ 'Content-Type': 'application/json' },
'{ "parse": { "text": "<p><b>Hello world</b></p>" } }'
] );
} );
QUnit.test( '.parse( Object.toString )', function ( assert ) {
- this.server.respondWith( /action=parse.*&text='''Hello(\+|%20)world'''/, [ 200,
+ this.server.respondWith( 'POST', /api.php/, [ 200,
{ 'Content-Type': 'application/json' },
'{ "parse": { "text": "<p><b>Hello world</b></p>" } }'
] );
} );
QUnit.test( '.parse( mw.Title )', function ( assert ) {
- this.server.respondWith( /action=parse.*&page=Earth/, [ 200,
+ this.server.respondWith( 'GET', /action=parse.*&page=Earth/, [ 200,
{ 'Content-Type': 'application/json' },
'{ "parse": { "text": "<p><b>Earth</b> is a planet.</p>" } }'
] );
// 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.' );
}
};