Debian Codegraph @

tests/api-testing/action/UserBlock.js

raw symbols SCIP
1 'use strict';
2
3 const { action, assert, utils } = require( 'api-testing' );
4
5 describe( 'The block/unblock action', () => {
6 const pageTitle = utils.title( 'Block_' );
7 let eve = action.getAnon();
8 let mindy;
9
10 before( async () => {
11 [ eve, mindy ] = await Promise.all( [
12 eve.account( 'Eve_' ),
13 action.mindy()
14 ] );
15 } );
16
17 it( 'allows an admin to block a user', async () => {
18 await eve.edit( pageTitle, { text: 'One', summary: 'first' } );
19
20 const result = await mindy.action( 'block', {
21 user: eve.username,
22 reason: 'testing',
23 token: await mindy.token()
24 }, 'POST' );
25
26 assert.exists( result.block.id );
27 assert.equal( result.block.userID, eve.userid );
28 assert.equal( result.block.user, eve.username );
29 } );
30
31 it( 'prevents a blocked user from editing', async () => {
32 const error = await eve.actionError(
33 'edit',
34 {
35 title: pageTitle,
36 text: 'Two',
37 summary: 'second',
38 token: await eve.token( 'csrf' )
39 },
40 'POST'
41 );
42 assert.equal( error.code, 'blocked' );
43 } );
44
45 it( 'allows an admin to unblock a user', async () => {
46 const result = await mindy.action( 'unblock', {
47 user: eve.username,
48 reason: 'testing',
49 token: await mindy.token()
50 }, 'POST' );
51
52 assert.exists( result.unblock.id );
53 assert.equal( result.unblock.userid, eve.userid );
54 assert.equal( result.unblock.user, eve.username );
55 } );
56
57 it( 'allows a user to edit after being unblocked', async () => {
58 await eve.edit( pageTitle, { text: 'Three', summary: 'third' } );
59 } );
60 } );