wiki.techinc.nl/tests/api-testing/action/Watchlist.js
Kosta Harlan d01950a57d
api-testing: Run all jobs after edit in Watchlist.js
See
https://integration.wikimedia.org/ci/job/mediawiki-quibble-apitests-vendor-php72-docker/28585/console
for a build failure where the watchlist query didn't return a result.

Change-Id: I891668e9daf92286d2cf8f98b9aab72f56c57d78
2022-02-10 14:03:57 +01:00

73 lines
2.2 KiB
JavaScript

'use strict';
const { action, assert, utils, wiki } = require( 'api-testing' );
describe( 'The watchlist', function testWatch() {
let alice;
const walter = action.getAnon();
const title = utils.title( 'Watch_' );
const edits = {};
before( async () => {
[ , alice ] = await Promise.all( [
walter.account( 'Walter_' ),
action.alice()
] );
} );
it( 'can have items added by an edit', async () => {
edits.walter1 = await walter.edit( title, { watchlist: 'watch' } );
await wiki.runAllJobs();
const list = await walter.list( 'watchlist', {
wltype: 'edit|new',
wlprop: 'ids|title|flags|user|comment|timestamp'
} );
assert.sameTitle( list[ 0 ].title, title );
assert.equal( list[ 0 ].type, 'new' );
assert.equal( list[ 0 ].revid, edits.walter1.newrevid );
assert.equal( list[ 0 ].user, edits.walter1.param_user );
assert.equal( list[ 0 ].comment, edits.walter1.param_summary );
assert.equal( list[ 0 ].timestamp, edits.walter1.newtimestamp );
} );
it( 'can have items removed using the unwatch flag', async () => {
await walter.action( 'watch', {
unwatch: true,
title: title,
token: await walter.token( 'watch' )
}, 'POST' );
const list = await walter.list( 'watchlist', {
wltype: 'edit|new',
wlprop: 'ids|title|flags|user|comment|timestamp'
} );
assert.empty( list );
} );
it( 'can have items added using the watch action', async () => {
await walter.action( 'watch', {
title: title,
token: await walter.token( 'watch' )
}, 'POST' );
edits.alice2 = await alice.edit( title, {} );
await wiki.runAllJobs();
// FIXME: this is needed to force a sync with the replica database.
// This trick only works with a single replica. We need a better
// way to ensure a sync! Not to mention waiting for the job queue...
await alice.getRevision( title );
const list = await walter.list( 'watchlist', {
wltype: 'edit|new',
wlprop: 'ids|title|flags|user|comment|timestamp'
} );
assert.equal( list[ 0 ].type, 'edit' );
assert.equal( list[ 0 ].revid, edits.alice2.newrevid );
assert.equal( list[ 0 ].user, edits.alice2.param_user );
assert.equal( list[ 0 ].comment, edits.alice2.param_summary );
assert.equal( list[ 0 ].timestamp, edits.alice2.newtimestamp );
} );
} );