]>
Commit | Line | Data |
---|---|---|
9567011b C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
9567011b | 3 | import * as chai from 'chai' |
975e6e0e | 4 | import 'mocha' |
9567011b C |
5 | import { |
6 | flushAndRunMultipleServers, | |
9567011b | 7 | getVideo, |
975e6e0e | 8 | getVideoDescription, |
9567011b C |
9 | getVideosList, |
10 | killallServers, | |
9567011b C |
11 | ServerInfo, |
12 | setAccessTokensToServers, | |
975e6e0e | 13 | updateVideo, |
3cd0734f | 14 | uploadVideo |
c5d31dba C |
15 | } from '../../utils/index' |
16 | import { doubleFollow } from '../../utils/server/follows' | |
3cd0734f | 17 | import { waitJobs } from '../../utils/server/jobs' |
9567011b C |
18 | |
19 | const expect = chai.expect | |
20 | ||
21 | describe('Test video description', function () { | |
22 | let servers: ServerInfo[] = [] | |
23 | let videoUUID = '' | |
8bf89b09 | 24 | let videoId: number |
975e6e0e | 25 | let longDescription = 'my super description for server 1'.repeat(50) |
9567011b C |
26 | |
27 | before(async function () { | |
572f8d3d | 28 | this.timeout(40000) |
9567011b C |
29 | |
30 | // Run servers | |
31 | servers = await flushAndRunMultipleServers(2) | |
32 | ||
33 | // Get the access tokens | |
34 | await setAccessTokensToServers(servers) | |
35 | ||
975e6e0e C |
36 | // Server 1 and server 2 follow each other |
37 | await doubleFollow(servers[0], servers[1]) | |
9567011b C |
38 | }) |
39 | ||
40 | it('Should upload video with long description', async function () { | |
572f8d3d | 41 | this.timeout(10000) |
9567011b C |
42 | |
43 | const attributes = { | |
44 | description: longDescription | |
45 | } | |
46 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | |
47 | ||
3cd0734f | 48 | await waitJobs(servers) |
9567011b C |
49 | |
50 | const res = await getVideosList(servers[0].url) | |
51 | ||
8bf89b09 | 52 | videoId = res.body.data[0].id |
9567011b C |
53 | videoUUID = res.body.data[0].uuid |
54 | }) | |
55 | ||
975e6e0e | 56 | it('Should have a truncated description on each server', async function () { |
9567011b C |
57 | for (const server of servers) { |
58 | const res = await getVideo(server.url, videoUUID) | |
59 | const video = res.body | |
60 | ||
61 | // 30 characters * 6 -> 240 characters | |
975e6e0e C |
62 | const truncatedDescription = 'my super description for server 1'.repeat(7) + |
63 | 'my super descrip...' | |
9567011b C |
64 | |
65 | expect(video.description).to.equal(truncatedDescription) | |
66 | } | |
67 | }) | |
68 | ||
975e6e0e | 69 | it('Should fetch long description on each server', async function () { |
9567011b C |
70 | for (const server of servers) { |
71 | const res = await getVideo(server.url, videoUUID) | |
72 | const video = res.body | |
73 | ||
74 | const res2 = await getVideoDescription(server.url, video.descriptionPath) | |
75 | expect(res2.body.description).to.equal(longDescription) | |
76 | } | |
77 | }) | |
78 | ||
8bf89b09 | 79 | it('Should update with a short description', async function () { |
572f8d3d | 80 | this.timeout(10000) |
8bf89b09 C |
81 | |
82 | const attributes = { | |
83 | description: 'short description' | |
84 | } | |
85 | await updateVideo(servers[0].url, servers[0].accessToken, videoId, attributes) | |
86 | ||
3cd0734f | 87 | await waitJobs(servers) |
8bf89b09 C |
88 | }) |
89 | ||
975e6e0e | 90 | it('Should have a small description on each server', async function () { |
8bf89b09 C |
91 | for (const server of servers) { |
92 | const res = await getVideo(server.url, videoUUID) | |
93 | const video = res.body | |
94 | ||
95 | expect(video.description).to.equal('short description') | |
96 | ||
97 | const res2 = await getVideoDescription(server.url, video.descriptionPath) | |
98 | expect(res2.body.description).to.equal('short description') | |
99 | } | |
100 | }) | |
101 | ||
9567011b C |
102 | after(async function () { |
103 | killallServers(servers) | |
9567011b C |
104 | }) |
105 | }) |