1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
9 setAccessTokensToServers,
11 } from '../../../../shared/extra-utils'
12 import { makePostBodyRequest } from '../../../../shared/extra-utils/requests/requests'
14 describe('Test bulk API validators', function () {
15 let server: ServerInfo
16 let userAccessToken: string
18 // ---------------------------------------------------------------
20 before(async function () {
23 server = await flushAndRunServer(1)
24 await setAccessTokensToServers([ server ])
26 const user = { username: 'user1', password: 'password' }
27 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
29 userAccessToken = await userLogin(server, user)
32 describe('When removing comments of', function () {
33 const path = '/api/v1/bulk/remove-comments-of'
35 it('Should fail with an unauthenticated user', async function () {
36 await makePostBodyRequest({
39 fields: { accountName: 'user1', scope: 'my-videos' },
40 statusCodeExpected: 401
44 it('Should fail with an unknown account', async function () {
45 await makePostBodyRequest({
47 token: server.accessToken,
49 fields: { accountName: 'user2', scope: 'my-videos' },
50 statusCodeExpected: 404
54 it('Should fail with an invalid scope', async function () {
55 await makePostBodyRequest({
57 token: server.accessToken,
59 fields: { accountName: 'user1', scope: 'my-videoss' },
60 statusCodeExpected: 400
64 it('Should fail to delete comments of the instance without the appropriate rights', async function () {
65 await makePostBodyRequest({
67 token: userAccessToken,
69 fields: { accountName: 'user1', scope: 'instance' },
70 statusCodeExpected: 403
74 it('Should succeed with the correct params', async function () {
75 await makePostBodyRequest({
77 token: server.accessToken,
79 fields: { accountName: 'user1', scope: 'instance' },
80 statusCodeExpected: 204
85 after(async function () {
86 await cleanupTests([ server ])