]>
Commit | Line | Data |
---|---|---|
0e1dc3e7 C |
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, | |
eec63bbc | 12 | serverLogin, |
0e1dc3e7 | 13 | uploadVideo, |
8be1afa1 | 14 | getVideosList, updateCustomConfig, getCustomConfig |
0e1dc3e7 C |
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) | |
eec63bbc | 26 | server.accessToken = await serverLogin(server) |
0e1dc3e7 C |
27 | |
28 | const videoAttributes = { | |
9a27cdc2 C |
29 | name: 'my super name for server 1', |
30 | description: 'my super description for server 1' | |
0e1dc3e7 C |
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 | ||
d8755eed | 42 | it('Should have valid Open Graph tags on the watch page with video id', async function () { |
0e1dc3e7 | 43 | const res = await request(server.url) |
98ec8b8e C |
44 | .get('/videos/watch/' + server.video.id) |
45 | .set('Accept', 'text/html') | |
46 | .expect(200) | |
0e1dc3e7 | 47 | |
9a27cdc2 C |
48 | expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />') |
49 | expect(res.text).to.contain('<meta property="og:description" content="my super description for server 1" />') | |
0e1dc3e7 C |
50 | }) |
51 | ||
d8755eed | 52 | it('Should have valid Open Graph tags on the watch page with video uuid', async function () { |
0e1dc3e7 | 53 | const res = await request(server.url) |
98ec8b8e C |
54 | .get('/videos/watch/' + server.video.uuid) |
55 | .set('Accept', 'text/html') | |
56 | .expect(200) | |
0e1dc3e7 | 57 | |
9a27cdc2 C |
58 | expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />') |
59 | expect(res.text).to.contain('<meta property="og:description" content="my super description for server 1" />') | |
0e1dc3e7 C |
60 | }) |
61 | ||
d8755eed C |
62 | it('Should have valid oEmbed discovery tags', async function () { |
63 | const path = '/videos/watch/' + server.video.uuid | |
64 | const res = await request(server.url) | |
65 | .get(path) | |
98ec8b8e | 66 | .set('Accept', 'text/html') |
d8755eed C |
67 | .expect(200) |
68 | ||
69 | const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:9001/services/oembed?' + | |
70 | `url=http%3A%2F%2Flocalhost%3A9001%2Fvideos%2Fwatch%2F${server.video.uuid}" ` + | |
71 | `title="${server.video.name}" />` | |
72 | ||
73 | expect(res.text).to.contain(expectedLink) | |
74 | }) | |
75 | ||
8be1afa1 C |
76 | it('Should have valid twitter card', async function () { |
77 | const res = await request(server.url) | |
78 | .get('/videos/watch/' + server.video.uuid) | |
79 | .set('Accept', 'text/html') | |
80 | .expect(200) | |
81 | ||
82 | expect(res.text).to.contain('<meta property="twitter:card" content="summary_large_image" />') | |
83 | expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') | |
84 | }) | |
85 | ||
86 | it('Should have valid twitter card if Twitter is whitelisted', async function () { | |
87 | const res1 = await getCustomConfig(server.url, server.accessToken) | |
88 | const config = res1.body | |
89 | config.services.twitter = { | |
90 | username: '@Kuja', | |
91 | whitelisted: true | |
92 | } | |
93 | await updateCustomConfig(server.url, server.accessToken, config) | |
94 | ||
95 | const res = await request(server.url) | |
96 | .get('/videos/watch/' + server.video.uuid) | |
97 | .set('Accept', 'text/html') | |
98 | .expect(200) | |
99 | ||
100 | expect(res.text).to.contain('<meta property="twitter:card" content="player" />') | |
101 | expect(res.text).to.contain('<meta property="twitter:site" content="@Kuja" />') | |
102 | }) | |
103 | ||
0e1dc3e7 C |
104 | after(async function () { |
105 | process.kill(-server.app.pid) | |
106 | ||
107 | // Keep the logs if the test failed | |
108 | if (this['ok']) { | |
109 | await flushTests() | |
110 | } | |
111 | }) | |
112 | }) |