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