1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
7 const expect = chai.expect
9 describe('Test video description', function () {
10 let servers: PeerTubeServer[] = []
13 const longDescription = 'my super description for server 1'.repeat(50)
15 before(async function () {
19 servers = await createMultipleServers(2)
21 // Get the access tokens
22 await setAccessTokensToServers(servers)
24 // Server 1 and server 2 follow each other
25 await doubleFollow(servers[0], servers[1])
28 it('Should upload video with long description', async function () {
32 description: longDescription
34 await servers[0].videos.upload({ attributes })
36 await waitJobs(servers)
38 const { data } = await servers[0].videos.list()
41 videoUUID = data[0].uuid
44 it('Should have a truncated description on each server', async function () {
45 for (const server of servers) {
46 const video = await server.videos.get({ id: videoUUID })
48 // 30 characters * 6 -> 240 characters
49 const truncatedDescription = 'my super description for server 1'.repeat(7) +
52 expect(video.description).to.equal(truncatedDescription)
56 it('Should fetch long description on each server', async function () {
57 for (const server of servers) {
58 const video = await server.videos.get({ id: videoUUID })
60 const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
61 expect(description).to.equal(longDescription)
65 it('Should update with a short description', async function () {
69 description: 'short description'
71 await servers[0].videos.update({ id: videoId, attributes })
73 await waitJobs(servers)
76 it('Should have a small description on each server', async function () {
77 for (const server of servers) {
78 const video = await server.videos.get({ id: videoUUID })
80 expect(video.description).to.equal('short description')
82 const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
83 expect(description).to.equal('short description')
87 after(async function () {
88 await cleanupTests(servers)