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