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