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