1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
5 import { getOEmbed, getVideosList, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils/index'
6 import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
8 const expect = chai.expect
10 describe('Test services', function () {
11 let server: ServerInfo = null
13 before(async function () {
16 server = await flushAndRunServer(1)
18 await setAccessTokensToServers([ server ])
20 const videoAttributes = {
23 await uploadVideo(server.url, server.accessToken, videoAttributes)
25 const res = await getVideosList(server.url)
26 server.video = res.body.data[0]
29 it('Should have a valid oEmbed response', async function () {
30 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid
32 const res = await getOEmbed(server.url, oembedUrl)
33 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
34 `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` +
35 'frameborder="0" allowfullscreen></iframe>'
36 const expectedThumbnailUrl = 'http://localhost:' + server.port + '/static/previews/' + server.video.uuid + '.jpg'
38 expect(res.body.html).to.equal(expectedHtml)
39 expect(res.body.title).to.equal(server.video.name)
40 expect(res.body.author_name).to.equal(server.video.account.name)
41 expect(res.body.width).to.equal(560)
42 expect(res.body.height).to.equal(315)
43 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
44 expect(res.body.thumbnail_width).to.equal(850)
45 expect(res.body.thumbnail_height).to.equal(480)
48 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
54 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
55 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
56 `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` +
57 'frameborder="0" allowfullscreen></iframe>'
59 expect(res.body.html).to.equal(expectedHtml)
60 expect(res.body.title).to.equal(server.video.name)
61 expect(res.body.author_name).to.equal(server.video.account.name)
62 expect(res.body.height).to.equal(50)
63 expect(res.body.width).to.equal(50)
64 expect(res.body).to.not.have.property('thumbnail_url')
65 expect(res.body).to.not.have.property('thumbnail_width')
66 expect(res.body).to.not.have.property('thumbnail_height')
69 after(async function () {
70 await cleanupTests([ server ])