]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/search/search-playlists.ts
Rename captions commands
[github/Chocobozzz/PeerTube.git] / server / tests / api / search / search-playlists.ts
index 1862ecd31484c22f2e95237594f5d7ae1e255b2c..22e9b8fca08d132e0d5ad09b1ed8c0d3d61afea2 100644 (file)
@@ -2,77 +2,64 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import { VideoPlaylistPrivacy } from '@shared/models'
 import {
-  addVideoInPlaylist,
   cleanupTests,
-  createVideoPlaylist,
-  flushAndRunServer,
+  createSingleServer,
+  PeerTubeServer,
   SearchCommand,
-  ServerInfo,
   setAccessTokensToServers,
-  setDefaultVideoChannel,
-  uploadVideoAndGetId
-} from '../../../../shared/extra-utils'
+  setDefaultVideoChannel
+} from '@shared/extra-utils'
+import { VideoPlaylistPrivacy } from '@shared/models'
 
 const expect = chai.expect
 
 describe('Test playlists search', function () {
-  let server: ServerInfo = null
+  let server: PeerTubeServer = null
   let command: SearchCommand
 
   before(async function () {
     this.timeout(30000)
 
-    server = await flushAndRunServer(1)
+    server = await createSingleServer(1)
 
     await setAccessTokensToServers([ server ])
     await setDefaultVideoChannel([ server ])
 
-    const videoId = (await uploadVideoAndGetId({ server: server, videoName: 'video' })).uuid
+    const videoId = (await server.videos.quickUpload({ name: 'video' })).uuid
 
     {
       const attributes = {
         displayName: 'Dr. Kenzo Tenma hospital videos',
         privacy: VideoPlaylistPrivacy.PUBLIC,
-        videoChannelId: server.videoChannel.id
+        videoChannelId: server.store.channel.id
       }
-      const res = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes })
-
-      await addVideoInPlaylist({
-        url: server.url,
-        token: server.accessToken,
-        playlistId: res.body.videoPlaylist.id,
-        elementAttrs: { videoId }
-      })
+      const created = await server.playlists.create({ attributes })
+
+      await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } })
     }
 
     {
       const attributes = {
         displayName: 'Johan & Anna Libert musics',
         privacy: VideoPlaylistPrivacy.PUBLIC,
-        videoChannelId: server.videoChannel.id
+        videoChannelId: server.store.channel.id
       }
-      const res = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes })
-
-      await addVideoInPlaylist({
-        url: server.url,
-        token: server.accessToken,
-        playlistId: res.body.videoPlaylist.id,
-        elementAttrs: { videoId }
-      })
+      const created = await server.playlists.create({ attributes })
+
+      await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } })
     }
 
     {
       const attributes = {
         displayName: 'Inspector Lunge playlist',
         privacy: VideoPlaylistPrivacy.PUBLIC,
-        videoChannelId: server.videoChannel.id
+        videoChannelId: server.store.channel.id
       }
-      await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes })
+      await server.playlists.create({ attributes })
     }
 
-    command = server.searchCommand
+    command = server.search
   })
 
   it('Should make a simple search and not have results', async function () {