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