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