]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/live/live-views.ts
Added 144p encoding (#4492)
[github/Chocobozzz/PeerTube.git] / server / tests / api / live / live-views.ts
index ae6af7cfdebf0c07a5674440edcf16b0760644cc..5e3a79c6415f9511e33fcc8f501bfabbb47dfe34 100644 (file)
@@ -3,17 +3,15 @@
 import 'mocha'
 import * as chai from 'chai'
 import { FfmpegCommand } from 'fluent-ffmpeg'
-import { VideoDetails, VideoPrivacy } from '@shared/models'
+import { VideoPrivacy } from '@shared/models'
 import {
   cleanupTests,
+  createMultipleServers,
   doubleFollow,
-  flushAndRunMultipleServers,
-  getVideo,
-  ServerInfo,
+  PeerTubeServer,
   setAccessTokensToServers,
   setDefaultVideoChannel,
   stopFfmpeg,
-  viewVideo,
   wait,
   waitJobs,
   waitUntilLivePublishedOnAllServers
@@ -22,18 +20,18 @@ import {
 const expect = chai.expect
 
 describe('Test live', function () {
-  let servers: ServerInfo[] = []
+  let servers: PeerTubeServer[] = []
 
   before(async function () {
     this.timeout(120000)
 
-    servers = await flushAndRunMultipleServers(2)
+    servers = await createMultipleServers(2)
 
     // Get the access tokens
     await setAccessTokensToServers(servers)
     await setDefaultVideoChannel(servers)
 
-    await servers[0].configCommand.updateCustomSubConfig({
+    await servers[0].config.updateCustomSubConfig({
       newConfig: {
         live: {
           enabled: true,
@@ -55,9 +53,7 @@ describe('Test live', function () {
 
     async function countViews (expected: number) {
       for (const server of servers) {
-        const res = await getVideo(server.url, liveVideoId)
-        const video: VideoDetails = res.body
-
+        const video = await server.videos.get({ id: liveVideoId })
         expect(video.views).to.equal(expected)
       }
     }
@@ -67,14 +63,14 @@ describe('Test live', function () {
 
       const liveAttributes = {
         name: 'live video',
-        channelId: servers[0].videoChannel.id,
+        channelId: servers[0].store.channel.id,
         privacy: VideoPrivacy.PUBLIC
       }
 
-      const live = await servers[0].liveCommand.createLive({ fields: liveAttributes })
+      const live = await servers[0].live.create({ fields: liveAttributes })
       liveVideoId = live.uuid
 
-      command = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId })
+      command = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId })
       await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
       await waitJobs(servers)
     })
@@ -86,8 +82,8 @@ describe('Test live', function () {
     it('Should view a live twice and display 1 view', async function () {
       this.timeout(30000)
 
-      await viewVideo(servers[0].url, liveVideoId)
-      await viewVideo(servers[0].url, liveVideoId)
+      await servers[0].videos.view({ id: liveVideoId })
+      await servers[0].videos.view({ id: liveVideoId })
 
       await wait(7000)
 
@@ -108,9 +104,9 @@ describe('Test live', function () {
     it('Should view a live on a remote and on local and display 2 views', async function () {
       this.timeout(30000)
 
-      await viewVideo(servers[0].url, liveVideoId)
-      await viewVideo(servers[1].url, liveVideoId)
-      await viewVideo(servers[1].url, liveVideoId)
+      await servers[0].videos.view({ id: liveVideoId })
+      await servers[1].videos.view({ id: liveVideoId })
+      await servers[1].videos.view({ id: liveVideoId })
 
       await wait(7000)
       await waitJobs(servers)