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