]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/video-playlists.ts
Fix server run
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / video-playlists.ts
index 1c507a047e593c6eecc5ef9def308bf803b46e49..9d054b1765cd96fd11a22f8190f7aab322bd8b8f 100644 (file)
@@ -1,6 +1,19 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
+import { HttpStatusCode } from '@shared/core-utils'
+import {
+  checkBadCountPagination,
+  checkBadSortPagination,
+  checkBadStartPagination,
+  cleanupTests,
+  createSingleServer,
+  makeGetRequest,
+  PlaylistsCommand,
+  PeerTubeServer,
+  setAccessTokensToServers,
+  setDefaultVideoChannel
+} from '@shared/extra-utils'
 import {
   VideoPlaylistCreate,
   VideoPlaylistCreateResult,
@@ -10,25 +23,9 @@ import {
   VideoPlaylistReorder,
   VideoPlaylistType
 } from '@shared/models'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
-import {
-  checkBadCountPagination,
-  checkBadSortPagination,
-  checkBadStartPagination,
-  cleanupTests,
-  flushAndRunServer,
-  generateUserAccessToken,
-  immutableAssign,
-  makeGetRequest,
-  PlaylistsCommand,
-  ServerInfo,
-  setAccessTokensToServers,
-  setDefaultVideoChannel,
-  uploadVideoAndGetId
-} from '../../../../shared/extra-utils'
 
 describe('Test video playlists API validator', function () {
-  let server: ServerInfo
+  let server: PeerTubeServer
   let userAccessToken: string
 
   let playlist: VideoPlaylistCreateResult
@@ -45,15 +42,15 @@ describe('Test video playlists API validator', function () {
   before(async function () {
     this.timeout(30000)
 
-    server = await flushAndRunServer(1)
+    server = await createSingleServer(1)
 
     await setAccessTokensToServers([ server ])
     await setDefaultVideoChannel([ server ])
 
-    userAccessToken = await generateUserAccessToken(server, 'user1')
-    videoId = (await uploadVideoAndGetId({ server, videoName: 'video 1' })).id
+    userAccessToken = await server.users.generateUserAndToken('user1')
+    videoId = (await server.videos.quickUpload({ name: 'video 1' })).id
 
-    command = server.playlistsCommand
+    command = server.playlists
 
     {
       const { data } = await command.listByAccount({
@@ -71,7 +68,7 @@ describe('Test video playlists API validator', function () {
         attributes: {
           displayName: 'super playlist',
           privacy: VideoPlaylistPrivacy.PUBLIC,
-          videoChannelId: server.videoChannel.id
+          videoChannelId: server.store.channel.id
         }
       })
     }
@@ -179,7 +176,7 @@ describe('Test video playlists API validator', function () {
       const playlist = await command.create({
         attributes: {
           displayName: 'super playlist',
-          videoChannelId: server.videoChannel.id,
+          videoChannelId: server.store.channel.id,
           privacy: VideoPlaylistPrivacy.UNLISTED
         }
       })
@@ -203,7 +200,7 @@ describe('Test video playlists API validator', function () {
           displayName: 'display name',
           privacy: VideoPlaylistPrivacy.UNLISTED,
           thumbnailfile: 'thumbnail.jpg',
-          videoChannelId: server.videoChannel.id,
+          videoChannelId: server.store.channel.id,
 
           ...attributes
         },
@@ -214,7 +211,7 @@ describe('Test video playlists API validator', function () {
       }
     }
     const getUpdate = (params: any, playlistId: number | string) => {
-      return immutableAssign(params, { playlistId: playlistId })
+      return { ...params, playlistId: playlistId }
     }
 
     it('Should fail with an unauthenticated user', async function () {
@@ -488,8 +485,8 @@ describe('Test video playlists API validator', function () {
     }
 
     before(async function () {
-      videoId3 = (await uploadVideoAndGetId({ server, videoName: 'video 3' })).id
-      videoId4 = (await uploadVideoAndGetId({ server, videoName: 'video 4' })).id
+      videoId3 = (await server.videos.quickUpload({ name: 'video 3' })).id
+      videoId4 = (await server.videos.quickUpload({ name: 'video 4' })).id
 
       for (const id of [ videoId3, videoId4 ]) {
         await command.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: id } })