From: Timo Tijhof Date: Fri, 25 Jan 2019 19:08:01 +0000 (-0800) Subject: wdio-mediawiki: Rename internal "Front page" ref to "Main page" X-Git-Tag: 1.34.0-rc.0~2869^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=b0102bcc98c35184f5c3d6f1260a4837f2dab7e2;p=lhc%2Fweb%2Fwiklou.git wdio-mediawiki: Rename internal "Front page" ref to "Main page" Also remove redundant 'new Promise' indirection, in favour of native chaining through "then()". This avoids a situation where wdio could hang indefinitely (until timeout) when MWBot.request fails because we did not attach any "catch()" handler to the promise. By always keeping a chain, the failures are (by default) forwarded and thus propagated and thus caught eventually. Change-Id: If2f09479600029db2fa967c57082031744a06d8f --- diff --git a/tests/selenium/wdio-mediawiki/RunJobs.js b/tests/selenium/wdio-mediawiki/RunJobs.js index 9f36202bf2..070ad56498 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 + MAINPAGE_REQUESTS_MAX_RUNS = 10; // (arbitrary) safe-guard against endless execution function getJobCount() { let bot = new MWBot( { apiUrl: `${browser.options.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 ) { +function runThroughMainPageRequests( runCount = 1 ) { let page = new Page(); - log( `through requests to the front page (run ${runCount}).` ); + 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(); } ); } }