aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/server/services.ts27
-rw-r--r--server/tests/api/videos/video-captions.ts12
2 files changed, 21 insertions, 18 deletions
diff --git a/server/tests/api/server/services.ts b/server/tests/api/server/services.ts
index 680e7a817..df910c111 100644
--- a/server/tests/api/server/services.ts
+++ b/server/tests/api/server/services.ts
@@ -2,24 +2,25 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { Video, VideoPlaylistPrivacy } from '@shared/models'
5import { 6import {
7 addVideoInPlaylist,
8 createVideoPlaylist,
6 getOEmbed, 9 getOEmbed,
7 getVideosList, 10 getVideosList,
8 ServerInfo, 11 ServerInfo,
9 setAccessTokensToServers, 12 setAccessTokensToServers,
10 setDefaultVideoChannel, 13 setDefaultVideoChannel,
11 uploadVideo, 14 uploadVideo
12 createVideoPlaylist,
13 addVideoInPlaylist
14} from '../../../../shared/extra-utils' 15} from '../../../../shared/extra-utils'
15import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers' 16import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
16import { VideoPlaylistPrivacy } from '@shared/models'
17 17
18const expect = chai.expect 18const expect = chai.expect
19 19
20describe('Test services', function () { 20describe('Test services', function () {
21 let server: ServerInfo = null 21 let server: ServerInfo = null
22 let playlistUUID: string 22 let playlistUUID: string
23 let video: Video
23 24
24 before(async function () { 25 before(async function () {
25 this.timeout(30000) 26 this.timeout(30000)
@@ -36,7 +37,7 @@ describe('Test services', function () {
36 await uploadVideo(server.url, server.accessToken, videoAttributes) 37 await uploadVideo(server.url, server.accessToken, videoAttributes)
37 38
38 const res = await getVideosList(server.url) 39 const res = await getVideosList(server.url)
39 server.video = res.body.data[0] 40 video = res.body.data[0]
40 } 41 }
41 42
42 { 43 {
@@ -57,23 +58,23 @@ describe('Test services', function () {
57 token: server.accessToken, 58 token: server.accessToken,
58 playlistId: res.body.videoPlaylist.id, 59 playlistId: res.body.videoPlaylist.id,
59 elementAttrs: { 60 elementAttrs: {
60 videoId: server.video.id 61 videoId: video.id
61 } 62 }
62 }) 63 })
63 } 64 }
64 }) 65 })
65 66
66 it('Should have a valid oEmbed video response', async function () { 67 it('Should have a valid oEmbed video response', async function () {
67 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid 68 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + video.uuid
68 69
69 const res = await getOEmbed(server.url, oembedUrl) 70 const res = await getOEmbed(server.url, oembedUrl)
70 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' + 71 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
71 `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` + 72 `src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
72 'frameborder="0" allowfullscreen></iframe>' 73 'frameborder="0" allowfullscreen></iframe>'
73 const expectedThumbnailUrl = 'http://localhost:' + server.port + '/lazy-static/previews/' + server.video.uuid + '.jpg' 74 const expectedThumbnailUrl = 'http://localhost:' + server.port + video.previewPath
74 75
75 expect(res.body.html).to.equal(expectedHtml) 76 expect(res.body.html).to.equal(expectedHtml)
76 expect(res.body.title).to.equal(server.video.name) 77 expect(res.body.title).to.equal(video.name)
77 expect(res.body.author_name).to.equal(server.videoChannel.displayName) 78 expect(res.body.author_name).to.equal(server.videoChannel.displayName)
78 expect(res.body.width).to.equal(560) 79 expect(res.body.width).to.equal(560)
79 expect(res.body.height).to.equal(315) 80 expect(res.body.height).to.equal(315)
@@ -101,18 +102,18 @@ describe('Test services', function () {
101 }) 102 })
102 103
103 it('Should have a valid oEmbed response with small max height query', async function () { 104 it('Should have a valid oEmbed response with small max height query', async function () {
104 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid 105 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + video.uuid
105 const format = 'json' 106 const format = 'json'
106 const maxHeight = 50 107 const maxHeight = 50
107 const maxWidth = 50 108 const maxWidth = 50
108 109
109 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth) 110 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
110 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' + 111 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
111 `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` + 112 `src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
112 'frameborder="0" allowfullscreen></iframe>' 113 'frameborder="0" allowfullscreen></iframe>'
113 114
114 expect(res.body.html).to.equal(expectedHtml) 115 expect(res.body.html).to.equal(expectedHtml)
115 expect(res.body.title).to.equal(server.video.name) 116 expect(res.body.title).to.equal(video.name)
116 expect(res.body.author_name).to.equal(server.videoChannel.displayName) 117 expect(res.body.author_name).to.equal(server.videoChannel.displayName)
117 expect(res.body.height).to.equal(50) 118 expect(res.body.height).to.equal(50)
118 expect(res.body.width).to.equal(50) 119 expect(res.body.width).to.equal(50)
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts
index 5b36dc021..14ecedfa6 100644
--- a/server/tests/api/videos/video-captions.ts
+++ b/server/tests/api/videos/video-captions.ts
@@ -24,6 +24,8 @@ import { VideoCaption } from '../../../../shared/models/videos/caption/video-cap
24const expect = chai.expect 24const expect = chai.expect
25 25
26describe('Test video captions', function () { 26describe('Test video captions', function () {
27 const uuidRegex = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
28
27 let servers: ServerInfo[] 29 let servers: ServerInfo[]
28 let videoUUID: string 30 let videoUUID: string
29 31
@@ -83,13 +85,13 @@ describe('Test video captions', function () {
83 const caption1: VideoCaption = res.body.data[0] 85 const caption1: VideoCaption = res.body.data[0]
84 expect(caption1.language.id).to.equal('ar') 86 expect(caption1.language.id).to.equal('ar')
85 expect(caption1.language.label).to.equal('Arabic') 87 expect(caption1.language.label).to.equal('Arabic')
86 expect(caption1.captionPath).to.equal('/lazy-static/video-captions/' + videoUUID + '-ar.vtt') 88 expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
87 await testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 1.') 89 await testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 1.')
88 90
89 const caption2: VideoCaption = res.body.data[1] 91 const caption2: VideoCaption = res.body.data[1]
90 expect(caption2.language.id).to.equal('zh') 92 expect(caption2.language.id).to.equal('zh')
91 expect(caption2.language.label).to.equal('Chinese') 93 expect(caption2.language.label).to.equal('Chinese')
92 expect(caption2.captionPath).to.equal('/lazy-static/video-captions/' + videoUUID + '-zh.vtt') 94 expect(caption2.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-zh.vtt$'))
93 await testCaptionFile(server.url, caption2.captionPath, 'Subtitle good 2.') 95 await testCaptionFile(server.url, caption2.captionPath, 'Subtitle good 2.')
94 } 96 }
95 }) 97 })
@@ -117,7 +119,7 @@ describe('Test video captions', function () {
117 const caption1: VideoCaption = res.body.data[0] 119 const caption1: VideoCaption = res.body.data[0]
118 expect(caption1.language.id).to.equal('ar') 120 expect(caption1.language.id).to.equal('ar')
119 expect(caption1.language.label).to.equal('Arabic') 121 expect(caption1.language.label).to.equal('Arabic')
120 expect(caption1.captionPath).to.equal('/lazy-static/video-captions/' + videoUUID + '-ar.vtt') 122 expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
121 await testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 2.') 123 await testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 2.')
122 } 124 }
123 }) 125 })
@@ -148,7 +150,7 @@ describe('Test video captions', function () {
148 const caption1: VideoCaption = res.body.data[0] 150 const caption1: VideoCaption = res.body.data[0]
149 expect(caption1.language.id).to.equal('ar') 151 expect(caption1.language.id).to.equal('ar')
150 expect(caption1.language.label).to.equal('Arabic') 152 expect(caption1.language.label).to.equal('Arabic')
151 expect(caption1.captionPath).to.equal('/lazy-static/video-captions/' + videoUUID + '-ar.vtt') 153 expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
152 154
153 const expected = 'WEBVTT FILE\r\n' + 155 const expected = 'WEBVTT FILE\r\n' +
154 '\r\n' + 156 '\r\n' +
@@ -185,7 +187,7 @@ describe('Test video captions', function () {
185 187
186 expect(caption.language.id).to.equal('zh') 188 expect(caption.language.id).to.equal('zh')
187 expect(caption.language.label).to.equal('Chinese') 189 expect(caption.language.label).to.equal('Chinese')
188 expect(caption.captionPath).to.equal('/lazy-static/video-captions/' + videoUUID + '-zh.vtt') 190 expect(caption.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-zh.vtt$'))
189 await testCaptionFile(server.url, caption.captionPath, 'Subtitle good 2.') 191 await testCaptionFile(server.url, caption.captionPath, 'Subtitle good 2.')
190 } 192 }
191 }) 193 })