2020-05-14 21:14:42 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
2019-10-01 01:36:15 +00:00
|
|
|
const Api = require( 'wdio-mediawiki/Api' );
|
2024-02-01 15:51:08 +00:00
|
|
|
const BlankPage = require( 'wdio-mediawiki/BlankPage' );
|
2019-10-01 01:36:15 +00:00
|
|
|
const RecentChangesPage = require( '../pageobjects/recentchanges.page' );
|
|
|
|
|
const Util = require( 'wdio-mediawiki/Util' );
|
2018-06-12 11:01:25 +00:00
|
|
|
|
2024-06-11 12:43:19 +00:00
|
|
|
describe( 'Special:RecentChanges', () => {
|
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();
|
|
|
|
|
} );
|
2018-06-12 11:01:25 +00:00
|
|
|
|
2024-06-11 12:43:19 +00:00
|
|
|
beforeEach( async () => {
|
2021-10-13 15:05:12 +00:00
|
|
|
await browser.deleteAllCookies();
|
2018-06-20 11:06:45 +00:00
|
|
|
content = Util.getTestString();
|
|
|
|
|
name = Util.getTestString();
|
2018-06-12 11:01:25 +00:00
|
|
|
} );
|
|
|
|
|
|
2024-02-01 15:51:08 +00:00
|
|
|
it( 'shows page creation', async function () {
|
|
|
|
|
|
|
|
|
|
// First try to load a blank page, so the next command works.
|
|
|
|
|
await BlankPage.open();
|
|
|
|
|
// Don't try to run wikitext-specific tests if the test namespace isn't wikitext by default.
|
|
|
|
|
if ( await Util.isTargetNotWikitext( name ) ) {
|
|
|
|
|
this.skip();
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 15:05:12 +00:00
|
|
|
await bot.edit( name, content );
|
|
|
|
|
await browser.waitUntil( async () => {
|
2021-01-05 15:48:56 +00:00
|
|
|
const result = await bot.request( {
|
|
|
|
|
action: 'query',
|
|
|
|
|
list: 'recentchanges',
|
|
|
|
|
rctitle: name
|
|
|
|
|
} );
|
|
|
|
|
return result.query.recentchanges.length > 0;
|
|
|
|
|
} );
|
|
|
|
|
|
2021-10-13 15:05:12 +00:00
|
|
|
await RecentChangesPage.open();
|
2022-11-25 13:42:59 +00:00
|
|
|
await RecentChangesPage.liveUpdates.click();
|
|
|
|
|
await browser.waitUntil(
|
|
|
|
|
async () => ( await RecentChangesPage.titles[ 0 ].getText() ) === name,
|
|
|
|
|
{ timeout: 10000 }
|
|
|
|
|
);
|
2024-09-16 10:22:51 +00:00
|
|
|
await expect( await RecentChangesPage.titles[ 0 ] ).toHaveText( name );
|
2018-06-12 11:01:25 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
} );
|