]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/client.ts
Fix dependencies toc
[github/Chocobozzz/PeerTube.git] / server / tests / client.ts
CommitLineData
a1587156 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
0e1dc3e7
C
2
3import 'mocha'
4import * as chai from 'chai'
012580d9 5import { omit } from 'lodash'
1159c4a6
C
6import {
7 Account,
8 HTMLServerConfig,
9 HttpStatusCode,
10 ServerConfig,
11 VideoPlaylistCreateResult,
12 VideoPlaylistPrivacy,
13 VideoPrivacy
14} from '@shared/models'
0e1dc3e7 15import {
7c3b7976 16 cleanupTests,
254d3579 17 createMultipleServers,
4c7e60bc 18 doubleFollow,
012580d9 19 makeGetRequest,
590fb506 20 makeHTMLRequest,
254d3579 21 PeerTubeServer,
a59f210f 22 setAccessTokensToServers,
39433fa5 23 setDefaultVideoChannel,
a59f210f 24 waitJobs
bf54587a 25} from '../../shared/server-commands'
590fb506
C
26
27const expect = chai.expect
5bcfd029 28
aea0b0e7 29function checkIndexTags (html: string, title: string, description: string, css: string, config: ServerConfig) {
5bcfd029
C
30 expect(html).to.contain('<title>' + title + '</title>')
31 expect(html).to.contain('<meta name="description" content="' + description + '" />')
32 expect(html).to.contain('<style class="custom-css-style">' + css + '</style>')
aea0b0e7
C
33
34 const htmlConfig: HTMLServerConfig = omit(config, 'signup')
afe501a6
C
35 const configObjectString = JSON.stringify(htmlConfig)
36 const configEscapedString = JSON.stringify(configObjectString)
37
38 expect(html).to.contain(`<script type="application/javascript">window.PeerTubeServerConfig = ${configEscapedString}</script>`)
5bcfd029 39}
0e1dc3e7
C
40
41describe('Test a client controllers', function () {
254d3579 42 let servers: PeerTubeServer[] = []
39433fa5
C
43 let account: Account
44
45 const videoName = 'my super name for server 1'
a073c912
RK
46 const videoDescription = 'my<br> super __description__ for *server* 1<p></p>'
47 const videoDescriptionPlainText = 'my super description for server 1'
39433fa5
C
48
49 const playlistName = 'super playlist name'
50 const playlistDescription = 'super playlist description'
d4a8e7a6 51 let playlist: VideoPlaylistCreateResult
39433fa5
C
52
53 const channelDescription = 'my super channel description'
0e1dc3e7 54
a1eda903
C
55 const watchVideoBasePaths = [ '/videos/watch/', '/w/' ]
56 const watchPlaylistBasePaths = [ '/videos/watch/playlist/', '/w/p/' ]
57
d4a8e7a6 58 let videoIds: (string | number)[] = []
c6d20c84
C
59 let privateVideoId: string
60 let internalVideoId: string
61 let unlistedVideoId: string
62
d4a8e7a6
C
63 let playlistIds: (string | number)[] = []
64
0e1dc3e7
C
65 before(async function () {
66 this.timeout(120000)
67
254d3579 68 servers = await createMultipleServers(2)
e5024f51
TC
69
70 await setAccessTokensToServers(servers)
71
e5024f51
TC
72 await doubleFollow(servers[0], servers[1])
73
a59f210f 74 await setDefaultVideoChannel(servers)
0e1dc3e7 75
89d241a7
C
76 await servers[0].channels.update({
77 channelName: servers[0].store.channel.name,
a5461888
C
78 attributes: { description: channelDescription }
79 })
8d987ec6 80
c6d20c84 81 // Public video
8d987ec6 82
d23dd9fb
C
83 {
84 const attributes = { name: videoName, description: videoDescription }
89d241a7 85 await servers[0].videos.upload({ attributes })
0e1dc3e7 86
89d241a7 87 const { data } = await servers[0].videos.list()
d23dd9fb 88 expect(data.length).to.equal(1)
0e1dc3e7 89
d23dd9fb 90 const video = data[0]
89d241a7 91 servers[0].store.video = video
d23dd9fb
C
92 videoIds = [ video.id, video.uuid, video.shortUUID ]
93 }
8d987ec6 94
c6d20c84
C
95 {
96 ({ uuid: privateVideoId } = await servers[0].videos.quickUpload({ name: 'private', privacy: VideoPrivacy.PRIVATE }));
97 ({ uuid: unlistedVideoId } = await servers[0].videos.quickUpload({ name: 'unlisted', privacy: VideoPrivacy.UNLISTED }));
98 ({ uuid: internalVideoId } = await servers[0].videos.quickUpload({ name: 'internal', privacy: VideoPrivacy.INTERNAL }))
99 }
100
8d987ec6
K
101 // Playlist
102
d23dd9fb
C
103 {
104 const attributes = {
105 displayName: playlistName,
106 description: playlistDescription,
107 privacy: VideoPlaylistPrivacy.PUBLIC,
89d241a7 108 videoChannelId: servers[0].store.channel.id
d23dd9fb 109 }
8d987ec6 110
89d241a7 111 playlist = await servers[0].playlists.create({ attributes })
d23dd9fb 112 playlistIds = [ playlist.id, playlist.shortUUID, playlist.uuid ]
8d987ec6 113
89d241a7 114 await servers[0].playlists.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: servers[0].store.video.id } })
d23dd9fb 115 }
8d987ec6
K
116
117 // Account
118
d23dd9fb 119 {
89d241a7 120 await servers[0].users.updateMe({ description: 'my account description' })
8d987ec6 121
89d241a7 122 account = await servers[0].accounts.get({ accountName: `${servers[0].store.user.username}@${servers[0].host}` })
d23dd9fb 123 }
a59f210f
C
124
125 await waitJobs(servers)
0e1dc3e7
C
126 })
127
6fad8e51 128 describe('oEmbed', function () {
a1eda903 129
6fad8e51 130 it('Should have valid oEmbed discovery tags for videos', async function () {
a1eda903 131 for (const basePath of watchVideoBasePaths) {
d4a8e7a6
C
132 for (const id of videoIds) {
133 const res = await makeGetRequest({
134 url: servers[0].url,
135 path: basePath + id,
136 accept: 'text/html',
c0e8b12e 137 expectedStatus: HttpStatusCode.OK_200
d4a8e7a6 138 })
0e1dc3e7 139
d4a8e7a6 140 const port = servers[0].port
0e1dc3e7 141
d4a8e7a6 142 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' +
a892c54a 143 `url=http%3A%2F%2Flocalhost%3A${port}%2Fw%2F${servers[0].store.video.shortUUID}" ` +
89d241a7 144 `title="${servers[0].store.video.name}" />`
8d987ec6 145
d4a8e7a6
C
146 expect(res.text).to.contain(expectedLink)
147 }
a1eda903 148 }
6fad8e51 149 })
8d987ec6 150
6fad8e51 151 it('Should have valid oEmbed discovery tags for a playlist', async function () {
a1eda903 152 for (const basePath of watchPlaylistBasePaths) {
d4a8e7a6
C
153 for (const id of playlistIds) {
154 const res = await makeGetRequest({
155 url: servers[0].url,
156 path: basePath + id,
157 accept: 'text/html',
c0e8b12e 158 expectedStatus: HttpStatusCode.OK_200
d4a8e7a6 159 })
6fad8e51 160
d4a8e7a6 161 const port = servers[0].port
8d987ec6 162
d4a8e7a6 163 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' +
a892c54a 164 `url=http%3A%2F%2Flocalhost%3A${port}%2Fw%2Fp%2F${playlist.shortUUID}" ` +
d4a8e7a6 165 `title="${playlistName}" />`
8d987ec6 166
d4a8e7a6
C
167 expect(res.text).to.contain(expectedLink)
168 }
a1eda903 169 }
6fad8e51 170 })
8d987ec6
K
171 })
172
6fad8e51 173 describe('Open Graph', function () {
8d987ec6 174
012580d9 175 async function accountPageTest (path: string) {
c0e8b12e 176 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
012580d9 177 const text = res.text
9a911038 178
012580d9
C
179 expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`)
180 expect(text).to.contain(`<meta property="og:description" content="${account.description}" />`)
181 expect(text).to.contain('<meta property="og:type" content="website" />')
89d241a7 182 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/accounts/${servers[0].store.user.username}" />`)
012580d9 183 }
9a911038 184
012580d9 185 async function channelPageTest (path: string) {
c0e8b12e 186 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
012580d9 187 const text = res.text
0e1dc3e7 188
89d241a7 189 expect(text).to.contain(`<meta property="og:title" content="${servers[0].store.channel.displayName}" />`)
012580d9
C
190 expect(text).to.contain(`<meta property="og:description" content="${channelDescription}" />`)
191 expect(text).to.contain('<meta property="og:type" content="website" />')
89d241a7 192 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/video-channels/${servers[0].store.channel.name}" />`)
012580d9
C
193 }
194
a1eda903 195 async function watchVideoPageTest (path: string) {
c0e8b12e 196 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
a1eda903
C
197 const text = res.text
198
199 expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`)
200 expect(text).to.contain(`<meta property="og:description" content="${videoDescriptionPlainText}" />`)
201 expect(text).to.contain('<meta property="og:type" content="video" />')
a892c54a 202 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/${servers[0].store.video.shortUUID}" />`)
a1eda903
C
203 }
204
205 async function watchPlaylistPageTest (path: string) {
c0e8b12e 206 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
a1eda903
C
207 const text = res.text
208
209 expect(text).to.contain(`<meta property="og:title" content="${playlistName}" />`)
210 expect(text).to.contain(`<meta property="og:description" content="${playlistDescription}" />`)
211 expect(text).to.contain('<meta property="og:type" content="video" />')
a892c54a 212 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/p/${playlist.shortUUID}" />`)
a1eda903
C
213 }
214
012580d9 215 it('Should have valid Open Graph tags on the account page', async function () {
89d241a7
C
216 await accountPageTest('/accounts/' + servers[0].store.user.username)
217 await accountPageTest('/a/' + servers[0].store.user.username)
218 await accountPageTest('/@' + servers[0].store.user.username)
6fad8e51 219 })
d8755eed 220
6fad8e51 221 it('Should have valid Open Graph tags on the channel page', async function () {
89d241a7
C
222 await channelPageTest('/video-channels/' + servers[0].store.channel.name)
223 await channelPageTest('/c/' + servers[0].store.channel.name)
224 await channelPageTest('/@' + servers[0].store.channel.name)
6fad8e51 225 })
d8755eed 226
a1eda903 227 it('Should have valid Open Graph tags on the watch page', async function () {
d4a8e7a6
C
228 for (const path of watchVideoBasePaths) {
229 for (const id of videoIds) {
230 await watchVideoPageTest(path + id)
231 }
232 }
6fad8e51 233 })
8d987ec6 234
6fad8e51 235 it('Should have valid Open Graph tags on the watch playlist page', async function () {
d4a8e7a6
C
236 for (const path of watchPlaylistBasePaths) {
237 for (const id of playlistIds) {
238 await watchPlaylistPageTest(path + id)
239 }
240 }
6fad8e51 241 })
8d987ec6
K
242 })
243
6fad8e51 244 describe('Twitter card', async function () {
8d987ec6 245
012580d9 246 describe('Not whitelisted', function () {
8d987ec6 247
012580d9 248 async function accountPageTest (path: string) {
c0e8b12e 249 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
012580d9 250 const text = res.text
8d987ec6 251
012580d9
C
252 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
253 expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
254 expect(text).to.contain(`<meta property="twitter:title" content="${account.name}" />`)
255 expect(text).to.contain(`<meta property="twitter:description" content="${account.description}" />`)
256 }
8be1afa1 257
012580d9 258 async function channelPageTest (path: string) {
c0e8b12e 259 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
012580d9 260 const text = res.text
8be1afa1 261
012580d9
C
262 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
263 expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
89d241a7 264 expect(text).to.contain(`<meta property="twitter:title" content="${servers[0].store.channel.displayName}" />`)
012580d9 265 expect(text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`)
9a911038
K
266 }
267
a1eda903 268 async function watchVideoPageTest (path: string) {
c0e8b12e 269 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
a1eda903 270 const text = res.text
8be1afa1 271
a1eda903
C
272 expect(text).to.contain('<meta property="twitter:card" content="summary_large_image" />')
273 expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
274 expect(text).to.contain(`<meta property="twitter:title" content="${videoName}" />`)
275 expect(text).to.contain(`<meta property="twitter:description" content="${videoDescriptionPlainText}" />`)
276 }
277
278 async function watchPlaylistPageTest (path: string) {
c0e8b12e 279 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
a1eda903
C
280 const text = res.text
281
282 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
283 expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
284 expect(text).to.contain(`<meta property="twitter:title" content="${playlistName}" />`)
285 expect(text).to.contain(`<meta property="twitter:description" content="${playlistDescription}" />`)
286 }
287
288 it('Should have valid twitter card on the watch video page', async function () {
d4a8e7a6
C
289 for (const path of watchVideoBasePaths) {
290 for (const id of videoIds) {
291 await watchVideoPageTest(path + id)
292 }
293 }
012580d9 294 })
9a911038 295
012580d9 296 it('Should have valid twitter card on the watch playlist page', async function () {
d4a8e7a6
C
297 for (const path of watchPlaylistBasePaths) {
298 for (const id of playlistIds) {
299 await watchPlaylistPageTest(path + id)
300 }
301 }
012580d9
C
302 })
303
304 it('Should have valid twitter card on the account page', async function () {
305 await accountPageTest('/accounts/' + account.name)
306 await accountPageTest('/a/' + account.name)
307 await accountPageTest('/@' + account.name)
308 })
309
310 it('Should have valid twitter card on the channel page', async function () {
89d241a7
C
311 await channelPageTest('/video-channels/' + servers[0].store.channel.name)
312 await channelPageTest('/c/' + servers[0].store.channel.name)
313 await channelPageTest('/@' + servers[0].store.channel.name)
012580d9 314 })
6fad8e51 315 })
8d987ec6 316
012580d9 317 describe('Whitelisted', function () {
8d987ec6 318
012580d9 319 before(async function () {
89d241a7 320 const config = await servers[0].config.getCustomConfig()
012580d9
C
321 config.services.twitter = {
322 username: '@Kuja',
323 whitelisted: true
324 }
8d987ec6 325
89d241a7 326 await servers[0].config.updateCustomConfig({ newCustomConfig: config })
012580d9 327 })
8d987ec6 328
012580d9 329 async function accountPageTest (path: string) {
c0e8b12e 330 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
012580d9 331 const text = res.text
8be1afa1 332
012580d9
C
333 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
334 expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
9a911038
K
335 }
336
012580d9 337 async function channelPageTest (path: string) {
c0e8b12e 338 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
012580d9 339 const text = res.text
9a911038 340
012580d9
C
341 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
342 expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
343 }
9a911038 344
a1eda903 345 async function watchVideoPageTest (path: string) {
c0e8b12e 346 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
a1eda903 347 const text = res.text
6fad8e51 348
a1eda903
C
349 expect(text).to.contain('<meta property="twitter:card" content="player" />')
350 expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
351 }
352
353 async function watchPlaylistPageTest (path: string) {
c0e8b12e 354 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
a1eda903
C
355 const text = res.text
356
357 expect(text).to.contain('<meta property="twitter:card" content="player" />')
358 expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
359 }
360
361 it('Should have valid twitter card on the watch video page', async function () {
d4a8e7a6
C
362 for (const path of watchVideoBasePaths) {
363 for (const id of videoIds) {
364 await watchVideoPageTest(path + id)
365 }
366 }
012580d9 367 })
9a911038 368
012580d9 369 it('Should have valid twitter card on the watch playlist page', async function () {
d4a8e7a6
C
370 for (const path of watchPlaylistBasePaths) {
371 for (const id of playlistIds) {
372 await watchPlaylistPageTest(path + id)
373 }
374 }
012580d9
C
375 })
376
377 it('Should have valid twitter card on the account page', async function () {
378 await accountPageTest('/accounts/' + account.name)
379 await accountPageTest('/a/' + account.name)
380 await accountPageTest('/@' + account.name)
381 })
382
383 it('Should have valid twitter card on the channel page', async function () {
89d241a7
C
384 await channelPageTest('/video-channels/' + servers[0].store.channel.name)
385 await channelPageTest('/c/' + servers[0].store.channel.name)
386 await channelPageTest('/@' + servers[0].store.channel.name)
012580d9 387 })
6fad8e51 388 })
5bcfd029
C
389 })
390
6fad8e51
C
391 describe('Index HTML', function () {
392
393 it('Should have valid index html tags (title, description...)', async function () {
89d241a7 394 const config = await servers[0].config.getConfig()
a59f210f 395 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
6fad8e51
C
396
397 const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'
65e6e260 398 checkIndexTags(res.text, 'PeerTube', description, '', config)
590fb506 399 })
5bcfd029 400
6fad8e51 401 it('Should update the customized configuration and have the correct index html tags', async function () {
89d241a7 402 await servers[0].config.updateCustomSubConfig({
65e6e260
C
403 newConfig: {
404 instance: {
405 name: 'PeerTube updated',
406 shortDescription: 'my short description',
407 description: 'my super description',
408 terms: 'my super terms',
409 defaultNSFWPolicy: 'blur',
410 defaultClientRoute: '/videos/recently-added',
411 customizations: {
412 javascript: 'alert("coucou")',
413 css: 'body { background-color: red; }'
414 }
6fad8e51
C
415 }
416 }
417 })
5bcfd029 418
89d241a7 419 const config = await servers[0].config.getConfig()
a59f210f 420 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
6fad8e51 421
65e6e260 422 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
6fad8e51 423 })
5bcfd029 424
6fad8e51 425 it('Should have valid index html updated tags (title, description...)', async function () {
89d241a7 426 const config = await servers[0].config.getConfig()
a59f210f 427 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
5bcfd029 428
65e6e260 429 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
6fad8e51 430 })
e5024f51
TC
431
432 it('Should use the original video URL for the canonical tag', async function () {
a1eda903 433 for (const basePath of watchVideoBasePaths) {
d4a8e7a6
C
434 for (const id of videoIds) {
435 const res = await makeHTMLRequest(servers[1].url, basePath + id)
89d241a7 436 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/videos/watch/${servers[0].store.video.uuid}" />`)
d4a8e7a6 437 }
a1eda903 438 }
a59f210f
C
439 })
440
441 it('Should use the original account URL for the canonical tag', async function () {
65e6e260 442 const accountURLtest = res => {
9a911038
K
443 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/accounts/root" />`)
444 }
445
446 accountURLtest(await makeHTMLRequest(servers[1].url, '/accounts/root@' + servers[0].host))
447 accountURLtest(await makeHTMLRequest(servers[1].url, '/a/root@' + servers[0].host))
448 accountURLtest(await makeHTMLRequest(servers[1].url, '/@root@' + servers[0].host))
a59f210f
C
449 })
450
451 it('Should use the original channel URL for the canonical tag', async function () {
65e6e260 452 const channelURLtests = res => {
9a911038
K
453 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-channels/root_channel" />`)
454 }
455
456 channelURLtests(await makeHTMLRequest(servers[1].url, '/video-channels/root_channel@' + servers[0].host))
457 channelURLtests(await makeHTMLRequest(servers[1].url, '/c/root_channel@' + servers[0].host))
458 channelURLtests(await makeHTMLRequest(servers[1].url, '/@root_channel@' + servers[0].host))
a59f210f
C
459 })
460
461 it('Should use the original playlist URL for the canonical tag', async function () {
a1eda903 462 for (const basePath of watchPlaylistBasePaths) {
d4a8e7a6
C
463 for (const id of playlistIds) {
464 const res = await makeHTMLRequest(servers[1].url, basePath + id)
465 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-playlists/${playlist.uuid}" />`)
466 }
a1eda903 467 }
e5024f51 468 })
352819ef
C
469
470 it('Should add noindex meta tag for remote accounts', async function () {
471 const handle = 'root@' + servers[0].host
472 const paths = [ '/accounts/', '/a/', '/@' ]
473
474 for (const path of paths) {
475 {
476 const { text } = await makeHTMLRequest(servers[1].url, path + handle)
477 expect(text).to.contain('<meta name="robots" content="noindex" />')
478 }
479
480 {
481 const { text } = await makeHTMLRequest(servers[0].url, path + handle)
482 expect(text).to.not.contain('<meta name="robots" content="noindex" />')
483 }
484 }
485 })
486
c6d20c84
C
487 it('Should add noindex meta tag for remote channels', async function () {
488 const handle = 'root_channel@' + servers[0].host
489 const paths = [ '/video-channels/', '/c/', '/@' ]
490
491 for (const path of paths) {
492 {
493 const { text } = await makeHTMLRequest(servers[1].url, path + handle)
494 expect(text).to.contain('<meta name="robots" content="noindex" />')
495 }
496
497 {
498 const { text } = await makeHTMLRequest(servers[0].url, path + handle)
499 expect(text).to.not.contain('<meta name="robots" content="noindex" />')
500 }
501 }
502 })
503
504 it('Should not display internal/private video', async function () {
505 for (const basePath of watchVideoBasePaths) {
506 for (const id of [ privateVideoId, internalVideoId ]) {
507 const res = await makeGetRequest({
508 url: servers[0].url,
509 path: basePath + id,
510 accept: 'text/html',
511 expectedStatus: HttpStatusCode.NOT_FOUND_404
512 })
513
514 expect(res.text).to.not.contain('internal')
515 expect(res.text).to.not.contain('private')
516 }
517 }
518 })
519
520 it('Should add noindex meta tag for unlisted video', async function () {
521 for (const basePath of watchVideoBasePaths) {
522 const res = await makeGetRequest({
523 url: servers[0].url,
524 path: basePath + unlistedVideoId,
525 accept: 'text/html',
526 expectedStatus: HttpStatusCode.OK_200
527 })
528
529 expect(res.text).to.contain('unlisted')
530 expect(res.text).to.contain('<meta name="robots" content="noindex" />')
531 }
532 })
5bcfd029
C
533 })
534
aea0b0e7
C
535 describe('Embed HTML', function () {
536
537 it('Should have the correct embed html tags', async function () {
89d241a7
C
538 const config = await servers[0].config.getConfig()
539 const res = await makeHTMLRequest(servers[0].url, servers[0].store.video.embedPath)
aea0b0e7 540
65e6e260 541 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
aea0b0e7
C
542 })
543 })
544
7c3b7976 545 after(async function () {
a59f210f 546 await cleanupTests(servers)
0e1dc3e7
C
547 })
548})