mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-12 08:58:25 +00:00
Merge "Ensure each api call creates a new instance of MWBot"
This commit is contained in:
commit
129de0821d
|
@ -1,7 +1,8 @@
|
|||
const assert = require( 'assert' ),
|
||||
MWBot = require( 'mwbot' ),
|
||||
Api = require( 'wdio-mediawiki/Api' ),
|
||||
ArticlePageWithOverlay = require( '../support/pages/article_page_with_overlay' ),
|
||||
{ ArticlePage, UserLoginPage, api } = require( '../support/world.js' );
|
||||
{ ArticlePage, UserLoginPage } = require( '../support/world.js' );
|
||||
|
||||
const waitForPropagation = ( timeMs ) => {
|
||||
// wait 2 seconds so the change can propogate.
|
||||
|
@ -9,32 +10,30 @@ const waitForPropagation = ( timeMs ) => {
|
|||
browser.waitUntil( () => new Date() - d > timeMs );
|
||||
};
|
||||
|
||||
const login = () => {
|
||||
return api.loginGetEditToken( {
|
||||
username: browser.options.username,
|
||||
password: browser.options.password,
|
||||
apiUrl: `${browser.options.baseUrl}/api.php`
|
||||
} );
|
||||
};
|
||||
|
||||
const createPages = ( pages ) => {
|
||||
const summary = 'edit by selenium test';
|
||||
browser.call( () => login() );
|
||||
browser.call( () => {
|
||||
return api.batch(
|
||||
pages.map( ( page ) => [ 'create' ].concat( page ).concat( [ summary ] ) )
|
||||
).catch( ( err ) => {
|
||||
if ( err.code === 'articleexists' ) {
|
||||
return;
|
||||
}
|
||||
throw err;
|
||||
} );
|
||||
|
||||
const bot = new MWBot();
|
||||
return bot.loginGetEditToken( {
|
||||
username: browser.options.username,
|
||||
password: browser.options.password,
|
||||
apiUrl: `${browser.options.baseUrl}/api.php`
|
||||
} )
|
||||
.then( () => {
|
||||
return bot.batch(
|
||||
pages.map( ( page ) => [ 'create' ].concat( page ).concat( [ summary ] ) )
|
||||
).catch( ( err ) => {
|
||||
if ( err.code === 'articleexists' ) {
|
||||
return;
|
||||
}
|
||||
throw err;
|
||||
} );
|
||||
} )
|
||||
.catch( ( err ) => { throw err; } );
|
||||
} );
|
||||
};
|
||||
|
||||
const createPage = ( title, wikitext ) => {
|
||||
browser.call( () => login() );
|
||||
browser.call( () => Api.edit( title, wikitext ) );
|
||||
};
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
const { api, ArticlePage } = require( '../support/world' );
|
||||
const RunJobs = require( 'wdio-mediawiki/RunJobs' );
|
||||
const Api = require( 'wdio-mediawiki/Api' );
|
||||
const Page = require( 'wdio-mediawiki/Page' );
|
||||
const {
|
||||
iAmOnPage,
|
||||
waitForPropagation,
|
||||
createPages,
|
||||
createPage
|
||||
} = require( './common_steps' );
|
||||
const { ArticlePage } = require( '../support/world' ),
|
||||
RunJobs = require( 'wdio-mediawiki/RunJobs' ),
|
||||
Api = require( 'wdio-mediawiki/Api' ),
|
||||
Page = require( 'wdio-mediawiki/Page' ),
|
||||
MWBot = require( 'mwbot' ),
|
||||
{
|
||||
iAmOnPage,
|
||||
waitForPropagation,
|
||||
createPages,
|
||||
createPage
|
||||
} = require( './common_steps' );
|
||||
|
||||
const iAmInAWikiThatHasCategories = ( title ) => {
|
||||
const msg = 'This page is used by Selenium to test category related features.',
|
||||
|
@ -45,15 +46,19 @@ const iAmOnAPageThatHasTheFollowingEdits = function ( table ) {
|
|||
edits = table.rawTable.map( ( row, i ) =>
|
||||
[ i === 0 ? 'create' : 'edit', pageTitle, row[ 0 ] ] );
|
||||
|
||||
api.loginGetEditToken( {
|
||||
username: browser.options.username,
|
||||
password: browser.options.password,
|
||||
apiUrl: `${browser.options.baseUrl}/api.php`
|
||||
} )
|
||||
.then( () => api.batch( edits ) )
|
||||
.then( () => ArticlePage.open( pageTitle ) )
|
||||
.catch( ( err ) => { throw err; } );
|
||||
waitForPropagation( 5000 );
|
||||
browser.call( () => {
|
||||
const bot = new MWBot();
|
||||
return bot.loginGetEditToken( {
|
||||
username: browser.options.username,
|
||||
password: browser.options.password,
|
||||
apiUrl: `${browser.options.baseUrl}/api.php`
|
||||
} )
|
||||
.then( () => bot.batch( edits ) )
|
||||
.catch( ( err ) => { throw err; } );
|
||||
} );
|
||||
|
||||
browser.call( () => RunJobs.run() );
|
||||
ArticlePage.open( pageTitle );
|
||||
};
|
||||
|
||||
const iGoToAPageThatHasLanguages = () => {
|
||||
|
|
|
@ -15,13 +15,10 @@
|
|||
* allowing us to use the dependencies across scenarios.
|
||||
*/
|
||||
|
||||
const MwBot = require( 'mwbot' ),
|
||||
mwCorePages = require( '../support/pages/mw_core_pages' ),
|
||||
const mwCorePages = require( '../support/pages/mw_core_pages' ),
|
||||
minervaPages = require( '../support/pages/minerva_pages' );
|
||||
|
||||
function MinervaWorld() {
|
||||
/* dependencies */
|
||||
this.api = new MwBot();
|
||||
/* pageObjects */
|
||||
Object.assign( this, mwCorePages );
|
||||
Object.assign( this, minervaPages );
|
||||
|
|
Loading…
Reference in a new issue