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'
13 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
15 describe('Test bulk API validators', function () {
16 let server: ServerInfo
17 let userAccessToken: string
19 // ---------------------------------------------------------------
21 before(async function () {
24 server = await flushAndRunServer(1)
25 await setAccessTokensToServers([ server ])
27 const user = { username: 'user1', password: 'password' }
28 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
30 userAccessToken = await userLogin(server, user)
33 describe('When removing comments of', function () {
34 const path = '/api/v1/bulk/remove-comments-of'
36 it('Should fail with an unauthenticated user', async function () {
37 await makePostBodyRequest({
40 fields: { accountName: 'user1', scope: 'my-videos' },
41 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
45 it('Should fail with an unknown account', async function () {
46 await makePostBodyRequest({
48 token: server.accessToken,
50 fields: { accountName: 'user2', scope: 'my-videos' },
51 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
55 it('Should fail with an invalid scope', async function () {
56 await makePostBodyRequest({
58 token: server.accessToken,
60 fields: { accountName: 'user1', scope: 'my-videoss' },
61 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
65 it('Should fail to delete comments of the instance without the appropriate rights', async function () {
66 await makePostBodyRequest({
68 token: userAccessToken,
70 fields: { accountName: 'user1', scope: 'instance' },
71 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
75 it('Should succeed with the correct params', async function () {
76 await makePostBodyRequest({
78 token: server.accessToken,
80 fields: { accountName: 'user1', scope: 'instance' },
81 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
86 after(async function () {
87 await cleanupTests([ server ])