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