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