aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-23 11:28:27 +0200
committerChocobozzz <me@florianbigard.com>2018-07-24 14:04:05 +0200
commit5bcfd02974389e1a131496d22f4321a79bed0fbb (patch)
tree483f0c64d28763aa5f0ad42eb67ccd5618e90052 /server
parent6e930af9f8f3a3b95c4693600ff8558bca3173ad (diff)
downloadPeerTube-5bcfd02974389e1a131496d22f4321a79bed0fbb.tar.gz
PeerTube-5bcfd02974389e1a131496d22f4321a79bed0fbb.tar.zst
PeerTube-5bcfd02974389e1a131496d22f4321a79bed0fbb.zip
Fix travis tests
Diffstat (limited to 'server')
-rw-r--r--server/tests/api/server/config.ts37
-rw-r--r--server/tests/client.ts80
2 files changed, 87 insertions, 30 deletions
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index 7d21b6ce9..1782a8623 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -4,16 +4,19 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { About } from '../../../../shared/models/server/about.model' 5import { About } from '../../../../shared/models/server/about.model'
6import { CustomConfig } from '../../../../shared/models/server/custom-config.model' 6import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
7import { deleteCustomConfig, getAbout, killallServers, makeHTMLRequest, reRunServer } from '../../utils' 7import { deleteCustomConfig, getAbout, killallServers, reRunServer } from '../../utils'
8const expect = chai.expect
9
10import { 8import {
11 getConfig,
12 flushTests, 9 flushTests,
10 getConfig,
11 getCustomConfig,
12 registerUser,
13 runServer, 13 runServer,
14 registerUser, getCustomConfig, setAccessTokensToServers, updateCustomConfig 14 setAccessTokensToServers,
15 updateCustomConfig
15} from '../../utils/index' 16} from '../../utils/index'
16 17
18const expect = chai.expect
19
17function checkInitialConfig (data: CustomConfig) { 20function checkInitialConfig (data: CustomConfig) {
18 expect(data.instance.name).to.equal('PeerTube') 21 expect(data.instance.name).to.equal('PeerTube')
19 expect(data.instance.shortDescription).to.equal( 22 expect(data.instance.shortDescription).to.equal(
@@ -69,12 +72,6 @@ function checkUpdatedConfig (data: CustomConfig) {
69 expect(data.transcoding.resolutions['1080p']).to.be.false 72 expect(data.transcoding.resolutions['1080p']).to.be.false
70} 73}
71 74
72function checkIndexTags (html: string, title: string, description: string, css: string) {
73 expect(html).to.contain('<title>' + title + '</title>')
74 expect(html).to.contain('<meta name="description" content="' + description + '" />')
75 expect(html).to.contain('<style class="custom-css-style">' + css + '</style>')
76}
77
78describe('Test config', function () { 75describe('Test config', function () {
79 let server = null 76 let server = null
80 77
@@ -115,14 +112,6 @@ describe('Test config', function () {
115 checkInitialConfig(data) 112 checkInitialConfig(data)
116 }) 113 })
117 114
118 it('Should have valid index html tags (title, description...)', async function () {
119 const res = await makeHTMLRequest(server.url, '/videos/trending')
120
121 const description = 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' +
122 'with WebTorrent and Angular.'
123 checkIndexTags(res.text, 'PeerTube', description, '')
124 })
125
126 it('Should update the customized configuration', async function () { 115 it('Should update the customized configuration', async function () {
127 const newCustomConfig: CustomConfig = { 116 const newCustomConfig: CustomConfig = {
128 instance: { 117 instance: {
@@ -181,12 +170,6 @@ describe('Test config', function () {
181 checkUpdatedConfig(data) 170 checkUpdatedConfig(data)
182 }) 171 })
183 172
184 it('Should have valid index html updated tags (title, description...)', async function () {
185 const res = await makeHTMLRequest(server.url, '/videos/trending')
186
187 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
188 })
189
190 it('Should have the configuration updated after a restart', async function () { 173 it('Should have the configuration updated after a restart', async function () {
191 this.timeout(10000) 174 this.timeout(10000)
192 175
@@ -198,10 +181,6 @@ describe('Test config', function () {
198 const data = res.body 181 const data = res.body
199 182
200 checkUpdatedConfig(data) 183 checkUpdatedConfig(data)
201
202 // Check HTML too
203 const resHtml = await makeHTMLRequest(server.url, '/videos/trending')
204 checkIndexTags(resHtml.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
205 }) 184 })
206 185
207 it('Should fetch the about information', async function () { 186 it('Should fetch the about information', async function () {
diff --git a/server/tests/client.ts b/server/tests/client.ts
index 687655452..bcbac86e9 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -11,8 +11,15 @@ import {
11 runServer, 11 runServer,
12 serverLogin, 12 serverLogin,
13 uploadVideo, 13 uploadVideo,
14 getVideosList, updateCustomConfig, getCustomConfig, killallServers 14 getVideosList, updateCustomConfig, getCustomConfig, killallServers, makeHTMLRequest
15} from './utils' 15} from './utils'
16import { CustomConfig } from '../../shared/models/server/custom-config.model'
17
18function checkIndexTags (html: string, title: string, description: string, css: string) {
19 expect(html).to.contain('<title>' + title + '</title>')
20 expect(html).to.contain('<meta name="description" content="' + description + '" />')
21 expect(html).to.contain('<style class="custom-css-style">' + css + '</style>')
22}
16 23
17describe('Test a client controllers', function () { 24describe('Test a client controllers', function () {
18 let server: ServerInfo 25 let server: ServerInfo
@@ -101,6 +108,77 @@ describe('Test a client controllers', function () {
101 expect(res.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 108 expect(res.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
102 }) 109 })
103 110
111 it('Should have valid index html tags (title, description...)', async function () {
112 const res = await makeHTMLRequest(server.url, '/videos/trending')
113
114 const description = 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' +
115 'with WebTorrent and Angular.'
116 checkIndexTags(res.text, 'PeerTube', description, '')
117 })
118
119 it('Should update the customized configuration and have the correct index html tags', async function () {
120 const newCustomConfig: CustomConfig = {
121 instance: {
122 name: 'PeerTube updated',
123 shortDescription: 'my short description',
124 description: 'my super description',
125 terms: 'my super terms',
126 defaultClientRoute: '/videos/recently-added',
127 defaultNSFWPolicy: 'blur' as 'blur',
128 customizations: {
129 javascript: 'alert("coucou")',
130 css: 'body { background-color: red; }'
131 }
132 },
133 services: {
134 twitter: {
135 username: '@Kuja',
136 whitelisted: true
137 }
138 },
139 cache: {
140 previews: {
141 size: 2
142 },
143 captions: {
144 size: 3
145 }
146 },
147 signup: {
148 enabled: false,
149 limit: 5
150 },
151 admin: {
152 email: 'superadmin1@example.com'
153 },
154 user: {
155 videoQuota: 5242881
156 },
157 transcoding: {
158 enabled: true,
159 threads: 1,
160 resolutions: {
161 '240p': false,
162 '360p': true,
163 '480p': true,
164 '720p': false,
165 '1080p': false
166 }
167 }
168 }
169 await updateCustomConfig(server.url, server.accessToken, newCustomConfig)
170
171 const res = await makeHTMLRequest(server.url, '/videos/trending')
172
173 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
174 })
175
176 it('Should have valid index html updated tags (title, description...)', async function () {
177 const res = await makeHTMLRequest(server.url, '/videos/trending')
178
179 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
180 })
181
104 after(async function () { 182 after(async function () {
105 killallServers([ server ]) 183 killallServers([ server ])
106 }) 184 })