]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
d8755eed | 2 | |
8b0d42ee | 3 | import 'mocha' |
6fad8e51 C |
4 | import * as chai from 'chai' |
5 | import { | |
6 | getOEmbed, | |
7 | getVideosList, | |
8 | ServerInfo, | |
9 | setAccessTokensToServers, | |
10 | setDefaultVideoChannel, | |
11 | uploadVideo, | |
12 | createVideoPlaylist, | |
13 | addVideoInPlaylist | |
14 | } from '../../../../shared/extra-utils' | |
7c3b7976 | 15 | import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers' |
6fad8e51 | 16 | import { VideoPlaylistPrivacy } from '@shared/models' |
d8755eed | 17 | |
8b0d42ee C |
18 | const expect = chai.expect |
19 | ||
d8755eed C |
20 | describe('Test services', function () { |
21 | let server: ServerInfo = null | |
6fad8e51 | 22 | let playlistUUID: string |
d8755eed C |
23 | |
24 | before(async function () { | |
e212f887 | 25 | this.timeout(30000) |
d8755eed | 26 | |
210feb6c | 27 | server = await flushAndRunServer(1) |
d8755eed C |
28 | |
29 | await setAccessTokensToServers([ server ]) | |
6fad8e51 | 30 | await setDefaultVideoChannel([ server ]) |
d8755eed | 31 | |
6fad8e51 C |
32 | { |
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] | |
d8755eed | 40 | } |
8b0d42ee | 41 | |
6fad8e51 C |
42 | { |
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 | } | |
d8755eed C |
64 | }) |
65 | ||
6fad8e51 | 66 | it('Should have a valid oEmbed video response', async function () { |
7243f84d | 67 | const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid |
d8755eed C |
68 | |
69 | const res = await getOEmbed(server.url, oembedUrl) | |
2186386c | 70 | const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' + |
a1587156 C |
71 | `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` + |
72 | 'frameborder="0" allowfullscreen></iframe>' | |
20dcfd74 | 73 | const expectedThumbnailUrl = 'http://localhost:' + server.port + '/lazy-static/previews/' + server.video.uuid + '.jpg' |
d8755eed C |
74 | |
75 | expect(res.body.html).to.equal(expectedHtml) | |
76 | expect(res.body.title).to.equal(server.video.name) | |
6fad8e51 | 77 | expect(res.body.author_name).to.equal(server.videoChannel.displayName) |
d8755eed | 78 | expect(res.body.width).to.equal(560) |
164174a6 | 79 | expect(res.body.height).to.equal(315) |
d8755eed | 80 | expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) |
80b8ad2a C |
81 | expect(res.body.thumbnail_width).to.equal(850) |
82 | expect(res.body.thumbnail_height).to.equal(480) | |
d8755eed C |
83 | }) |
84 | ||
6fad8e51 C |
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 | ||
d8755eed | 103 | it('Should have a valid oEmbed response with small max height query', async function () { |
7243f84d | 104 | const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid |
d8755eed C |
105 | const format = 'json' |
106 | const maxHeight = 50 | |
107 | const maxWidth = 50 | |
108 | ||
109 | const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth) | |
3cd0734f | 110 | const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' + |
a1587156 C |
111 | `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` + |
112 | 'frameborder="0" allowfullscreen></iframe>' | |
d8755eed C |
113 | |
114 | expect(res.body.html).to.equal(expectedHtml) | |
115 | expect(res.body.title).to.equal(server.video.name) | |
6fad8e51 | 116 | expect(res.body.author_name).to.equal(server.videoChannel.displayName) |
d8755eed C |
117 | expect(res.body.height).to.equal(50) |
118 | expect(res.body.width).to.equal(50) | |
119 | expect(res.body).to.not.have.property('thumbnail_url') | |
120 | expect(res.body).to.not.have.property('thumbnail_width') | |
121 | expect(res.body).to.not.have.property('thumbnail_height') | |
122 | }) | |
123 | ||
7c3b7976 C |
124 | after(async function () { |
125 | await cleanupTests([ server ]) | |
d8755eed C |
126 | }) |
127 | }) |