aboutsummaryrefslogtreecommitdiffstats
path: root/tests/api-testing/action/DiffCompare.js
blob: 4e72c36fc163a37bf57c0f3c7800d6594e17ed12 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';

const { action, assert, utils } = require( 'api-testing' );

describe( 'Diff Compare with Variables', function () {
	let wikiuser;
	const title = utils.title( 'DiffCompare' );
	const variables = {};

	before( async () => {
		wikiuser = await action.alice();
	} );

	it( 'should edit a page', async () => {
		const editPage = await wikiuser.edit( title, { text: 'Counting: \n* One' } );

		variables.revision1 = editPage.newrevid;
	} );

	it( 'should edit a page, revision 2', async () => {
		await wikiuser.edit( title, { text: 'Counting: \n* One \n* Two' } );
	} );

	it( 'should edit a page, revision 3', async () => {
		const editPage = await wikiuser.edit( title, { text: 'Counting: \n* One \n* Two \n* Three' } );

		variables.revision3 = editPage.newrevid;
	} );

	it( 'should edit a page, revision 4', async () => {
		const editPage = await wikiuser.edit( title, { text: 'Counting: \n* One \n* Two' } );

		variables.revision4 = editPage.newrevid;
	} );

	it( 'should compare revisions 1 and 4', async () => {
		const compareRevisions = await wikiuser.action( 'compare', { fromrev: variables.revision1, torev: variables.revision4 } );

		assert.match( compareRevisions.compare[ '*' ], /<td class=.diff-addedline.*>.*\* Two/ );
	} );

	it( 'should compare revisions 3 and 4', async () => {
		const compareRevisions = await wikiuser.action( 'compare', { fromrev: variables.revision3, torev: variables.revision4 } );

		assert.match( compareRevisions.compare[ '*' ], /<td class=.diff-deletedline.*>.*\* Three/ );
	} );
} );