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