]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/search/search-playlists.ts
Add runner server tests
[github/Chocobozzz/PeerTube.git] / server / tests / api / search / search-playlists.ts
index e7e53ff411afee0b1b2a88f9273b9b2975f1fa20..a357674c289c84cd2fdcef62f965483a5f44d135 100644 (file)
@@ -1,7 +1,7 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
-import * as chai from 'chai'
+import { expect } from 'chai'
+import { VideoPlaylistPrivacy } from '@shared/models'
 import {
   cleanupTests,
   createSingleServer,
@@ -9,25 +9,34 @@ import {
   PeerTubeServer,
   SearchCommand,
   setAccessTokensToServers,
+  setDefaultAccountAvatar,
+  setDefaultChannelAvatar,
   setDefaultVideoChannel
-} from '@shared/extra-utils'
-import { VideoPlaylistPrivacy } from '@shared/models'
-
-const expect = chai.expect
+} from '@shared/server-commands'
 
 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)
+    ])
+    server = servers[0]
+    remoteServer = servers[1]
 
     await setAccessTokensToServers([ remoteServer, server ])
     await setDefaultVideoChannel([ remoteServer, server ])
+    await setDefaultChannelAvatar([ remoteServer, server ])
+    await setDefaultAccountAvatar([ remoteServer, server ])
+
+    await servers[1].config.disableTranscoding()
 
     {
       const videoId = (await server.videos.upload()).uuid
@@ -38,6 +47,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 +147,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 +175,6 @@ describe('Test playlists search', function () {
   })
 
   after(async function () {
-    await cleanupTests([ server ])
+    await cleanupTests([ server, remoteServer ])
   })
 })