wiki.techinc.nl/tests/api-testing/action/ListUsers.js
Ed Sanders 9fe2995989 build: Update eslint-config-wikimedia to 0.21.0
* Replace `substr`/`substring` with `slice`. The second argument
  to `substring` is length, not end index as in `substr`/`slice`,
  so convert where necessary.
* Replace `new Date().getTime()` with `Date.now()`
* Documentation fixes
* Replace `throw Error` with `throw new Error`

Change-Id: I532500ea4c99d8ebec01efb21273c8df21626e59
2021-11-09 21:08:55 +00:00

34 lines
1,022 B
JavaScript

'use strict';
const { action, assert, utils } = require( 'api-testing' );
describe( 'Listing Users', function () {
let prefix;
// users
const user1 = action.getAnon();
const user2 = action.getAnon();
const user3 = action.getAnon();
before( async () => {
prefix = await utils.title();
prefix = prefix.slice( 0, 7 );
// NOTE: Because of T199393, the accounts have to be created sequentially.
// Doing so in parallel triggers a race condition that often results in a DBQueryError.
await user1.account( `${prefix}1` );
await user2.account( `${prefix}2` );
await user3.account( `${prefix}3` );
} );
it( 'should get a list of registered users that begin with a given prefix', async () => {
const result = await user1.list( 'allusers', { auprefix: prefix } );
assert.sameDeepMembers( result, [
{ name: user1.username, userid: user1.userid },
{ name: user2.username, userid: user2.userid },
{ name: user3.username, userid: user3.userid }
] );
assert.lengthOf( result, 3 );
} );
} );