aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/services.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/services.ts')
-rw-r--r--server/tests/api/check-params/services.ts46
1 files changed, 39 insertions, 7 deletions
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index 457adfaab..e57edd9e4 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -8,11 +8,15 @@ import {
8 makeGetRequest, 8 makeGetRequest,
9 ServerInfo, 9 ServerInfo,
10 setAccessTokensToServers, 10 setAccessTokensToServers,
11 uploadVideo 11 uploadVideo,
12 createVideoPlaylist,
13 setDefaultVideoChannel
12} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
15import { VideoPlaylistPrivacy } from '@shared/models'
13 16
14describe('Test services API validators', function () { 17describe('Test services API validators', function () {
15 let server: ServerInfo 18 let server: ServerInfo
19 let playlistUUID: string
16 20
17 // --------------------------------------------------------------- 21 // ---------------------------------------------------------------
18 22
@@ -21,9 +25,26 @@ describe('Test services API validators', function () {
21 25
22 server = await flushAndRunServer(1) 26 server = await flushAndRunServer(1)
23 await setAccessTokensToServers([ server ]) 27 await setAccessTokensToServers([ server ])
24 28 await setDefaultVideoChannel([ server ])
25 const res = await uploadVideo(server.url, server.accessToken, { name: 'my super name' }) 29
26 server.video = res.body.video 30 {
31 const res = await uploadVideo(server.url, server.accessToken, { name: 'my super name' })
32 server.video = res.body.video
33 }
34
35 {
36 const res = await createVideoPlaylist({
37 url: server.url,
38 token: server.accessToken,
39 playlistAttrs: {
40 displayName: 'super playlist',
41 privacy: VideoPlaylistPrivacy.PUBLIC,
42 videoChannelId: server.videoChannel.id
43 }
44 })
45
46 playlistUUID = res.body.videoPlaylist.uuid
47 }
27 }) 48 })
28 49
29 describe('Test oEmbed API validators', function () { 50 describe('Test oEmbed API validators', function () {
@@ -38,12 +59,12 @@ describe('Test services API validators', function () {
38 await checkParamEmbed(server, embedUrl) 59 await checkParamEmbed(server, embedUrl)
39 }) 60 })
40 61
41 it('Should fail with an invalid video id', async function () { 62 it('Should fail with an invalid element id', async function () {
42 const embedUrl = `http://localhost:${server.port}/videos/watch/blabla` 63 const embedUrl = `http://localhost:${server.port}/videos/watch/blabla`
43 await checkParamEmbed(server, embedUrl) 64 await checkParamEmbed(server, embedUrl)
44 }) 65 })
45 66
46 it('Should fail with an unknown video', async function () { 67 it('Should fail with an unknown element', async function () {
47 const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c` 68 const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c`
48 await checkParamEmbed(server, embedUrl, 404) 69 await checkParamEmbed(server, embedUrl, 404)
49 }) 70 })
@@ -78,7 +99,7 @@ describe('Test services API validators', function () {
78 await checkParamEmbed(server, embedUrl, 501, { format: 'xml' }) 99 await checkParamEmbed(server, embedUrl, 501, { format: 'xml' })
79 }) 100 })
80 101
81 it('Should succeed with the correct params', async function () { 102 it('Should succeed with the correct params with a video', async function () {
82 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 103 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
83 const query = { 104 const query = {
84 format: 'json', 105 format: 'json',
@@ -88,6 +109,17 @@ describe('Test services API validators', function () {
88 109
89 await checkParamEmbed(server, embedUrl, 200, query) 110 await checkParamEmbed(server, embedUrl, 200, query)
90 }) 111 })
112
113 it('Should succeed with the correct params with a playlist', async function () {
114 const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${playlistUUID}`
115 const query = {
116 format: 'json',
117 maxheight: 400,
118 maxwidth: 400
119 }
120
121 await checkParamEmbed(server, embedUrl, 200, query)
122 })
91 }) 123 })
92 124
93 after(async function () { 125 after(async function () {