aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/services.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/services.ts')
-rw-r--r--server/tests/api/videos/services.ts85
1 files changed, 85 insertions, 0 deletions
diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts
new file mode 100644
index 000000000..1cda464d9
--- /dev/null
+++ b/server/tests/api/videos/services.ts
@@ -0,0 +1,85 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import * as chai from 'chai'
5const expect = chai.expect
6
7import {
8 ServerInfo,
9 flushTests,
10 uploadVideo,
11 getVideosList,
12 setAccessTokensToServers,
13 killallServers,
14 getOEmbed
15} from '../../utils/index'
16import { runServer } from '../../utils/server/servers'
17
18describe('Test services', function () {
19 let server: ServerInfo = null
20
21 before(async function () {
22 this.timeout(10000)
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>'
45 const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg'
46
47 expect(res.body.html).to.equal(expectedHtml)
48 expect(res.body.title).to.equal(server.video.name)
49 expect(res.body.author_name).to.equal(server.video.accountName)
50 expect(res.body.width).to.equal(560)
51 expect(res.body.height).to.equal(315)
52 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
53 expect(res.body.thumbnail_width).to.equal(560)
54 expect(res.body.thumbnail_height).to.equal(315)
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)
69 expect(res.body.author_name).to.equal(server.video.accountName)
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})