| 1 |
'use strict'; |
| 2 |
|
| 3 |
const { action, assert, utils, wiki } = require( 'api-testing' ); |
| 4 |
|
| 5 |
describe( 'The watchlist', () => { |
| 6 |
let alice; |
| 7 |
const walter = action.getAnon(); |
| 8 |
const title = utils.title( 'Watch_' ); |
| 9 |
const edits = {}; |
| 10 |
|
| 11 |
before( async () => { |
| 12 |
[ , alice ] = await Promise.all( [ |
| 13 |
walter.account( 'Walter_' ), |
| 14 |
action.alice() |
| 15 |
] ); |
| 16 |
} ); |
| 17 |
|
| 18 |
it( 'can have items added by an edit', async () => { |
| 19 |
edits.walter1 = await walter.edit( title, { watchlist: 'watch' } ); |
| 20 |
await wiki.runAllJobs(); |
| 21 |
const list = await walter.list( 'watchlist', { |
| 22 |
wltype: 'edit|new', |
| 23 |
wlprop: 'ids|title|flags|user|comment|timestamp' |
| 24 |
} ); |
| 25 |
|
| 26 |
assert.sameTitle( list[ 0 ].title, title ); |
| 27 |
assert.equal( list[ 0 ].type, 'new' ); |
| 28 |
assert.equal( list[ 0 ].revid, edits.walter1.newrevid ); |
| 29 |
assert.equal( list[ 0 ].user, edits.walter1.param_user ); |
| 30 |
assert.equal( list[ 0 ].comment, edits.walter1.param_summary ); |
| 31 |
assert.equal( list[ 0 ].timestamp, edits.walter1.newtimestamp ); |
| 32 |
} ); |
| 33 |
|
| 34 |
it( 'can have items removed using the unwatch flag', async () => { |
| 35 |
await walter.action( 'watch', { |
| 36 |
unwatch: true, |
| 37 |
title: title, |
| 38 |
token: await walter.token( 'watch' ) |
| 39 |
}, 'POST' ); |
| 40 |
|
| 41 |
const list = await walter.list( 'watchlist', { |
| 42 |
wltype: 'edit|new', |
| 43 |
wlprop: 'ids|title|flags|user|comment|timestamp' |
| 44 |
} ); |
| 45 |
assert.empty( list ); |
| 46 |
} ); |
| 47 |
|
| 48 |
it( 'can have items added using the watch action', async () => { |
| 49 |
await walter.action( 'watch', { |
| 50 |
title: title, |
| 51 |
token: await walter.token( 'watch' ) |
| 52 |
}, 'POST' ); |
| 53 |
|
| 54 |
edits.alice2 = await alice.edit( title, {} ); |
| 55 |
|
| 56 |
await wiki.runAllJobs(); |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
await alice.getRevision( title ); |
| 61 |
|
| 62 |
const list = await walter.list( 'watchlist', { |
| 63 |
wltype: 'edit|new', |
| 64 |
wlprop: 'ids|title|flags|user|comment|timestamp' |
| 65 |
} ); |
| 66 |
|
| 67 |
assert.equal( list[ 0 ].type, 'edit' ); |
| 68 |
assert.equal( list[ 0 ].revid, edits.alice2.newrevid ); |
| 69 |
assert.equal( list[ 0 ].user, edits.alice2.param_user ); |
| 70 |
assert.equal( list[ 0 ].comment, edits.alice2.param_summary ); |
| 71 |
assert.equal( list[ 0 ].timestamp, edits.alice2.newtimestamp ); |
| 72 |
} ); |
| 73 |
} ); |