]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/video-description.ts
Check channel sync id is owned by channel
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-description.ts
index c2985194c5c026b9ddde917bf81fe25fe3b768d0..a74b78a5fe1c074f2cde1a7c1c4e20b2cbecb69f 100644 (file)
@@ -1,35 +1,26 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import * as chai from 'chai'
-import 'mocha'
+import { expect } from 'chai'
 import {
-  flushAndRunMultipleServers,
-  flushTests,
-  getVideo,
-  getVideoDescription,
-  getVideosList,
-  killallServers,
-  ServerInfo,
+  cleanupTests,
+  createMultipleServers,
+  doubleFollow,
+  PeerTubeServer,
   setAccessTokensToServers,
-  updateVideo,
-  uploadVideo,
-  wait
-} from '../../utils/index'
-import { doubleFollow } from '../../utils/server/follows'
-
-const expect = chai.expect
+  waitJobs
+} from '@shared/server-commands'
 
 describe('Test video description', function () {
-  let servers: ServerInfo[] = []
+  let servers: PeerTubeServer[] = []
   let videoUUID = ''
   let videoId: number
-  let longDescription = 'my super description for server 1'.repeat(50)
+  const longDescription = 'my super description for server 1'.repeat(50)
 
   before(async function () {
     this.timeout(40000)
 
     // Run servers
-    servers = await flushAndRunMultipleServers(2)
+    servers = await createMultipleServers(2)
 
     // Get the access tokens
     await setAccessTokensToServers(servers)
@@ -44,24 +35,23 @@ describe('Test video description', function () {
     const attributes = {
       description: longDescription
     }
-    await uploadVideo(servers[0].url, servers[0].accessToken, attributes)
+    await servers[0].videos.upload({ attributes })
 
-    await wait(5000)
+    await waitJobs(servers)
 
-    const res = await getVideosList(servers[0].url)
+    const { data } = await servers[0].videos.list()
 
-    videoId = res.body.data[0].id
-    videoUUID = res.body.data[0].uuid
+    videoId = data[0].id
+    videoUUID = data[0].uuid
   })
 
   it('Should have a truncated description on each server', async function () {
     for (const server of servers) {
-      const res = await getVideo(server.url, videoUUID)
-      const video = res.body
+      const video = await server.videos.get({ id: videoUUID })
 
       // 30 characters * 6 -> 240 characters
       const truncatedDescription = 'my super description for server 1'.repeat(7) +
-                                   'my super descrip...'
+        'my super descrip...'
 
       expect(video.description).to.equal(truncatedDescription)
     }
@@ -69,11 +59,10 @@ describe('Test video description', function () {
 
   it('Should fetch long description on each server', async function () {
     for (const server of servers) {
-      const res = await getVideo(server.url, videoUUID)
-      const video = res.body
+      const video = await server.videos.get({ id: videoUUID })
 
-      const res2 = await getVideoDescription(server.url, video.descriptionPath)
-      expect(res2.body.description).to.equal(longDescription)
+      const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
+      expect(description).to.equal(longDescription)
     }
   })
 
@@ -83,29 +72,23 @@ describe('Test video description', function () {
     const attributes = {
       description: 'short description'
     }
-    await updateVideo(servers[0].url, servers[0].accessToken, videoId, attributes)
+    await servers[0].videos.update({ id: videoId, attributes })
 
-    await wait(5000)
+    await waitJobs(servers)
   })
 
   it('Should have a small description on each server', async function () {
     for (const server of servers) {
-      const res = await getVideo(server.url, videoUUID)
-      const video = res.body
+      const video = await server.videos.get({ id: videoUUID })
 
       expect(video.description).to.equal('short description')
 
-      const res2 = await getVideoDescription(server.url, video.descriptionPath)
-      expect(res2.body.description).to.equal('short description')
+      const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
+      expect(description).to.equal('short description')
     }
   })
 
   after(async function () {
-    killallServers(servers)
-
-    // Keep the logs if the test failed
-    if (this['ok']) {
-      await flushTests()
-    }
+    await cleanupTests(servers)
   })
 })