]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/videos/video-description.ts
Federate entire description
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-description.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import { expect } from 'chai'
4 import {
5 cleanupTests,
6 createMultipleServers,
7 doubleFollow,
8 PeerTubeServer,
9 setAccessTokensToServers,
10 waitJobs
11 } from '@shared/server-commands'
12
13 describe('Test video description', function () {
14 let servers: PeerTubeServer[] = []
15 let videoUUID = ''
16 let videoId: number
17
18 const longDescription = 'my super description for server 1'.repeat(50)
19
20 // 30 characters * 6 -> 240 characters
21 const truncatedDescription = 'my super description for server 1'.repeat(7) + 'my super descrip...'
22
23 before(async function () {
24 this.timeout(40000)
25
26 // Run servers
27 servers = await createMultipleServers(2)
28
29 // Get the access tokens
30 await setAccessTokensToServers(servers)
31
32 // Server 1 and server 2 follow each other
33 await doubleFollow(servers[0], servers[1])
34 })
35
36 it('Should upload video with long description', async function () {
37 this.timeout(30000)
38
39 const attributes = {
40 description: longDescription
41 }
42 await servers[0].videos.upload({ attributes })
43
44 await waitJobs(servers)
45
46 const { data } = await servers[0].videos.list()
47
48 videoId = data[0].id
49 videoUUID = data[0].uuid
50 })
51
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)
56
57 expect(video.description).to.equal(truncatedDescription)
58 expect(video.truncatedDescription).to.equal(truncatedDescription)
59 }
60 })
61
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 })
65
66 expect(video.description).to.equal(longDescription)
67 expect(video.truncatedDescription).to.equal(truncatedDescription)
68 }
69 })
70
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 })
74
75 const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
76 expect(description).to.equal(longDescription)
77 }
78 })
79
80 it('Should update with a short description', async function () {
81 this.timeout(10000)
82
83 const attributes = {
84 description: 'short description'
85 }
86 await servers[0].videos.update({ id: videoId, attributes })
87
88 await waitJobs(servers)
89 })
90
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 })
94
95 expect(video.description).to.equal('short description')
96
97 const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
98 expect(description).to.equal('short description')
99 }
100 })
101
102 after(async function () {
103 await cleanupTests(servers)
104 })
105 })