]>
Commit | Line | Data |
---|---|---|
1 | /* tslint:disable:no-unused-expression */ | |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
5 | import * as request from 'supertest' | |
6 | const expect = chai.expect | |
7 | ||
8 | import { | |
9 | ServerInfo, | |
10 | flushTests, | |
11 | runServer, | |
12 | loginAndGetAccessToken, | |
13 | uploadVideo, | |
14 | getVideosList | |
15 | } from './utils' | |
16 | ||
17 | describe('Test a client controllers', function () { | |
18 | let server: ServerInfo | |
19 | ||
20 | before(async function () { | |
21 | this.timeout(120000) | |
22 | ||
23 | await flushTests() | |
24 | ||
25 | server = await runServer(1) | |
26 | server.accessToken = await loginAndGetAccessToken(server) | |
27 | ||
28 | const videoAttributes = { | |
29 | name: 'my super name for pod 1', | |
30 | description: 'my super description for pod 1' | |
31 | } | |
32 | await uploadVideo(server.url, server.accessToken, videoAttributes) | |
33 | ||
34 | const res = await getVideosList(server.url) | |
35 | const videos = res.body.data | |
36 | ||
37 | expect(videos.length).to.equal(1) | |
38 | ||
39 | server.video = videos[0] | |
40 | }) | |
41 | ||
42 | it('Should have valid Open Graph tags on the watch page with video id', async function () { | |
43 | const res = await request(server.url) | |
44 | .get('/videos/watch/' + server.video.id) | |
45 | .expect(200) | |
46 | ||
47 | expect(res.text).to.contain('<meta property="og:title" content="my super name for pod 1" />') | |
48 | expect(res.text).to.contain('<meta property="og:description" content="my super description for pod 1" />') | |
49 | }) | |
50 | ||
51 | it('Should have valid Open Graph tags on the watch page with video uuid', async function () { | |
52 | const res = await request(server.url) | |
53 | .get('/videos/watch/' + server.video.uuid) | |
54 | .expect(200) | |
55 | ||
56 | expect(res.text).to.contain('<meta property="og:title" content="my super name for pod 1" />') | |
57 | expect(res.text).to.contain('<meta property="og:description" content="my super description for pod 1" />') | |
58 | }) | |
59 | ||
60 | it('Should have valid oEmbed discovery tags', async function () { | |
61 | const path = '/videos/watch/' + server.video.uuid | |
62 | const res = await request(server.url) | |
63 | .get(path) | |
64 | .expect(200) | |
65 | ||
66 | const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:9001/services/oembed?' + | |
67 | `url=http%3A%2F%2Flocalhost%3A9001%2Fvideos%2Fwatch%2F${server.video.uuid}" ` + | |
68 | `title="${server.video.name}" />` | |
69 | ||
70 | expect(res.text).to.contain(expectedLink) | |
71 | }) | |
72 | ||
73 | after(async function () { | |
74 | process.kill(-server.app.pid) | |
75 | ||
76 | // Keep the logs if the test failed | |
77 | if (this['ok']) { | |
78 | await flushTests() | |
79 | } | |
80 | }) | |
81 | }) |