]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/video-description.ts
Federate entire description
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-description.ts
index 6ac9206f584171700446f36e9d7ff7d7d0f47bcd..c4185882a3d1b167a3fa3901578942a3f7751d62 100644 (file)
@@ -1,22 +1,30 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
-import * as chai from 'chai'
-import { cleanupTests, doubleFollow, flushAndRunMultipleServers, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
-
-const expect = chai.expect
+import { expect } from 'chai'
+import {
+  cleanupTests,
+  createMultipleServers,
+  doubleFollow,
+  PeerTubeServer,
+  setAccessTokensToServers,
+  waitJobs
+} from '@shared/server-commands'
 
 describe('Test video description', function () {
-  let servers: ServerInfo[] = []
+  let servers: PeerTubeServer[] = []
   let videoUUID = ''
   let videoId: number
+
   const longDescription = 'my super description for server 1'.repeat(50)
 
+  // 30 characters * 6 -> 240 characters
+  const truncatedDescription = 'my super description for server 1'.repeat(7) + 'my super descrip...'
+
   before(async function () {
     this.timeout(40000)
 
     // Run servers
-    servers = await flushAndRunMultipleServers(2)
+    servers = await createMultipleServers(2)
 
     // Get the access tokens
     await setAccessTokensToServers(servers)
@@ -26,38 +34,45 @@ describe('Test video description', function () {
   })
 
   it('Should upload video with long description', async function () {
-    this.timeout(10000)
+    this.timeout(30000)
 
     const attributes = {
       description: longDescription
     }
-    await servers[0].videosCommand.upload({ attributes })
+    await servers[0].videos.upload({ attributes })
 
     await waitJobs(servers)
 
-    const { data } = await servers[0].videosCommand.list()
+    const { data } = await servers[0].videos.list()
 
     videoId = data[0].id
     videoUUID = data[0].uuid
   })
 
-  it('Should have a truncated description on each server', async function () {
+  it('Should have a truncated description on each server when listing videos', async function () {
     for (const server of servers) {
-      const video = await server.videosCommand.get({ id: videoUUID })
-
-      // 30 characters * 6 -> 240 characters
-      const truncatedDescription = 'my super description for server 1'.repeat(7) +
-        'my super descrip...'
+      const { data } = await server.videos.list()
+      const video = data.find(v => v.uuid === videoUUID)
 
       expect(video.description).to.equal(truncatedDescription)
+      expect(video.truncatedDescription).to.equal(truncatedDescription)
+    }
+  })
+
+  it('Should not have a truncated description on each server when getting videos', async function () {
+    for (const server of servers) {
+      const video = await server.videos.get({ id: videoUUID })
+
+      expect(video.description).to.equal(longDescription)
+      expect(video.truncatedDescription).to.equal(truncatedDescription)
     }
   })
 
   it('Should fetch long description on each server', async function () {
     for (const server of servers) {
-      const video = await server.videosCommand.get({ id: videoUUID })
+      const video = await server.videos.get({ id: videoUUID })
 
-      const { description } = await server.videosCommand.getDescription({ descriptionPath: video.descriptionPath })
+      const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
       expect(description).to.equal(longDescription)
     }
   })
@@ -68,18 +83,18 @@ describe('Test video description', function () {
     const attributes = {
       description: 'short description'
     }
-    await servers[0].videosCommand.update({ id: videoId, attributes })
+    await servers[0].videos.update({ id: videoId, attributes })
 
     await waitJobs(servers)
   })
 
   it('Should have a small description on each server', async function () {
     for (const server of servers) {
-      const video = await server.videosCommand.get({ id: videoUUID })
+      const video = await server.videos.get({ id: videoUUID })
 
       expect(video.description).to.equal('short description')
 
-      const { description } = await server.videosCommand.getDescription({ descriptionPath: video.descriptionPath })
+      const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
       expect(description).to.equal('short description')
     }
   })