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