X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fselenium%2Fwdio-mediawiki%2FRunJobs.js;h=daa7fbd71b1d694ec2cfb5fd492d8fc9be2fc495;hp=9f36202bf2b684db05c100699a9035e0955e07bb;hb=46586a243c6adf6a7020608173ba5a73fb97ee72;hpb=a1e51bf94325130fa3d54d65c071d3ab57a4ab79 diff --git a/tests/selenium/wdio-mediawiki/RunJobs.js b/tests/selenium/wdio-mediawiki/RunJobs.js index 9f36202bf2..daa7fbd71b 100644 --- a/tests/selenium/wdio-mediawiki/RunJobs.js +++ b/tests/selenium/wdio-mediawiki/RunJobs.js @@ -1,19 +1,17 @@ -const MWBot = require( 'mwbot' ), - Page = require( './Page' ), - FRONTPAGE_REQUESTS_MAX_RUNS = 10; // (arbitrary) safe-guard against endless execution +const MWBot = require( 'mwbot' ); +const Page = require( './Page' ); +const MAINPAGE_REQUESTS_MAX_RUNS = 10; // (arbitrary) safe-guard against endless execution function getJobCount() { - let bot = new MWBot( { - apiUrl: `${browser.options.baseUrl}/api.php` + const bot = new MWBot( { + apiUrl: `${browser.config.baseUrl}/api.php` } ); - return new Promise( ( resolve ) => { - return bot.request( { - action: 'query', - meta: 'siteinfo', - siprop: 'statistics' - } ).then( ( response ) => { - resolve( response.query.statistics.jobs ); - } ); + return bot.request( { + action: 'query', + meta: 'siteinfo', + siprop: 'statistics' + } ).then( ( response ) => { + return response.query.statistics.jobs; } ); } @@ -21,9 +19,9 @@ function log( message ) { process.stdout.write( `RunJobs ${message}\n` ); } -function runThroughFrontPageRequests( runCount = 1 ) { - let page = new Page(); - log( `through requests to the front page (run ${runCount}).` ); +function runThroughMainPageRequests( runCount = 1 ) { + const page = new Page(); + log( `through requests to the main page (run ${runCount}).` ); page.openTitle( '' ); @@ -33,11 +31,11 @@ function runThroughFrontPageRequests( runCount = 1 ) { return; } log( `detected ${jobCount} more queued job(s).` ); - if ( runCount >= FRONTPAGE_REQUESTS_MAX_RUNS ) { - log( 'stopping requests to the front page due to reached limit.' ); + if ( runCount >= MAINPAGE_REQUESTS_MAX_RUNS ) { + log( 'stopping requests to the main page due to reached limit.' ); return; } - return runThroughFrontPageRequests( ++runCount ); + return runThroughMainPageRequests( ++runCount ); } ); } @@ -65,7 +63,7 @@ class RunJobs { static run() { browser.call( () => { - return runThroughFrontPageRequests(); + return runThroughMainPageRequests(); } ); } }