]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/services.ts
Introduce playlist command
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / services.ts
index ea64e4040b79693b6c36319e3344e05b217d5e77..77b95de103e976720b657ab6ed55d0503d5bc6d7 100644 (file)
@@ -4,9 +4,6 @@ import 'mocha'
 import * as chai from 'chai'
 import { Video, VideoPlaylistPrivacy } from '@shared/models'
 import {
-  addVideoInPlaylist,
-  createVideoPlaylist,
-  getOEmbed,
   getVideosList,
   ServerInfo,
   setAccessTokensToServers,
@@ -42,24 +39,20 @@ describe('Test services', function () {
     }
 
     {
-      const res = await createVideoPlaylist({
-        url: server.url,
-        token: server.accessToken,
-        playlistAttrs: {
+      const created = await server.playlistsCommand.create({
+        attributes: {
           displayName: 'The Life and Times of Scrooge McDuck',
           privacy: VideoPlaylistPrivacy.PUBLIC,
           videoChannelId: server.videoChannel.id
         }
       })
 
-      playlistUUID = res.body.videoPlaylist.uuid
+      playlistUUID = created.uuid
       playlistDisplayName = 'The Life and Times of Scrooge McDuck'
 
-      await addVideoInPlaylist({
-        url: server.url,
-        token: server.accessToken,
-        playlistId: res.body.videoPlaylist.id,
-        elementAttrs: {
+      await server.playlistsCommand.addElement({
+        playlistId: created.id,
+        attributes: {
           videoId: video.id
         }
       })
@@ -70,7 +63,7 @@ describe('Test services', function () {
     for (const basePath of [ '/videos/watch/', '/w/' ]) {
       const oembedUrl = 'http://localhost:' + server.port + basePath + video.uuid
 
-      const res = await getOEmbed(server.url, oembedUrl)
+      const res = await server.servicesCommand.getOEmbed({ oembedUrl })
       const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
         `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
         'frameborder="0" allowfullscreen></iframe>'
@@ -91,7 +84,7 @@ describe('Test services', function () {
     for (const basePath of [ '/videos/watch/playlist/', '/w/p/' ]) {
       const oembedUrl = 'http://localhost:' + server.port + basePath + playlistUUID
 
-      const res = await getOEmbed(server.url, oembedUrl)
+      const res = await server.servicesCommand.getOEmbed({ oembedUrl })
       const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
         `title="${playlistDisplayName}" src="http://localhost:${server.port}/video-playlists/embed/${playlistUUID}" ` +
         'frameborder="0" allowfullscreen></iframe>'
@@ -114,7 +107,7 @@ describe('Test services', function () {
       const maxHeight = 50
       const maxWidth = 50
 
-      const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
+      const res = await server.servicesCommand.getOEmbed({ oembedUrl, format, maxHeight, maxWidth })
       const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
         `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
         'frameborder="0" allowfullscreen></iframe>'