diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/index.ts | 1 | ||||
-rw-r--r-- | server/tests/api/video-description.ts | 86 |
2 files changed, 87 insertions, 0 deletions
diff --git a/server/tests/api/index.ts b/server/tests/api/index.ts index e50e65049..2ff0ecf24 100644 --- a/server/tests/api/index.ts +++ b/server/tests/api/index.ts | |||
@@ -7,6 +7,7 @@ import './single-pod' | |||
7 | import './video-abuse' | 7 | import './video-abuse' |
8 | import './video-blacklist' | 8 | import './video-blacklist' |
9 | import './video-blacklist-management' | 9 | import './video-blacklist-management' |
10 | import './video-description' | ||
10 | import './multiple-pods' | 11 | import './multiple-pods' |
11 | import './services' | 12 | import './services' |
12 | import './request-schedulers' | 13 | import './request-schedulers' |
diff --git a/server/tests/api/video-description.ts b/server/tests/api/video-description.ts new file mode 100644 index 000000000..f04c5f1f6 --- /dev/null +++ b/server/tests/api/video-description.ts | |||
@@ -0,0 +1,86 @@ | |||
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, | ||
17 | getVideoDescription | ||
18 | } from '../utils' | ||
19 | |||
20 | const expect = chai.expect | ||
21 | |||
22 | describe('Test video description', function () { | ||
23 | let servers: ServerInfo[] = [] | ||
24 | let videoUUID = '' | ||
25 | let longDescription = 'my super description for pod 1'.repeat(50) | ||
26 | |||
27 | before(async function () { | ||
28 | this.timeout(10000) | ||
29 | |||
30 | // Run servers | ||
31 | servers = await flushAndRunMultipleServers(2) | ||
32 | |||
33 | // Get the access tokens | ||
34 | await setAccessTokensToServers(servers) | ||
35 | |||
36 | // Pod 1 makes friend with pod 2 | ||
37 | await makeFriends(servers[0].url, servers[0].accessToken) | ||
38 | }) | ||
39 | |||
40 | it('Should upload video with long description', async function () { | ||
41 | this.timeout(15000) | ||
42 | |||
43 | const attributes = { | ||
44 | description: longDescription | ||
45 | } | ||
46 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | ||
47 | |||
48 | await wait(11000) | ||
49 | |||
50 | const res = await getVideosList(servers[0].url) | ||
51 | |||
52 | videoUUID = res.body.data[0].uuid | ||
53 | }) | ||
54 | |||
55 | it('Should have a truncated description on each pod', async function () { | ||
56 | for (const server of servers) { | ||
57 | const res = await getVideo(server.url, videoUUID) | ||
58 | const video = res.body | ||
59 | |||
60 | // 30 characters * 6 -> 240 characters | ||
61 | const truncatedDescription = 'my super description for pod 1'.repeat(8) + | ||
62 | 'my supe...' | ||
63 | |||
64 | expect(video.description).to.equal(truncatedDescription) | ||
65 | } | ||
66 | }) | ||
67 | |||
68 | it('Should fetch long description on each pod', async function () { | ||
69 | for (const server of servers) { | ||
70 | const res = await getVideo(server.url, videoUUID) | ||
71 | const video = res.body | ||
72 | |||
73 | const res2 = await getVideoDescription(server.url, video.descriptionPath) | ||
74 | expect(res2.body.description).to.equal(longDescription) | ||
75 | } | ||
76 | }) | ||
77 | |||
78 | after(async function () { | ||
79 | killallServers(servers) | ||
80 | |||
81 | // Keep the logs if the test failed | ||
82 | if (this['ok']) { | ||
83 | await flushTests() | ||
84 | } | ||
85 | }) | ||
86 | }) | ||