aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/client.ts')
-rw-r--r--server/tests/client.ts396
1 files changed, 244 insertions, 152 deletions
diff --git a/server/tests/client.ts b/server/tests/client.ts
index 3c99bcd1f..253a95624 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -2,8 +2,10 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash'
5import * as request from 'supertest' 6import * as request from 'supertest'
6import { Account, VideoPlaylistPrivacy } from '@shared/models' 7import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
8import { Account, CustomConfig, HTMLServerConfig, ServerConfig, VideoPlaylistPrivacy } from '@shared/models'
7import { 9import {
8 addVideoInPlaylist, 10 addVideoInPlaylist,
9 cleanupTests, 11 cleanupTests,
@@ -11,8 +13,10 @@ import {
11 doubleFollow, 13 doubleFollow,
12 flushAndRunMultipleServers, 14 flushAndRunMultipleServers,
13 getAccount, 15 getAccount,
16 getConfig,
14 getCustomConfig, 17 getCustomConfig,
15 getVideosList, 18 getVideosList,
19 makeGetRequest,
16 makeHTMLRequest, 20 makeHTMLRequest,
17 ServerInfo, 21 ServerInfo,
18 setAccessTokensToServers, 22 setAccessTokensToServers,
@@ -24,14 +28,16 @@ import {
24 uploadVideo, 28 uploadVideo,
25 waitJobs 29 waitJobs
26} from '../../shared/extra-utils' 30} from '../../shared/extra-utils'
27import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
28 31
29const expect = chai.expect 32const expect = chai.expect
30 33
31function checkIndexTags (html: string, title: string, description: string, css: string) { 34function checkIndexTags (html: string, title: string, description: string, css: string, config: ServerConfig) {
32 expect(html).to.contain('<title>' + title + '</title>') 35 expect(html).to.contain('<title>' + title + '</title>')
33 expect(html).to.contain('<meta name="description" content="' + description + '" />') 36 expect(html).to.contain('<meta name="description" content="' + description + '" />')
34 expect(html).to.contain('<style class="custom-css-style">' + css + '</style>') 37 expect(html).to.contain('<style class="custom-css-style">' + css + '</style>')
38
39 const htmlConfig: HTMLServerConfig = omit(config, 'signup')
40 expect(html).to.contain(`<script type="application/javascript">window.PeerTubeServerConfig = '${JSON.stringify(htmlConfig)}'</script>`)
35} 41}
36 42
37describe('Test a client controllers', function () { 43describe('Test a client controllers', function () {
@@ -48,6 +54,9 @@ describe('Test a client controllers', function () {
48 54
49 const channelDescription = 'my super channel description' 55 const channelDescription = 'my super channel description'
50 56
57 const watchVideoBasePaths = [ '/videos/watch/', '/w/' ]
58 const watchPlaylistBasePaths = [ '/videos/watch/playlist/', '/w/p/' ]
59
51 before(async function () { 60 before(async function () {
52 this.timeout(120000) 61 this.timeout(120000)
53 62
@@ -105,201 +114,258 @@ describe('Test a client controllers', function () {
105 }) 114 })
106 115
107 describe('oEmbed', function () { 116 describe('oEmbed', function () {
117
108 it('Should have valid oEmbed discovery tags for videos', async function () { 118 it('Should have valid oEmbed discovery tags for videos', async function () {
109 const path = '/videos/watch/' + servers[0].video.uuid 119 for (const basePath of watchVideoBasePaths) {
110 const res = await request(servers[0].url) 120 const path = basePath + servers[0].video.uuid
111 .get(path) 121 const res = await request(servers[0].url)
112 .set('Accept', 'text/html') 122 .get(path)
113 .expect(HttpStatusCode.OK_200) 123 .set('Accept', 'text/html')
124 .expect(HttpStatusCode.OK_200)
114 125
115 const port = servers[0].port 126 const port = servers[0].port
116 127
117 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' + 128 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' +
118 `url=http%3A%2F%2Flocalhost%3A${port}%2Fvideos%2Fwatch%2F${servers[0].video.uuid}" ` + 129 `url=http%3A%2F%2Flocalhost%3A${port}%2Fw%2F${servers[0].video.uuid}" ` +
119 `title="${servers[0].video.name}" />` 130 `title="${servers[0].video.name}" />`
120 131
121 expect(res.text).to.contain(expectedLink) 132 expect(res.text).to.contain(expectedLink)
133 }
122 }) 134 })
123 135
124 it('Should have valid oEmbed discovery tags for a playlist', async function () { 136 it('Should have valid oEmbed discovery tags for a playlist', async function () {
125 const res = await request(servers[0].url) 137 for (const basePath of watchPlaylistBasePaths) {
126 .get('/videos/watch/playlist/' + playlistUUID) 138 const res = await request(servers[0].url)
127 .set('Accept', 'text/html') 139 .get(basePath + playlistUUID)
128 .expect(HttpStatusCode.OK_200) 140 .set('Accept', 'text/html')
141 .expect(HttpStatusCode.OK_200)
129 142
130 const port = servers[0].port 143 const port = servers[0].port
131 144
132 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' + 145 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' +
133 `url=http%3A%2F%2Flocalhost%3A${port}%2Fvideos%2Fwatch%2Fplaylist%2F${playlistUUID}" ` + 146 `url=http%3A%2F%2Flocalhost%3A${port}%2Fw%2Fp%2F${playlistUUID}" ` +
134 `title="${playlistName}" />` 147 `title="${playlistName}" />`
135 148
136 expect(res.text).to.contain(expectedLink) 149 expect(res.text).to.contain(expectedLink)
150 }
137 }) 151 })
138 }) 152 })
139 153
140 describe('Open Graph', function () { 154 describe('Open Graph', function () {
141 155
142 it('Should have valid Open Graph tags on the account page', async function () { 156 async function accountPageTest (path: string) {
143 const res = await request(servers[0].url) 157 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
144 .get('/accounts/' + servers[0].user.username) 158 const text = res.text
145 .set('Accept', 'text/html')
146 .expect(HttpStatusCode.OK_200)
147
148 expect(res.text).to.contain(`<meta property="og:title" content="${account.displayName}" />`)
149 expect(res.text).to.contain(`<meta property="og:description" content="${account.description}" />`)
150 expect(res.text).to.contain('<meta property="og:type" content="website" />')
151 expect(res.text).to.contain(`<meta property="og:url" content="${servers[0].url}/accounts/${servers[0].user.username}" />`)
152 })
153 159
154 it('Should have valid Open Graph tags on the channel page', async function () { 160 expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`)
155 const res = await request(servers[0].url) 161 expect(text).to.contain(`<meta property="og:description" content="${account.description}" />`)
156 .get('/video-channels/' + servers[0].videoChannel.name) 162 expect(text).to.contain('<meta property="og:type" content="website" />')
157 .set('Accept', 'text/html') 163 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/accounts/${servers[0].user.username}" />`)
158 .expect(HttpStatusCode.OK_200) 164 }
159 165
160 expect(res.text).to.contain(`<meta property="og:title" content="${servers[0].videoChannel.displayName}" />`) 166 async function channelPageTest (path: string) {
161 expect(res.text).to.contain(`<meta property="og:description" content="${channelDescription}" />`) 167 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
162 expect(res.text).to.contain('<meta property="og:type" content="website" />') 168 const text = res.text
163 expect(res.text).to.contain(`<meta property="og:url" content="${servers[0].url}/video-channels/${servers[0].videoChannel.name}" />`)
164 })
165 169
166 it('Should have valid Open Graph tags on the watch page with video id', async function () { 170 expect(text).to.contain(`<meta property="og:title" content="${servers[0].videoChannel.displayName}" />`)
167 const res = await request(servers[0].url) 171 expect(text).to.contain(`<meta property="og:description" content="${channelDescription}" />`)
168 .get('/videos/watch/' + servers[0].video.id) 172 expect(text).to.contain('<meta property="og:type" content="website" />')
169 .set('Accept', 'text/html') 173 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/video-channels/${servers[0].videoChannel.name}" />`)
170 .expect(HttpStatusCode.OK_200) 174 }
175
176 async function watchVideoPageTest (path: string) {
177 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
178 const text = res.text
179
180 expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`)
181 expect(text).to.contain(`<meta property="og:description" content="${videoDescriptionPlainText}" />`)
182 expect(text).to.contain('<meta property="og:type" content="video" />')
183 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/${servers[0].video.uuid}" />`)
184 }
171 185
172 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`) 186 async function watchPlaylistPageTest (path: string) {
173 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescriptionPlainText}" />`) 187 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
174 expect(res.text).to.contain('<meta property="og:type" content="video" />') 188 const text = res.text
175 expect(res.text).to.contain(`<meta property="og:url" content="${servers[0].url}/videos/watch/${servers[0].video.uuid}" />`) 189
190 expect(text).to.contain(`<meta property="og:title" content="${playlistName}" />`)
191 expect(text).to.contain(`<meta property="og:description" content="${playlistDescription}" />`)
192 expect(text).to.contain('<meta property="og:type" content="video" />')
193 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/p/${playlistUUID}" />`)
194 }
195
196 it('Should have valid Open Graph tags on the account page', async function () {
197 await accountPageTest('/accounts/' + servers[0].user.username)
198 await accountPageTest('/a/' + servers[0].user.username)
199 await accountPageTest('/@' + servers[0].user.username)
176 }) 200 })
177 201
178 it('Should have valid Open Graph tags on the watch page with video uuid', async function () { 202 it('Should have valid Open Graph tags on the channel page', async function () {
179 const res = await request(servers[0].url) 203 await channelPageTest('/video-channels/' + servers[0].videoChannel.name)
180 .get('/videos/watch/' + servers[0].video.uuid) 204 await channelPageTest('/c/' + servers[0].videoChannel.name)
181 .set('Accept', 'text/html') 205 await channelPageTest('/@' + servers[0].videoChannel.name)
182 .expect(HttpStatusCode.OK_200) 206 })
183 207
184 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`) 208 it('Should have valid Open Graph tags on the watch page', async function () {
185 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescriptionPlainText}" />`) 209 await watchVideoPageTest('/videos/watch/' + servers[0].video.id)
186 expect(res.text).to.contain('<meta property="og:type" content="video" />') 210 await watchVideoPageTest('/videos/watch/' + servers[0].video.uuid)
187 expect(res.text).to.contain(`<meta property="og:url" content="${servers[0].url}/videos/watch/${servers[0].video.uuid}" />`) 211 await watchVideoPageTest('/w/' + servers[0].video.uuid)
212 await watchVideoPageTest('/w/' + servers[0].video.id)
188 }) 213 })
189 214
190 it('Should have valid Open Graph tags on the watch playlist page', async function () { 215 it('Should have valid Open Graph tags on the watch playlist page', async function () {
191 const res = await request(servers[0].url) 216 await watchPlaylistPageTest('/videos/watch/playlist/' + playlistUUID)
192 .get('/videos/watch/playlist/' + playlistUUID) 217 await watchPlaylistPageTest('/w/p/' + playlistUUID)
193 .set('Accept', 'text/html')
194 .expect(HttpStatusCode.OK_200)
195
196 expect(res.text).to.contain(`<meta property="og:title" content="${playlistName}" />`)
197 expect(res.text).to.contain(`<meta property="og:description" content="${playlistDescription}" />`)
198 expect(res.text).to.contain('<meta property="og:type" content="video" />')
199 expect(res.text).to.contain(`<meta property="og:url" content="${servers[0].url}/videos/watch/playlist/${playlistUUID}" />`)
200 }) 218 })
201 }) 219 })
202 220
203 describe('Twitter card', async function () { 221 describe('Twitter card', async function () {
204 222
205 it('Should have valid twitter card on the watch video page', async function () { 223 describe('Not whitelisted', function () {
206 const res = await request(servers[0].url)
207 .get('/videos/watch/' + servers[0].video.uuid)
208 .set('Accept', 'text/html')
209 .expect(HttpStatusCode.OK_200)
210 224
211 expect(res.text).to.contain('<meta property="twitter:card" content="summary_large_image" />') 225 async function accountPageTest (path: string) {
212 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 226 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
213 expect(res.text).to.contain(`<meta property="twitter:title" content="${videoName}" />`) 227 const text = res.text
214 expect(res.text).to.contain(`<meta property="twitter:description" content="${videoDescriptionPlainText}" />`) 228
215 }) 229 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
230 expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
231 expect(text).to.contain(`<meta property="twitter:title" content="${account.name}" />`)
232 expect(text).to.contain(`<meta property="twitter:description" content="${account.description}" />`)
233 }
216 234
217 it('Should have valid twitter card on the watch playlist page', async function () { 235 async function channelPageTest (path: string) {
218 const res = await request(servers[0].url) 236 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
219 .get('/videos/watch/playlist/' + playlistUUID) 237 const text = res.text
220 .set('Accept', 'text/html')
221 .expect(HttpStatusCode.OK_200)
222 238
223 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') 239 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
224 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 240 expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
225 expect(res.text).to.contain(`<meta property="twitter:title" content="${playlistName}" />`) 241 expect(text).to.contain(`<meta property="twitter:title" content="${servers[0].videoChannel.displayName}" />`)
226 expect(res.text).to.contain(`<meta property="twitter:description" content="${playlistDescription}" />`) 242 expect(text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`)
227 }) 243 }
228 244
229 it('Should have valid twitter card on the account page', async function () { 245 async function watchVideoPageTest (path: string) {
230 const res = await request(servers[0].url) 246 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
231 .get('/accounts/' + account.name) 247 const text = res.text
232 .set('Accept', 'text/html')
233 .expect(HttpStatusCode.OK_200)
234 248
235 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') 249 expect(text).to.contain('<meta property="twitter:card" content="summary_large_image" />')
236 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 250 expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
237 expect(res.text).to.contain(`<meta property="twitter:title" content="${account.name}" />`) 251 expect(text).to.contain(`<meta property="twitter:title" content="${videoName}" />`)
238 expect(res.text).to.contain(`<meta property="twitter:description" content="${account.description}" />`) 252 expect(text).to.contain(`<meta property="twitter:description" content="${videoDescriptionPlainText}" />`)
239 }) 253 }
254
255 async function watchPlaylistPageTest (path: string) {
256 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
257 const text = res.text
240 258
241 it('Should have valid twitter card on the channel page', async function () { 259 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
242 const res = await request(servers[0].url) 260 expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
243 .get('/video-channels/' + servers[0].videoChannel.name) 261 expect(text).to.contain(`<meta property="twitter:title" content="${playlistName}" />`)
244 .set('Accept', 'text/html') 262 expect(text).to.contain(`<meta property="twitter:description" content="${playlistDescription}" />`)
245 .expect(HttpStatusCode.OK_200) 263 }
246 264
247 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') 265 it('Should have valid twitter card on the watch video page', async function () {
248 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 266 await watchVideoPageTest('/videos/watch/' + servers[0].video.id)
249 expect(res.text).to.contain(`<meta property="twitter:title" content="${servers[0].videoChannel.displayName}" />`) 267 await watchVideoPageTest('/videos/watch/' + servers[0].video.uuid)
250 expect(res.text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`) 268 await watchVideoPageTest('/w/' + servers[0].video.uuid)
269 await watchVideoPageTest('/w/' + servers[0].video.id)
270 })
271
272 it('Should have valid twitter card on the watch playlist page', async function () {
273 await watchPlaylistPageTest('/videos/watch/playlist/' + playlistUUID)
274 await watchPlaylistPageTest('/w/p/' + playlistUUID)
275 })
276
277 it('Should have valid twitter card on the account page', async function () {
278 await accountPageTest('/accounts/' + account.name)
279 await accountPageTest('/a/' + account.name)
280 await accountPageTest('/@' + account.name)
281 })
282
283 it('Should have valid twitter card on the channel page', async function () {
284 await channelPageTest('/video-channels/' + servers[0].videoChannel.name)
285 await channelPageTest('/c/' + servers[0].videoChannel.name)
286 await channelPageTest('/@' + servers[0].videoChannel.name)
287 })
251 }) 288 })
252 289
253 it('Should have valid twitter card if Twitter is whitelisted', async function () { 290 describe('Whitelisted', function () {
254 const res1 = await getCustomConfig(servers[0].url, servers[0].accessToken) 291
255 const config = res1.body 292 before(async function () {
256 config.services.twitter = { 293 const res = await getCustomConfig(servers[0].url, servers[0].accessToken)
257 username: '@Kuja', 294 const config = res.body as CustomConfig
258 whitelisted: true 295 config.services.twitter = {
296 username: '@Kuja',
297 whitelisted: true
298 }
299
300 await updateCustomConfig(servers[0].url, servers[0].accessToken, config)
301 })
302
303 async function accountPageTest (path: string) {
304 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
305 const text = res.text
306
307 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
308 expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
259 } 309 }
260 await updateCustomConfig(servers[0].url, servers[0].accessToken, config)
261 310
262 const resVideoRequest = await request(servers[0].url) 311 async function channelPageTest (path: string) {
263 .get('/videos/watch/' + servers[0].video.uuid) 312 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
264 .set('Accept', 'text/html') 313 const text = res.text
265 .expect(HttpStatusCode.OK_200)
266 314
267 expect(resVideoRequest.text).to.contain('<meta property="twitter:card" content="player" />') 315 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
268 expect(resVideoRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 316 expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
317 }
318
319 async function watchVideoPageTest (path: string) {
320 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
321 const text = res.text
322
323 expect(text).to.contain('<meta property="twitter:card" content="player" />')
324 expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
325 }
269 326
270 const resVideoPlaylistRequest = await request(servers[0].url) 327 async function watchPlaylistPageTest (path: string) {
271 .get('/videos/watch/playlist/' + playlistUUID) 328 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
272 .set('Accept', 'text/html') 329 const text = res.text
273 .expect(HttpStatusCode.OK_200)
274 330
275 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:card" content="player" />') 331 expect(text).to.contain('<meta property="twitter:card" content="player" />')
276 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 332 expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
333 }
277 334
278 const resAccountRequest = await request(servers[0].url) 335 it('Should have valid twitter card on the watch video page', async function () {
279 .get('/accounts/' + account.name) 336 await watchVideoPageTest('/videos/watch/' + servers[0].video.id)
280 .set('Accept', 'text/html') 337 await watchVideoPageTest('/videos/watch/' + servers[0].video.uuid)
281 .expect(HttpStatusCode.OK_200) 338 await watchVideoPageTest('/w/' + servers[0].video.uuid)
339 await watchVideoPageTest('/w/' + servers[0].video.id)
340 })
282 341
283 expect(resAccountRequest.text).to.contain('<meta property="twitter:card" content="summary" />') 342 it('Should have valid twitter card on the watch playlist page', async function () {
284 expect(resAccountRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 343 await watchPlaylistPageTest('/videos/watch/playlist/' + playlistUUID)
344 await watchPlaylistPageTest('/w/p/' + playlistUUID)
345 })
285 346
286 const resChannelRequest = await request(servers[0].url) 347 it('Should have valid twitter card on the account page', async function () {
287 .get('/video-channels/' + servers[0].videoChannel.name) 348 await accountPageTest('/accounts/' + account.name)
288 .set('Accept', 'text/html') 349 await accountPageTest('/a/' + account.name)
289 .expect(HttpStatusCode.OK_200) 350 await accountPageTest('/@' + account.name)
351 })
290 352
291 expect(resChannelRequest.text).to.contain('<meta property="twitter:card" content="summary" />') 353 it('Should have valid twitter card on the channel page', async function () {
292 expect(resChannelRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 354 await channelPageTest('/video-channels/' + servers[0].videoChannel.name)
355 await channelPageTest('/c/' + servers[0].videoChannel.name)
356 await channelPageTest('/@' + servers[0].videoChannel.name)
357 })
293 }) 358 })
294 }) 359 })
295 360
296 describe('Index HTML', function () { 361 describe('Index HTML', function () {
297 362
298 it('Should have valid index html tags (title, description...)', async function () { 363 it('Should have valid index html tags (title, description...)', async function () {
364 const resConfig = await getConfig(servers[0].url)
299 const res = await makeHTMLRequest(servers[0].url, '/videos/trending') 365 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
300 366
301 const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' 367 const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'
302 checkIndexTags(res.text, 'PeerTube', description, '') 368 checkIndexTags(res.text, 'PeerTube', description, '', resConfig.body)
303 }) 369 })
304 370
305 it('Should update the customized configuration and have the correct index html tags', async function () { 371 it('Should update the customized configuration and have the correct index html tags', async function () {
@@ -318,35 +384,61 @@ describe('Test a client controllers', function () {
318 } 384 }
319 }) 385 })
320 386
387 const resConfig = await getConfig(servers[0].url)
321 const res = await makeHTMLRequest(servers[0].url, '/videos/trending') 388 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
322 389
323 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }') 390 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body)
324 }) 391 })
325 392
326 it('Should have valid index html updated tags (title, description...)', async function () { 393 it('Should have valid index html updated tags (title, description...)', async function () {
394 const resConfig = await getConfig(servers[0].url)
327 const res = await makeHTMLRequest(servers[0].url, '/videos/trending') 395 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
328 396
329 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }') 397 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body)
330 }) 398 })
331 399
332 it('Should use the original video URL for the canonical tag', async function () { 400 it('Should use the original video URL for the canonical tag', async function () {
333 const res = await makeHTMLRequest(servers[1].url, '/videos/watch/' + servers[0].video.uuid) 401 for (const basePath of watchVideoBasePaths) {
334 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/videos/watch/${servers[0].video.uuid}" />`) 402 const res = await makeHTMLRequest(servers[1].url, basePath + servers[0].video.uuid)
403 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/videos/watch/${servers[0].video.uuid}" />`)
404 }
335 }) 405 })
336 406
337 it('Should use the original account URL for the canonical tag', async function () { 407 it('Should use the original account URL for the canonical tag', async function () {
338 const res = await makeHTMLRequest(servers[1].url, '/accounts/root@' + servers[0].host) 408 const accountURLtest = (res) => {
339 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/accounts/root" />`) 409 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/accounts/root" />`)
410 }
411
412 accountURLtest(await makeHTMLRequest(servers[1].url, '/accounts/root@' + servers[0].host))
413 accountURLtest(await makeHTMLRequest(servers[1].url, '/a/root@' + servers[0].host))
414 accountURLtest(await makeHTMLRequest(servers[1].url, '/@root@' + servers[0].host))
340 }) 415 })
341 416
342 it('Should use the original channel URL for the canonical tag', async function () { 417 it('Should use the original channel URL for the canonical tag', async function () {
343 const res = await makeHTMLRequest(servers[1].url, '/video-channels/root_channel@' + servers[0].host) 418 const channelURLtests = (res) => {
344 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-channels/root_channel" />`) 419 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-channels/root_channel" />`)
420 }
421
422 channelURLtests(await makeHTMLRequest(servers[1].url, '/video-channels/root_channel@' + servers[0].host))
423 channelURLtests(await makeHTMLRequest(servers[1].url, '/c/root_channel@' + servers[0].host))
424 channelURLtests(await makeHTMLRequest(servers[1].url, '/@root_channel@' + servers[0].host))
345 }) 425 })
346 426
347 it('Should use the original playlist URL for the canonical tag', async function () { 427 it('Should use the original playlist URL for the canonical tag', async function () {
348 const res = await makeHTMLRequest(servers[1].url, '/videos/watch/playlist/' + playlistUUID) 428 for (const basePath of watchPlaylistBasePaths) {
349 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-playlists/${playlistUUID}" />`) 429 const res = await makeHTMLRequest(servers[1].url, basePath + playlistUUID)
430 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-playlists/${playlistUUID}" />`)
431 }
432 })
433 })
434
435 describe('Embed HTML', function () {
436
437 it('Should have the correct embed html tags', async function () {
438 const resConfig = await getConfig(servers[0].url)
439 const res = await makeHTMLRequest(servers[0].url, servers[0].video.embedPath)
440
441 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body)
350 }) 442 })
351 }) 443 })
352 444