]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/videos/services.ts
Try to fix travis
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / services.ts
CommitLineData
d8755eed
C
1/* tslint:disable:no-unused-expression */
2
d8755eed 3import * as chai from 'chai'
8b0d42ee 4import 'mocha'
9639bd17 5import {
6 flushTests,
7 getOEmbed,
8 getVideosList,
9 killallServers,
10 ServerInfo,
11 setAccessTokensToServers,
12 uploadVideo
94565d52 13} from '../../../../shared/extra-utils/index'
210feb6c 14import { flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
d8755eed 15
8b0d42ee
C
16const expect = chai.expect
17
d8755eed
C
18describe('Test services', function () {
19 let server: ServerInfo = null
20
21 before(async function () {
e212f887 22 this.timeout(30000)
d8755eed 23
210feb6c 24 server = await flushAndRunServer(1)
d8755eed
C
25
26 await setAccessTokensToServers([ server ])
27
28 const videoAttributes = {
29 name: 'my super name'
30 }
8b0d42ee
C
31 await uploadVideo(server.url, server.accessToken, videoAttributes)
32
33 const res = await getVideosList(server.url)
34 server.video = res.body.data[0]
d8755eed
C
35 })
36
37 it('Should have a valid oEmbed response', async function () {
38 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
39
40 const res = await getOEmbed(server.url, oembedUrl)
2186386c
C
41 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
42 `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` +
d8755eed 43 'frameborder="0" allowfullscreen></iframe>'
164174a6 44 const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg'
d8755eed
C
45
46 expect(res.body.html).to.equal(expectedHtml)
47 expect(res.body.title).to.equal(server.video.name)
b64c950a 48 expect(res.body.author_name).to.equal(server.video.account.name)
d8755eed 49 expect(res.body.width).to.equal(560)
164174a6 50 expect(res.body.height).to.equal(315)
d8755eed 51 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
164174a6
C
52 expect(res.body.thumbnail_width).to.equal(560)
53 expect(res.body.thumbnail_height).to.equal(315)
d8755eed
C
54 })
55
56 it('Should have a valid oEmbed response with small max height query', async function () {
57 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
58 const format = 'json'
59 const maxHeight = 50
60 const maxWidth = 50
61
62 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
3cd0734f
C
63 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
64 `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` +
d8755eed
C
65 'frameborder="0" allowfullscreen></iframe>'
66
67 expect(res.body.html).to.equal(expectedHtml)
68 expect(res.body.title).to.equal(server.video.name)
b64c950a 69 expect(res.body.author_name).to.equal(server.video.account.name)
d8755eed
C
70 expect(res.body.height).to.equal(50)
71 expect(res.body.width).to.equal(50)
72 expect(res.body).to.not.have.property('thumbnail_url')
73 expect(res.body).to.not.have.property('thumbnail_width')
74 expect(res.body).to.not.have.property('thumbnail_height')
75 })
76
210feb6c 77 after(function () {
d8755eed 78 killallServers([ server ])
d8755eed
C
79 })
80})