| 1 | 'use strict'; |
| 2 | |
| 3 | const { action, assert, utils, wiki } = require( 'api-testing' ); |
| 4 | |
| 5 | describe( 'Recent Changes', () => { |
| 6 | const title = utils.title( 'Recent_Changes_' ); |
| 7 | let alice; |
| 8 | |
| 9 | before( async () => { |
| 10 | alice = await action.alice(); |
| 11 | } ); |
| 12 | |
| 13 | it( 'should create page and get new page recent changes', async () => { |
| 14 | const edit = await alice.edit( title, { text: 'Recent changes testing', createonly: true } ); |
| 15 | await wiki.runAllJobs(); |
| 16 | const results = await alice.list( 'recentchanges', { rctype: 'new', rctitle: title } ); |
| 17 | |
| 18 | assert.equal( results[ 0 ].type, 'new' ); |
| 19 | assert.sameTitle( results[ 0 ].title, title ); |
| 20 | assert.equal( results[ 0 ].pageid, edit.pageid ); |
| 21 | assert.equal( results[ 0 ].revid, edit.newrevid ); |
| 22 | } ); |
| 23 | |
| 24 | it( 'should edit page and get most recent edit changes', async () => { |
| 25 | const rev1 = await alice.edit( title, { text: 'Recent changes testing..R1' } ); |
| 26 | await wiki.runAllJobs(); |
| 27 | const results = await alice.list( 'recentchanges', { rctype: 'edit', rctitle: title } ); |
| 28 | |
| 29 | assert.equal( results[ 0 ].type, 'edit' ); |
| 30 | assert.sameTitle( results[ 0 ].title, title ); |
| 31 | assert.equal( results[ 0 ].pageid, rev1.pageid ); |
| 32 | assert.equal( results[ 0 ].revid, rev1.newrevid ); |
| 33 | } ); |
| 34 | } ); |