]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/videos/video-description.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-description.ts
CommitLineData
a1587156 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
9567011b 2
86347717 3import { expect } from 'chai'
c55e3d72
C
4import {
5 cleanupTests,
6 createMultipleServers,
7 doubleFollow,
8 PeerTubeServer,
9 setAccessTokensToServers,
10 waitJobs
11} from '@shared/server-commands'
9567011b 12
9567011b 13describe('Test video description', function () {
254d3579 14 let servers: PeerTubeServer[] = []
9567011b 15 let videoUUID = ''
8bf89b09 16 let videoId: number
f713f36b 17
a1587156 18 const longDescription = 'my super description for server 1'.repeat(50)
9567011b 19
f713f36b
C
20 // 30 characters * 6 -> 240 characters
21 const truncatedDescription = 'my super description for server 1'.repeat(7) + 'my super descrip...'
22
9567011b 23 before(async function () {
572f8d3d 24 this.timeout(40000)
9567011b
C
25
26 // Run servers
254d3579 27 servers = await createMultipleServers(2)
9567011b
C
28
29 // Get the access tokens
30 await setAccessTokensToServers(servers)
31
975e6e0e
C
32 // Server 1 and server 2 follow each other
33 await doubleFollow(servers[0], servers[1])
9567011b
C
34 })
35
36 it('Should upload video with long description', async function () {
3c4754a3 37 this.timeout(30000)
9567011b
C
38
39 const attributes = {
40 description: longDescription
41 }
89d241a7 42 await servers[0].videos.upload({ attributes })
9567011b 43
3cd0734f 44 await waitJobs(servers)
9567011b 45
89d241a7 46 const { data } = await servers[0].videos.list()
9567011b 47
d23dd9fb
C
48 videoId = data[0].id
49 videoUUID = data[0].uuid
9567011b
C
50 })
51
f713f36b 52 it('Should have a truncated description on each server when listing videos', async function () {
9567011b 53 for (const server of servers) {
f713f36b
C
54 const { data } = await server.videos.list()
55 const video = data.find(v => v.uuid === videoUUID)
9567011b
C
56
57 expect(video.description).to.equal(truncatedDescription)
f713f36b
C
58 expect(video.truncatedDescription).to.equal(truncatedDescription)
59 }
60 })
61
62 it('Should not have a truncated description on each server when getting videos', async function () {
63 for (const server of servers) {
64 const video = await server.videos.get({ id: videoUUID })
65
66 expect(video.description).to.equal(longDescription)
67 expect(video.truncatedDescription).to.equal(truncatedDescription)
9567011b
C
68 }
69 })
70
975e6e0e 71 it('Should fetch long description on each server', async function () {
9567011b 72 for (const server of servers) {
89d241a7 73 const video = await server.videos.get({ id: videoUUID })
9567011b 74
89d241a7 75 const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
d23dd9fb 76 expect(description).to.equal(longDescription)
9567011b
C
77 }
78 })
79
8bf89b09 80 it('Should update with a short description', async function () {
8bf89b09
C
81 const attributes = {
82 description: 'short description'
83 }
89d241a7 84 await servers[0].videos.update({ id: videoId, attributes })
8bf89b09 85
3cd0734f 86 await waitJobs(servers)
8bf89b09
C
87 })
88
975e6e0e 89 it('Should have a small description on each server', async function () {
8bf89b09 90 for (const server of servers) {
89d241a7 91 const video = await server.videos.get({ id: videoUUID })
8bf89b09
C
92
93 expect(video.description).to.equal('short description')
94
89d241a7 95 const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
d23dd9fb 96 expect(description).to.equal('short description')
8bf89b09
C
97 }
98 })
99
7c3b7976
C
100 after(async function () {
101 await cleanupTests(servers)
9567011b
C
102 })
103})