diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-07-11 16:16:51 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-07-11 16:16:51 +0200 |
commit | 4e979c3e1b81f4762025d9db3052b1f70774b3bb (patch) | |
tree | 19bc5485d866279cce246d8fa1a0546faddc0696 | |
parent | 0a6658fdcbd779ada8f3758048c326e997902d5a (diff) | |
download | PeerTube-4e979c3e1b81f4762025d9db3052b1f70774b3bb.tar.gz PeerTube-4e979c3e1b81f4762025d9db3052b1f70774b3bb.tar.zst PeerTube-4e979c3e1b81f4762025d9db3052b1f70774b3bb.zip |
Add tests for open graph tags
-rw-r--r-- | server/tests/client.js | 96 | ||||
-rw-r--r-- | server/tests/index.js | 1 |
2 files changed, 97 insertions, 0 deletions
diff --git a/server/tests/client.js b/server/tests/client.js new file mode 100644 index 000000000..0cdf0a260 --- /dev/null +++ b/server/tests/client.js | |||
@@ -0,0 +1,96 @@ | |||
1 | /* eslint-disable no-unused-expressions */ | ||
2 | |||
3 | 'use strict' | ||
4 | |||
5 | const chai = require('chai') | ||
6 | const expect = chai.expect | ||
7 | const request = require('supertest') | ||
8 | const series = require('async/series') | ||
9 | |||
10 | const loginUtils = require('./utils/login') | ||
11 | const serversUtils = require('./utils/servers') | ||
12 | const videosUtils = require('./utils/videos') | ||
13 | |||
14 | describe('Test a client controllers', function () { | ||
15 | let server = null | ||
16 | |||
17 | before(function (done) { | ||
18 | this.timeout(120000) | ||
19 | |||
20 | series([ | ||
21 | function (next) { | ||
22 | serversUtils.flushTests(next) | ||
23 | }, | ||
24 | function (next) { | ||
25 | serversUtils.runServer(1, function (server1) { | ||
26 | server = server1 | ||
27 | next() | ||
28 | }) | ||
29 | }, | ||
30 | function (next) { | ||
31 | loginUtils.loginAndGetAccessToken(server, function (err, token) { | ||
32 | if (err) throw err | ||
33 | server.accessToken = token | ||
34 | next() | ||
35 | }) | ||
36 | }, | ||
37 | function (next) { | ||
38 | const videoAttributes = { | ||
39 | name: 'my super name for pod 1', | ||
40 | description: 'my super description for pod 1' | ||
41 | } | ||
42 | videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, next) | ||
43 | }, | ||
44 | function (next) { | ||
45 | videosUtils.getVideosList(server.url, function (err, res) { | ||
46 | if (err) throw err | ||
47 | |||
48 | const videos = res.body.data | ||
49 | |||
50 | expect(videos.length).to.equal(1) | ||
51 | |||
52 | server.video = videos[0] | ||
53 | |||
54 | next() | ||
55 | }) | ||
56 | } | ||
57 | ], done) | ||
58 | }) | ||
59 | |||
60 | it('It should have valid opengraph tags on the watch page with video id', function (done) { | ||
61 | request(server.url) | ||
62 | .get('/videos/watch/' + server.video.id) | ||
63 | .expect(200, function (err, res) { | ||
64 | if (err) throw err | ||
65 | |||
66 | expect(res.text).to.contain('<meta property="og:title" content="my super name for pod 1" />') | ||
67 | expect(res.text).to.contain('<meta property="og:description" content="my super description for pod 1" />') | ||
68 | |||
69 | done() | ||
70 | }) | ||
71 | }) | ||
72 | |||
73 | it('It should have valid opengraph tags on the watch page with video uuid', function (done) { | ||
74 | request(server.url) | ||
75 | .get('/videos/watch/' + server.video.uuid) | ||
76 | .expect(200, function (err, res) { | ||
77 | if (err) throw err | ||
78 | |||
79 | expect(res.text).to.contain('<meta property="og:title" content="my super name for pod 1" />') | ||
80 | expect(res.text).to.contain('<meta property="og:description" content="my super description for pod 1" />') | ||
81 | |||
82 | done() | ||
83 | }) | ||
84 | }) | ||
85 | |||
86 | after(function (done) { | ||
87 | process.kill(-server.app.pid) | ||
88 | |||
89 | // Keep the logs if the test failed | ||
90 | if (this.ok) { | ||
91 | serversUtils.flushTests(done) | ||
92 | } else { | ||
93 | done() | ||
94 | } | ||
95 | }) | ||
96 | }) | ||
diff --git a/server/tests/index.js b/server/tests/index.js index cb177b87c..0bc0523a5 100644 --- a/server/tests/index.js +++ b/server/tests/index.js | |||
@@ -1,4 +1,5 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | // Order of the tests we want to execute | 3 | // Order of the tests we want to execute |
4 | require('./client') | ||
4 | require('./api/') | 5 | require('./api/') |