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