Debian Codegraph @

tests/api-testing/action/Delete.js

raw symbols SCIP
1 'use strict';
2
3 const { action, assert, utils } = require( 'api-testing' );
4
5 describe( 'The delete/undelete action', () => {
6 const title = utils.title( 'Delete_' );
7 let alice, mindy;
8
9 before( async () => {
10 [ alice, mindy ] = await Promise.all( [
11 action.alice(),
12 action.mindy()
13 ] );
14 } );
15
16 it( 'allows an admin to delete a page', async () => {
17 await alice.edit( title, {
18 text: 'Testing the testy test',
19 summary: 'first',
20 createonly: true
21 } );
22
23 const result = await mindy.action( 'delete', {
24 title,
25 summary: 'testing',
26 token: await mindy.token( 'csrf' )
27 }, 'POST' );
28
29 assert.sameTitle( result.delete.title, title );
30
31 const error = await mindy.actionError( 'parse', { page: title } );
32 assert.equal( error.code, 'missingtitle' );
33 } );
34
35 it( 'logs the deletion', async () => {
36 const log = await alice.getLogEntry( {
37 letype: 'delete',
38 letitle: title
39 } );
40 assert.equal( log.user, mindy.username );
41 assert.equal( log.action, 'delete' );
42 } );
43
44 it( 'allows an admin to undelete a page', async () => {
45 const result = await mindy.action( 'undelete', {
46 title,
47 summary: 'testing',
48 token: await mindy.token( 'csrf' )
49 }, 'POST' );
50
51 assert.sameTitle( result.undelete.title, title );
52
53 const html = await alice.getHtml( title );
54 assert.match( html, /Testing the testy test/ );
55 } );
56
57 it( 'logs the undeletion', async () => {
58 const log = await alice.getLogEntry( {
59 letype: 'delete',
60 letitle: title
61 } );
62 assert.equal( log.user, mindy.username );
63 assert.equal( log.action, 'restore' );
64 } );
65 } );