]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/videos-filter.ts
Rewrite youtube-dl import
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / videos-filter.ts
index 4aa00cfc49b118e6f31a8e2071cfaf1381a82693..2306807bf94232562e239ea6d5bcdfcba39be815 100644 (file)
@@ -1,23 +1,18 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
-import * as chai from 'chai'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { expect } from 'chai'
 import {
   cleanupTests,
+  createMultipleServers,
   doubleFollow,
-  flushAndRunMultipleServers,
   makeGetRequest,
-  ServerInfo,
-  setAccessTokensToServers,
-  uploadVideo
-} from '../../../../shared/extra-utils'
-import { UserRole } from '../../../../shared/models/users'
-import { Video, VideoPrivacy } from '../../../../shared/models/videos'
+  PeerTubeServer,
+  setAccessTokensToServers
+} from '@shared/extra-utils'
+import { HttpStatusCode, UserRole, Video, VideoPrivacy } from '@shared/models'
 
-const expect = chai.expect
-
-async function getVideosNames (server: ServerInfo, token: string, filter: string, statusCodeExpected = HttpStatusCode.OK_200) {
+async function getVideosNames (server: PeerTubeServer, token: string, filter: string, expectedStatus = HttpStatusCode.OK_200) {
   const paths = [
     '/api/v1/video-channels/root_channel/videos',
     '/api/v1/accounts/root/videos',
@@ -36,7 +31,7 @@ async function getVideosNames (server: ServerInfo, token: string, filter: string
         sort: 'createdAt',
         filter
       },
-      statusCodeExpected
+      expectedStatus
     })
 
     videosResults.push(res.body.data.map(v => v.name))
@@ -46,32 +41,32 @@ async function getVideosNames (server: ServerInfo, token: string, filter: string
 }
 
 describe('Test videos filter', function () {
-  let servers: ServerInfo[]
+  let servers: PeerTubeServer[]
 
   // ---------------------------------------------------------------
 
   before(async function () {
     this.timeout(160000)
 
-    servers = await flushAndRunMultipleServers(2)
+    servers = await createMultipleServers(2)
 
     await setAccessTokensToServers(servers)
 
     for (const server of servers) {
       const moderator = { username: 'moderator', password: 'my super password' }
-      await server.usersCommand.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
-      server['moderatorAccessToken'] = await server.loginCommand.getAccessToken(moderator)
+      await server.users.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
+      server['moderatorAccessToken'] = await server.login.getAccessToken(moderator)
 
-      await uploadVideo(server.url, server.accessToken, { name: 'public ' + server.serverNumber })
+      await server.videos.upload({ attributes: { name: 'public ' + server.serverNumber } })
 
       {
         const attributes = { name: 'unlisted ' + server.serverNumber, privacy: VideoPrivacy.UNLISTED }
-        await uploadVideo(server.url, server.accessToken, attributes)
+        await server.videos.upload({ attributes })
       }
 
       {
         const attributes = { name: 'private ' + server.serverNumber, privacy: VideoPrivacy.PRIVATE }
-        await uploadVideo(server.url, server.accessToken, attributes)
+        await server.videos.upload({ attributes })
       }
     }