aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/index.ts1
-rw-r--r--server/tests/api/video-description.ts86
-rw-r--r--server/tests/utils/videos.ts9
3 files changed, 96 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'
7import './video-abuse' 7import './video-abuse'
8import './video-blacklist' 8import './video-blacklist'
9import './video-blacklist-management' 9import './video-blacklist-management'
10import './video-description'
10import './multiple-pods' 11import './multiple-pods'
11import './services' 12import './services'
12import './request-schedulers' 13import './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
3import 'mocha'
4import * as chai from 'chai'
5
6import {
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
20const expect = chai.expect
21
22describe('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})
diff --git a/server/tests/utils/videos.ts b/server/tests/utils/videos.ts
index 08fa48da6..2a5d00255 100644
--- a/server/tests/utils/videos.ts
+++ b/server/tests/utils/videos.ts
@@ -61,6 +61,14 @@ function getVideo (url: string, id: number | string) {
61 .expect('Content-Type', /json/) 61 .expect('Content-Type', /json/)
62} 62}
63 63
64function getVideoDescription (url: string, descriptionPath: string) {
65 return request(url)
66 .get(descriptionPath)
67 .set('Accept', 'application/json')
68 .expect(200)
69 .expect('Content-Type', /json/)
70}
71
64function getVideosList (url: string) { 72function getVideosList (url: string) {
65 const path = '/api/v1/videos' 73 const path = '/api/v1/videos'
66 74
@@ -263,6 +271,7 @@ function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: n
263// --------------------------------------------------------------------------- 271// ---------------------------------------------------------------------------
264 272
265export { 273export {
274 getVideoDescription,
266 getVideoCategories, 275 getVideoCategories,
267 getVideoLicences, 276 getVideoLicences,
268 getVideoLanguages, 277 getVideoLanguages,