1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { expect } from 'chai'
9 setAccessTokensToServers,
11 } from '@shared/server-commands'
13 describe('Test video description', function () {
14 let servers: PeerTubeServer[] = []
18 const longDescription = 'my super description for server 1'.repeat(50)
20 // 30 characters * 6 -> 240 characters
21 const truncatedDescription = 'my super description for server 1'.repeat(7) + 'my super descrip...'
23 before(async function () {
27 servers = await createMultipleServers(2)
29 // Get the access tokens
30 await setAccessTokensToServers(servers)
32 // Server 1 and server 2 follow each other
33 await doubleFollow(servers[0], servers[1])
36 it('Should upload video with long description', async function () {
40 description: longDescription
42 await servers[0].videos.upload({ attributes })
44 await waitJobs(servers)
46 const { data } = await servers[0].videos.list()
49 videoUUID = data[0].uuid
52 it('Should have a truncated description on each server when listing videos', async function () {
53 for (const server of servers) {
54 const { data } = await server.videos.list()
55 const video = data.find(v => v.uuid === videoUUID)
57 expect(video.description).to.equal(truncatedDescription)
58 expect(video.truncatedDescription).to.equal(truncatedDescription)
62 it('Should not have a truncated description on each server when getting videos', async function () {
63 for (const server of servers) {
64 const video = await server.videos.get({ id: videoUUID })
66 expect(video.description).to.equal(longDescription)
67 expect(video.truncatedDescription).to.equal(truncatedDescription)
71 it('Should fetch long description on each server', async function () {
72 for (const server of servers) {
73 const video = await server.videos.get({ id: videoUUID })
75 const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
76 expect(description).to.equal(longDescription)
80 it('Should update with a short description', async function () {
84 description: 'short description'
86 await servers[0].videos.update({ id: videoId, attributes })
88 await waitJobs(servers)
91 it('Should have a small description on each server', async function () {
92 for (const server of servers) {
93 const video = await server.videos.get({ id: videoUUID })
95 expect(video.description).to.equal('short description')
97 const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
98 expect(description).to.equal('short description')
102 after(async function () {
103 await cleanupTests(servers)