]>
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 |
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 () { |
572f8d3d | 81 | this.timeout(10000) |
8bf89b09 C |
82 | |
83 | const attributes = { | |
84 | description: 'short description' | |
85 | } | |
89d241a7 | 86 | await servers[0].videos.update({ id: videoId, attributes }) |
8bf89b09 | 87 | |
3cd0734f | 88 | await waitJobs(servers) |
8bf89b09 C |
89 | }) |
90 | ||
975e6e0e | 91 | it('Should have a small description on each server', async function () { |
8bf89b09 | 92 | for (const server of servers) { |
89d241a7 | 93 | const video = await server.videos.get({ id: videoUUID }) |
8bf89b09 C |
94 | |
95 | expect(video.description).to.equal('short description') | |
96 | ||
89d241a7 | 97 | const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath }) |
d23dd9fb | 98 | expect(description).to.equal('short description') |
8bf89b09 C |
99 | } |
100 | }) | |
101 | ||
7c3b7976 C |
102 | after(async function () { |
103 | await cleanupTests(servers) | |
9567011b C |
104 | }) |
105 | }) |