Merge "Selenium: Replace nodemw with mwbot"
This commit is contained in:
commit
33fa8c095c
4 changed files with 44 additions and 98 deletions
|
|
@ -25,7 +25,7 @@
|
|||
"karma-firefox-launcher": "1.0.1",
|
||||
"karma-mocha-reporter": "2.2.5",
|
||||
"karma-qunit": "1.2.1",
|
||||
"nodemw": "0.11.0",
|
||||
"mwbot": "1.0.10",
|
||||
"postcss-less": "1.1.3",
|
||||
"qunitjs": "2.4.1",
|
||||
"stylelint": "8.2.0",
|
||||
|
|
|
|||
|
|
@ -22,54 +22,26 @@ class CreateAccountPage extends Page {
|
|||
}
|
||||
|
||||
apiCreateAccount( username, password ) {
|
||||
const url = require( 'url' ), // https://nodejs.org/docs/latest/api/url.html
|
||||
baseUrl = url.parse( browser.options.baseUrl ), // http://webdriver.io/guide/testrunner/browserobject.html
|
||||
Bot = require( 'nodemw' ), // https://github.com/macbre/nodemw
|
||||
client = new Bot( {
|
||||
protocol: baseUrl.protocol,
|
||||
server: baseUrl.hostname,
|
||||
port: baseUrl.port,
|
||||
path: baseUrl.path,
|
||||
debug: false
|
||||
|
||||
const MWBot = require( 'mwbot' ), // https://github.com/Fannon/mwbot
|
||||
Promise = require( 'bluebird' );
|
||||
let bot = new MWBot();
|
||||
|
||||
return Promise.coroutine( function* () {
|
||||
yield bot.loginGetCreateaccountToken( {
|
||||
apiUrl: `${browser.options.baseUrl}/api.php`,
|
||||
username: browser.options.username,
|
||||
password: browser.options.password
|
||||
} );
|
||||
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
client.api.call(
|
||||
{
|
||||
action: 'query',
|
||||
meta: 'tokens',
|
||||
type: 'createaccount'
|
||||
},
|
||||
/**
|
||||
* @param {Error|null} err
|
||||
* @param {Object} info Processed query result
|
||||
* @param {Object} next More results?
|
||||
* @param {Object} data Raw data
|
||||
*/
|
||||
function ( err, info, next, data ) {
|
||||
if ( err ) {
|
||||
reject( err );
|
||||
return;
|
||||
}
|
||||
client.api.call( {
|
||||
action: 'createaccount',
|
||||
createreturnurl: browser.options.baseUrl,
|
||||
createtoken: data.query.tokens.createaccounttoken,
|
||||
username: username,
|
||||
password: password,
|
||||
retype: password
|
||||
}, function ( err ) {
|
||||
if ( err ) {
|
||||
reject( err );
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
}, 'POST' );
|
||||
},
|
||||
'POST'
|
||||
);
|
||||
|
||||
} );
|
||||
yield bot.request( {
|
||||
action: 'createaccount',
|
||||
createreturnurl: browser.options.baseUrl,
|
||||
createtoken: bot.createaccountToken,
|
||||
username: username,
|
||||
password: password,
|
||||
retype: password
|
||||
} );
|
||||
} ).call( this );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,33 +19,20 @@ class DeletePage extends Page {
|
|||
}
|
||||
|
||||
apiDelete( name, reason ) {
|
||||
const url = require( 'url' ), // https://nodejs.org/docs/latest/api/url.html
|
||||
baseUrl = url.parse( browser.options.baseUrl ), // http://webdriver.io/guide/testrunner/browserobject.html
|
||||
Bot = require( 'nodemw' ), // https://github.com/macbre/nodemw
|
||||
client = new Bot( {
|
||||
protocol: baseUrl.protocol,
|
||||
server: baseUrl.hostname,
|
||||
port: baseUrl.port,
|
||||
path: baseUrl.path,
|
||||
username: browser.options.username,
|
||||
password: browser.options.password,
|
||||
debug: false
|
||||
} );
|
||||
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
client.logIn( function ( err ) {
|
||||
if ( err ) {
|
||||
console.log( err );
|
||||
return reject( err );
|
||||
}
|
||||
client.delete( name, reason, function ( err ) {
|
||||
if ( err ) {
|
||||
return reject( err );
|
||||
}
|
||||
resolve();
|
||||
} );
|
||||
const MWBot = require( 'mwbot' ), // https://github.com/Fannon/mwbot
|
||||
Promise = require( 'bluebird' );
|
||||
let bot = new MWBot();
|
||||
|
||||
return Promise.coroutine( function* () {
|
||||
yield bot.loginGetEditToken( {
|
||||
apiUrl: `${browser.options.baseUrl}/api.php`,
|
||||
username: browser.options.username,
|
||||
password: browser.options.password
|
||||
} );
|
||||
} );
|
||||
yield bot.delete( name, reason );
|
||||
} ).call( this );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,33 +19,20 @@ class EditPage extends Page {
|
|||
}
|
||||
|
||||
apiEdit( name, content ) {
|
||||
const url = require( 'url' ), // https://nodejs.org/docs/latest/api/url.html
|
||||
baseUrl = url.parse( browser.options.baseUrl ), // http://webdriver.io/guide/testrunner/browserobject.html
|
||||
Bot = require( 'nodemw' ), // https://github.com/macbre/nodemw
|
||||
client = new Bot( {
|
||||
protocol: baseUrl.protocol,
|
||||
server: baseUrl.hostname,
|
||||
port: baseUrl.port,
|
||||
path: baseUrl.path,
|
||||
username: browser.options.username,
|
||||
password: browser.options.password,
|
||||
debug: false
|
||||
} );
|
||||
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
client.logIn( function ( err ) {
|
||||
if ( err ) {
|
||||
console.log( err );
|
||||
return reject( err );
|
||||
}
|
||||
client.edit( name, content, `Created page with "${content}"`, function ( err ) {
|
||||
if ( err ) {
|
||||
return reject( err );
|
||||
}
|
||||
resolve();
|
||||
} );
|
||||
const MWBot = require( 'mwbot' ), // https://github.com/Fannon/mwbot
|
||||
Promise = require( 'bluebird' );
|
||||
let bot = new MWBot();
|
||||
|
||||
return Promise.coroutine( function* () {
|
||||
yield bot.loginGetEditToken( {
|
||||
apiUrl: `${browser.options.baseUrl}/api.php`,
|
||||
username: browser.options.username,
|
||||
password: browser.options.password
|
||||
} );
|
||||
} );
|
||||
yield bot.edit( name, content, `Created page with "${content}"` );
|
||||
} ).call( this );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue