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