]>
Commit | Line | Data |
---|---|---|
d8755eed C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
5 | const expect = chai.expect | |
6 | ||
7 | import { | |
8 | ServerInfo, | |
9 | flushTests, | |
10 | uploadVideo, | |
11 | getVideosList, | |
12 | setAccessTokensToServers, | |
13 | killallServers, | |
14 | getOEmbed | |
15 | } from '../utils' | |
16 | import { runServer } from '../utils/servers' | |
17 | ||
18 | describe('Test services', function () { | |
19 | let server: ServerInfo = null | |
20 | ||
21 | before(async function () { | |
572f8d3d | 22 | this.timeout(10000) |
d8755eed C |
23 | |
24 | await flushTests() | |
25 | ||
26 | server = await runServer(1) | |
27 | ||
28 | await setAccessTokensToServers([ server ]) | |
29 | ||
30 | const videoAttributes = { | |
31 | name: 'my super name' | |
32 | } | |
33 | await uploadVideo(server.url, server.accessToken, videoAttributes) | |
34 | ||
35 | const res = await getVideosList(server.url) | |
36 | server.video = res.body.data[0] | |
37 | }) | |
38 | ||
39 | it('Should have a valid oEmbed response', async function () { | |
40 | const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid | |
41 | ||
42 | const res = await getOEmbed(server.url, oembedUrl) | |
43 | const expectedHtml = `<iframe width="560" height="315" src="http://localhost:9001/videos/embed/${server.video.uuid}" ` + | |
44 | 'frameborder="0" allowfullscreen></iframe>' | |
164174a6 | 45 | const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg' |
d8755eed C |
46 | |
47 | expect(res.body.html).to.equal(expectedHtml) | |
48 | expect(res.body.title).to.equal(server.video.name) | |
afffe988 | 49 | expect(res.body.author_name).to.equal(server.video.account) |
d8755eed | 50 | expect(res.body.width).to.equal(560) |
164174a6 | 51 | expect(res.body.height).to.equal(315) |
d8755eed | 52 | expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) |
164174a6 C |
53 | expect(res.body.thumbnail_width).to.equal(560) |
54 | expect(res.body.thumbnail_height).to.equal(315) | |
d8755eed C |
55 | }) |
56 | ||
57 | it('Should have a valid oEmbed response with small max height query', async function () { | |
58 | const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid | |
59 | const format = 'json' | |
60 | const maxHeight = 50 | |
61 | const maxWidth = 50 | |
62 | ||
63 | const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth) | |
64 | const expectedHtml = `<iframe width="50" height="50" src="http://localhost:9001/videos/embed/${server.video.uuid}" ` + | |
65 | 'frameborder="0" allowfullscreen></iframe>' | |
66 | ||
67 | expect(res.body.html).to.equal(expectedHtml) | |
68 | expect(res.body.title).to.equal(server.video.name) | |
afffe988 | 69 | expect(res.body.author_name).to.equal(server.video.account) |
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 | ||
77 | after(async function () { | |
78 | killallServers([ server ]) | |
79 | ||
80 | // Keep the logs if the test failed | |
81 | if (this['ok']) { | |
82 | await flushTests() | |
83 | } | |
84 | }) | |
85 | }) |