]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/services.ts
Fix audio encoding params
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / services.ts
index 457adfaabf0033f2ce43e5ac01dd0d806b1331c0..e57edd9e4aee68ad98d575e85a33a05f1de4b0eb 100644 (file)
@@ -8,11 +8,15 @@ import {
   makeGetRequest,
   ServerInfo,
   setAccessTokensToServers,
-  uploadVideo
+  uploadVideo,
+  createVideoPlaylist,
+  setDefaultVideoChannel
 } from '../../../../shared/extra-utils'
+import { VideoPlaylistPrivacy } from '@shared/models'
 
 describe('Test services API validators', function () {
   let server: ServerInfo
+  let playlistUUID: string
 
   // ---------------------------------------------------------------
 
@@ -21,9 +25,26 @@ describe('Test services API validators', function () {
 
     server = await flushAndRunServer(1)
     await setAccessTokensToServers([ server ])
-
-    const res = await uploadVideo(server.url, server.accessToken, { name: 'my super name' })
-    server.video = res.body.video
+    await setDefaultVideoChannel([ server ])
+
+    {
+      const res = await uploadVideo(server.url, server.accessToken, { name: 'my super name' })
+      server.video = res.body.video
+    }
+
+    {
+      const res = await createVideoPlaylist({
+        url: server.url,
+        token: server.accessToken,
+        playlistAttrs: {
+          displayName: 'super playlist',
+          privacy: VideoPlaylistPrivacy.PUBLIC,
+          videoChannelId: server.videoChannel.id
+        }
+      })
+
+      playlistUUID = res.body.videoPlaylist.uuid
+    }
   })
 
   describe('Test oEmbed API validators', function () {
@@ -38,12 +59,12 @@ describe('Test services API validators', function () {
       await checkParamEmbed(server, embedUrl)
     })
 
-    it('Should fail with an invalid video id', async function () {
+    it('Should fail with an invalid element id', async function () {
       const embedUrl = `http://localhost:${server.port}/videos/watch/blabla`
       await checkParamEmbed(server, embedUrl)
     })
 
-    it('Should fail with an unknown video', async function () {
+    it('Should fail with an unknown element', async function () {
       const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c`
       await checkParamEmbed(server, embedUrl, 404)
     })
@@ -78,7 +99,7 @@ describe('Test services API validators', function () {
       await checkParamEmbed(server, embedUrl, 501, { format: 'xml' })
     })
 
-    it('Should succeed with the correct params', async function () {
+    it('Should succeed with the correct params with a video', async function () {
       const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
       const query = {
         format: 'json',
@@ -88,6 +109,17 @@ describe('Test services API validators', function () {
 
       await checkParamEmbed(server, embedUrl, 200, query)
     })
+
+    it('Should succeed with the correct params with a playlist', async function () {
+      const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${playlistUUID}`
+      const query = {
+        format: 'json',
+        maxheight: 400,
+        maxwidth: 400
+      }
+
+      await checkParamEmbed(server, embedUrl, 200, query)
+    })
   })
 
   after(async function () {