]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/users.ts
Don't rely on youtube for tests
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / users.ts
index 472fbda4314e6628211f8e5805cce71dfc52a700..3e53c445d313870607c92d9aa73e36fc5b6d7f56 100644 (file)
@@ -1,10 +1,10 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import { omit } from 'lodash'
 import 'mocha'
+import { expect } from 'chai'
+import { omit } from 'lodash'
 import { join } from 'path'
 import { User, UserRole, VideoImport, VideoImportState } from '../../../../shared'
-
 import {
   addVideoChannel,
   blockUser,
@@ -31,17 +31,16 @@ import {
   uploadVideo,
   userLogin
 } from '../../../../shared/extra-utils'
+import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
 import {
   checkBadCountPagination,
   checkBadSortPagination,
   checkBadStartPagination
 } from '../../../../shared/extra-utils/requests/check-api-params'
-import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
-import { VideoPrivacy } from '../../../../shared/models/videos'
 import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
-import { expect } from 'chai'
+import { getMagnetURI, getMyVideoImports, getGoodVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
 import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
-import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
+import { VideoPrivacy } from '../../../../shared/models/videos'
 
 describe('Test users API validators', function () {
   const path = '/api/v1/users/'
@@ -55,8 +54,6 @@ describe('Test users API validators', function () {
   let moderatorAccessToken = ''
   let emailPort: number
   let overrideConfig: Object
-  // eslint-disable-next-line @typescript-eslint/no-unused-vars
-  let channelId: number
 
   // ---------------------------------------------------------------
 
@@ -129,11 +126,6 @@ describe('Test users API validators', function () {
       })
     }
 
-    {
-      const res = await getMyUserInformation(server.url, server.accessToken)
-      channelId = res.body.videoChannels[0].id
-    }
-
     {
       const res = await uploadVideo(server.url, server.accessToken, {})
       videoId = res.body.video.id
@@ -162,6 +154,18 @@ describe('Test users API validators', function () {
       await checkBadSortPagination(server.url, path, server.accessToken)
     })
 
+    it('Should fail with a bad blocked/banned user filter', async function () {
+      await makeGetRequest({
+        url: server.url,
+        path,
+        query: {
+          blocked: 42
+        },
+        token: server.accessToken,
+        statusCodeExpected: 400
+      })
+    })
+
     it('Should fail with a non authenticated user', async function () {
       await makeGetRequest({
         url: server.url,
@@ -1042,7 +1046,7 @@ describe('Test users API validators', function () {
         channelId: 1,
         privacy: VideoPrivacy.PUBLIC
       }
-      await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }))
+      await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getGoodVideoUrl() }))
       await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() }))
       await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: 'video-720p.torrent' as any }))