aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/services.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/services.ts')
-rw-r--r--server/tests/api/videos/services.ts75
1 files changed, 65 insertions, 10 deletions
diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts
index 5505a845a..897f37c04 100644
--- a/server/tests/api/videos/services.ts
+++ b/server/tests/api/videos/services.ts
@@ -1,14 +1,25 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
5import { getOEmbed, getVideosList, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils/index' 4import * as chai from 'chai'
5import {
6 getOEmbed,
7 getVideosList,
8 ServerInfo,
9 setAccessTokensToServers,
10 setDefaultVideoChannel,
11 uploadVideo,
12 createVideoPlaylist,
13 addVideoInPlaylist
14} from '../../../../shared/extra-utils'
6import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers' 15import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
16import { VideoPlaylistPrivacy } from '@shared/models'
7 17
8const expect = chai.expect 18const expect = chai.expect
9 19
10describe('Test services', function () { 20describe('Test services', function () {
11 let server: ServerInfo = null 21 let server: ServerInfo = null
22 let playlistUUID: string
12 23
13 before(async function () { 24 before(async function () {
14 this.timeout(30000) 25 this.timeout(30000)
@@ -16,17 +27,43 @@ describe('Test services', function () {
16 server = await flushAndRunServer(1) 27 server = await flushAndRunServer(1)
17 28
18 await setAccessTokensToServers([ server ]) 29 await setAccessTokensToServers([ server ])
30 await setDefaultVideoChannel([ server ])
19 31
20 const videoAttributes = { 32 {
21 name: 'my super name' 33 const videoAttributes = {
34 name: 'my super name'
35 }
36 await uploadVideo(server.url, server.accessToken, videoAttributes)
37
38 const res = await getVideosList(server.url)
39 server.video = res.body.data[0]
22 } 40 }
23 await uploadVideo(server.url, server.accessToken, videoAttributes)
24 41
25 const res = await getVideosList(server.url) 42 {
26 server.video = res.body.data[0] 43 const res = await createVideoPlaylist({
44 url: server.url,
45 token: server.accessToken,
46 playlistAttrs: {
47 displayName: 'The Life and Times of Scrooge McDuck',
48 privacy: VideoPlaylistPrivacy.PUBLIC,
49 videoChannelId: server.videoChannel.id
50 }
51 })
52
53 playlistUUID = res.body.videoPlaylist.uuid
54
55 await addVideoInPlaylist({
56 url: server.url,
57 token: server.accessToken,
58 playlistId: res.body.videoPlaylist.id,
59 elementAttrs: {
60 videoId: server.video.id
61 }
62 })
63 }
27 }) 64 })
28 65
29 it('Should have a valid oEmbed response', async function () { 66 it('Should have a valid oEmbed video response', async function () {
30 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid 67 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid
31 68
32 const res = await getOEmbed(server.url, oembedUrl) 69 const res = await getOEmbed(server.url, oembedUrl)
@@ -37,7 +74,7 @@ describe('Test services', function () {
37 74
38 expect(res.body.html).to.equal(expectedHtml) 75 expect(res.body.html).to.equal(expectedHtml)
39 expect(res.body.title).to.equal(server.video.name) 76 expect(res.body.title).to.equal(server.video.name)
40 expect(res.body.author_name).to.equal(server.video.account.name) 77 expect(res.body.author_name).to.equal(server.videoChannel.displayName)
41 expect(res.body.width).to.equal(560) 78 expect(res.body.width).to.equal(560)
42 expect(res.body.height).to.equal(315) 79 expect(res.body.height).to.equal(315)
43 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) 80 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
@@ -45,6 +82,24 @@ describe('Test services', function () {
45 expect(res.body.thumbnail_height).to.equal(480) 82 expect(res.body.thumbnail_height).to.equal(480)
46 }) 83 })
47 84
85 it('Should have a valid playlist oEmbed response', async function () {
86 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/playlist/' + playlistUUID
87
88 const res = await getOEmbed(server.url, oembedUrl)
89 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
90 `src="http://localhost:${server.port}/video-playlists/embed/${playlistUUID}" ` +
91 'frameborder="0" allowfullscreen></iframe>'
92
93 expect(res.body.html).to.equal(expectedHtml)
94 expect(res.body.title).to.equal('The Life and Times of Scrooge McDuck')
95 expect(res.body.author_name).to.equal(server.videoChannel.displayName)
96 expect(res.body.width).to.equal(560)
97 expect(res.body.height).to.equal(315)
98 expect(res.body.thumbnail_url).exist
99 expect(res.body.thumbnail_width).to.equal(223)
100 expect(res.body.thumbnail_height).to.equal(122)
101 })
102
48 it('Should have a valid oEmbed response with small max height query', async function () { 103 it('Should have a valid oEmbed response with small max height query', async function () {
49 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid 104 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid
50 const format = 'json' 105 const format = 'json'
@@ -58,7 +113,7 @@ describe('Test services', function () {
58 113
59 expect(res.body.html).to.equal(expectedHtml) 114 expect(res.body.html).to.equal(expectedHtml)
60 expect(res.body.title).to.equal(server.video.name) 115 expect(res.body.title).to.equal(server.video.name)
61 expect(res.body.author_name).to.equal(server.video.account.name) 116 expect(res.body.author_name).to.equal(server.videoChannel.displayName)
62 expect(res.body.height).to.equal(50) 117 expect(res.body.height).to.equal(50)
63 expect(res.body.width).to.equal(50) 118 expect(res.body.width).to.equal(50)
64 expect(res.body).to.not.have.property('thumbnail_url') 119 expect(res.body).to.not.have.property('thumbnail_url')