wiki.techinc.nl/tests/selenium/specs/recentchanges.js

41 lines
910 B
JavaScript
Raw Normal View History

'use strict';
const assert = require( 'assert' );
const Api = require( 'wdio-mediawiki/Api' );
const RecentChangesPage = require( '../pageobjects/recentchanges.page' );
const Util = require( 'wdio-mediawiki/Util' );
describe( 'Special:RecentChanges', function () {
selenium: Fix more inefficient MWBot use and simplify wdio-mediawiki Api This does the same for the other specs, as previously done to the page.js spec in 058d5b7cd857af. * rollkback: From 6 api logins to 4 api logins. Before (2x3): admin for edit, admin for createaccount, vandal for edit. After (2x2): admin for edit + createaccount, vandal for edit. * recentchanges spec: No difference, but updated pattern for consistency so that if it is extended in the future, it will be natural to re-use the bot object instead of creating a new one. * watchlist spec: From 3 api logins to 1 api login. Before: admin for createaccount, admin for edit, admin for edit. After: admin (re-used) * user spec: From 2 to 1 api login. Also: * Remove the now-unused Api.edit() and Api.delete() anti-pattern methods, as these are nothing but one-line shortcuts to the already one-line invocation of bot.edit() and bot.delete(), except that they bypassed the current bot object, causing inefficient repeat logins in way that was non-obvious. Migration is simple and won't be required until other repos upgrade to the next wdio-mediawiki version (not yet released). * Make 'bot' a mandatory parameter for the createAccount, block, and unblock convenience wrapper methods. * Move the vandalizePage() method from HistoryPage to rollback spec, as it had no connection with that page object or the action=history interface, and document why it can't (yet) re-use its bot object. Bug: T234002 Change-Id: Id6e995916566f7dd7b618892295198b897fbee2e
2019-10-01 02:10:05 +00:00
let content, name, bot;
before( async () => {
bot = await Api.bot();
} );
beforeEach( function () {
selenium: Upgrade from webdriver v4 to v5 * Options no longer needed or no longer exist in wdio v5: - coloredLogs: Now always on. The underlying 'chalk' library can still be influenced via the FORCE_COLOR environment variable. - screenshotPath: Removed. Was already disabled in our config. - deprecationWarnings: Meh. - 'sync: true' – On by default when `@wdio/sync` is installed. The wdio v5 config generator doesn't recommend setting manually. * The selenium.sh script was removed. It existed to start and stop chromedriver for local use by developers. This is now done by the wdio-chromedriver-service. In WMF CI, Quibble starts its own chromedriver (as optimisation, reused across gated repos), which is why the 'selenium-test' entry points remains and skips this. * The wdio-mediawiki package now requires wdio v5 and Node 10. This doesn't affect extension repos because versions are pinned. Upgrade may happen at the earliest convenience. * Several WDIO methods changed names or signature. Full list at: <https://github.com/webdriverio/webdriverio/blob/v5.13.2/CHANGELOG.md#v500-2018-12-20> Highlights: - browser.element() is now browser.findElement() with "$()" as alias. - browser.localStorage replaced by browser.setLocalStorage. - browser.deleteCookie() requires `name` param. To delete all at once, there is a new method browser.deleteAllCookies(). - Commands that return data no longer wrapped in `{ value: … }`. Values are now returned directly. - Custom config keys are now under browser.config instead of browser.options. Renamed our username/password keys to be mw-prefixed, to avoid clashes and reduce confusion with similar config keys. - browser.click(selector) and browser.getText(selector) no longer exist. Use $(selector).click() or .getText() instead. * Fix "no such alert" warning from specs/page.js by removing the apparently redundant code. Bug: T234002 Bug: T213268 Change-Id: I908997569ca8457997af30cb29e98ac41fae3b64
2019-09-27 03:08:00 +00:00
browser.deleteAllCookies();
content = Util.getTestString();
name = Util.getTestString();
} );
it( 'shows page creation', function () {
selenium: Fix more inefficient MWBot use and simplify wdio-mediawiki Api This does the same for the other specs, as previously done to the page.js spec in 058d5b7cd857af. * rollkback: From 6 api logins to 4 api logins. Before (2x3): admin for edit, admin for createaccount, vandal for edit. After (2x2): admin for edit + createaccount, vandal for edit. * recentchanges spec: No difference, but updated pattern for consistency so that if it is extended in the future, it will be natural to re-use the bot object instead of creating a new one. * watchlist spec: From 3 api logins to 1 api login. Before: admin for createaccount, admin for edit, admin for edit. After: admin (re-used) * user spec: From 2 to 1 api login. Also: * Remove the now-unused Api.edit() and Api.delete() anti-pattern methods, as these are nothing but one-line shortcuts to the already one-line invocation of bot.edit() and bot.delete(), except that they bypassed the current bot object, causing inefficient repeat logins in way that was non-obvious. Migration is simple and won't be required until other repos upgrade to the next wdio-mediawiki version (not yet released). * Make 'bot' a mandatory parameter for the createAccount, block, and unblock convenience wrapper methods. * Move the vandalizePage() method from HistoryPage to rollback spec, as it had no connection with that page object or the action=history interface, and document why it can't (yet) re-use its bot object. Bug: T234002 Change-Id: Id6e995916566f7dd7b618892295198b897fbee2e
2019-10-01 02:10:05 +00:00
browser.call( async () => {
await bot.edit( name, content );
} );
browser.waitUntil( async () => {
const result = await bot.request( {
action: 'query',
list: 'recentchanges',
rctitle: name
} );
return result.query.recentchanges.length > 0;
} );
RecentChangesPage.open();
assert.strictEqual( RecentChangesPage.titles[ 0 ].getText(), name );
} );
} );