]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/tests/api/videos/video-description.ts
emit more specific status codes on video upload (#3423)
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-description.ts
... / ...
CommitLineData
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import * as chai from 'chai'
4import 'mocha'
5import {
6 cleanupTests,
7 flushAndRunMultipleServers,
8 getVideo,
9 getVideoDescription,
10 getVideosList,
11 ServerInfo,
12 setAccessTokensToServers,
13 updateVideo,
14 uploadVideo
15} from '../../../../shared/extra-utils/index'
16import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
17import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
18
19const expect = chai.expect
20
21describe('Test video description', function () {
22 let servers: ServerInfo[] = []
23 let videoUUID = ''
24 let videoId: number
25 const longDescription = 'my super description for server 1'.repeat(50)
26
27 before(async function () {
28 this.timeout(40000)
29
30 // Run servers
31 servers = await flushAndRunMultipleServers(2)
32
33 // Get the access tokens
34 await setAccessTokensToServers(servers)
35
36 // Server 1 and server 2 follow each other
37 await doubleFollow(servers[0], servers[1])
38 })
39
40 it('Should upload video with long description', async function () {
41 this.timeout(10000)
42
43 const attributes = {
44 description: longDescription
45 }
46 await uploadVideo(servers[0].url, servers[0].accessToken, attributes)
47
48 await waitJobs(servers)
49
50 const res = await getVideosList(servers[0].url)
51
52 videoId = res.body.data[0].id
53 videoUUID = res.body.data[0].uuid
54 })
55
56 it('Should have a truncated description on each server', async function () {
57 for (const server of servers) {
58 const res = await getVideo(server.url, videoUUID)
59 const video = res.body
60
61 // 30 characters * 6 -> 240 characters
62 const truncatedDescription = 'my super description for server 1'.repeat(7) +
63 'my super descrip...'
64
65 expect(video.description).to.equal(truncatedDescription)
66 }
67 })
68
69 it('Should fetch long description on each server', async function () {
70 for (const server of servers) {
71 const res = await getVideo(server.url, videoUUID)
72 const video = res.body
73
74 const res2 = await getVideoDescription(server.url, video.descriptionPath)
75 expect(res2.body.description).to.equal(longDescription)
76 }
77 })
78
79 it('Should update with a short description', async function () {
80 this.timeout(10000)
81
82 const attributes = {
83 description: 'short description'
84 }
85 await updateVideo(servers[0].url, servers[0].accessToken, videoId, attributes)
86
87 await waitJobs(servers)
88 })
89
90 it('Should have a small description on each server', async function () {
91 for (const server of servers) {
92 const res = await getVideo(server.url, videoUUID)
93 const video = res.body
94
95 expect(video.description).to.equal('short description')
96
97 const res2 = await getVideoDescription(server.url, video.descriptionPath)
98 expect(res2.body.description).to.equal('short description')
99 }
100 })
101
102 after(async function () {
103 await cleanupTests(servers)
104 })
105})