]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/search/search-playlists.ts
shared/ typescript types dir server-commands
[github/Chocobozzz/PeerTube.git] / server / tests / api / search / search-playlists.ts
index e7e53ff411afee0b1b2a88f9273b9b2975f1fa20..1e9c8d4bb1ba46721d9f474097c45447b6a1d0f0 100644 (file)
@@ -10,7 +10,7 @@ import {
   SearchCommand,
   setAccessTokensToServers,
   setDefaultVideoChannel
-} from '@shared/extra-utils'
+} from '@shared/server-commands'
 import { VideoPlaylistPrivacy } from '@shared/models'
 
 const expect = chai.expect
@@ -19,12 +19,18 @@ describe('Test playlists search', function () {
   let server: PeerTubeServer
   let remoteServer: PeerTubeServer
   let command: SearchCommand
+  let playlistUUID: string
+  let playlistShortUUID: string
 
   before(async function () {
     this.timeout(120000)
 
-    server = await createSingleServer(1)
-    remoteServer = await createSingleServer(2, { transcoding: { enabled: false } })
+    const servers = await Promise.all([
+      createSingleServer(1),
+      createSingleServer(2, { transcoding: { enabled: false } })
+    ])
+    server = servers[0]
+    remoteServer = servers[1]
 
     await setAccessTokensToServers([ remoteServer, server ])
     await setDefaultVideoChannel([ remoteServer, server ])
@@ -38,6 +44,8 @@ describe('Test playlists search', function () {
         videoChannelId: server.store.channel.id
       }
       const created = await server.playlists.create({ attributes })
+      playlistUUID = created.uuid
+      playlistShortUUID = created.shortUUID
 
       await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } })
     }
@@ -136,6 +144,22 @@ describe('Test playlists search', function () {
     }
   })
 
+  it('Should filter by UUIDs', async function () {
+    for (const uuid of [ playlistUUID, playlistShortUUID ]) {
+      const body = await command.advancedPlaylistSearch({ search: { uuids: [ uuid ] } })
+
+      expect(body.total).to.equal(1)
+      expect(body.data[0].displayName).to.equal('Dr. Kenzo Tenma hospital videos')
+    }
+
+    {
+      const body = await command.advancedPlaylistSearch({ search: { uuids: [ 'dfd70b83-639f-4980-94af-304a56ab4b35' ] } })
+
+      expect(body.total).to.equal(0)
+      expect(body.data).to.have.lengthOf(0)
+    }
+  })
+
   it('Should not display playlists without videos', async function () {
     const search = {
       search: 'Lunge',
@@ -148,6 +172,6 @@ describe('Test playlists search', function () {
   })
 
   after(async function () {
-    await cleanupTests([ server ])
+    await cleanupTests([ server, remoteServer ])
   })
 })