aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-05 15:35:58 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-08-07 08:58:29 +0200
commit6fad8e51c47b9d07bea99b777c1f55c10f6d576d (patch)
tree09b33652d565a6dbe70e413b88c64aa611f7f4b6
parenta75292db788d400ba84933693f5f98a83f3aaa60 (diff)
downloadPeerTube-6fad8e51c47b9d07bea99b777c1f55c10f6d576d.tar.gz
PeerTube-6fad8e51c47b9d07bea99b777c1f55c10f6d576d.tar.zst
PeerTube-6fad8e51c47b9d07bea99b777c1f55c10f6d576d.zip
Handle playlist oembed
-rw-r--r--client/src/standalone/videos/embed.ts4
-rw-r--r--server/controllers/services.ts73
-rw-r--r--server/lib/client-html.ts56
-rw-r--r--server/middlewares/validators/oembed.ts65
-rw-r--r--server/models/video/video-playlist.ts4
-rw-r--r--server/tests/api/check-params/services.ts46
-rw-r--r--server/tests/api/videos/services.ts75
-rw-r--r--server/tests/client.ts342
8 files changed, 452 insertions, 213 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index a7fb087b1..8d1720f75 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -438,7 +438,7 @@ export class PeerTubeEmbed {
438 return videoInfo 438 return videoInfo
439 }) 439 })
440 440
441 const [ videoInfo, serverTranslations, captionsResponse, config, PeertubePlayerManagerModule ] = await Promise.all([ 441 const [ videoInfoTmp, serverTranslations, captionsResponse, config, PeertubePlayerManagerModule ] = await Promise.all([
442 videoInfoPromise, 442 videoInfoPromise,
443 this.translationsPromise, 443 this.translationsPromise,
444 captionsPromise, 444 captionsPromise,
@@ -446,6 +446,8 @@ export class PeerTubeEmbed {
446 this.PeertubePlayerManagerModulePromise 446 this.PeertubePlayerManagerModulePromise
447 ]) 447 ])
448 448
449 const videoInfo: VideoDetails = videoInfoTmp
450
449 const PeertubePlayerManager = PeertubePlayerManagerModule.PeertubePlayerManager 451 const PeertubePlayerManager = PeertubePlayerManagerModule.PeertubePlayerManager
450 const videoCaptions = await this.buildCaptions(serverTranslations, captionsResponse) 452 const videoCaptions = await this.buildCaptions(serverTranslations, captionsResponse)
451 453
diff --git a/server/controllers/services.ts b/server/controllers/services.ts
index ec057235f..d0217c30a 100644
--- a/server/controllers/services.ts
+++ b/server/controllers/services.ts
@@ -1,7 +1,8 @@
1import * as express from 'express' 1import * as express from 'express'
2import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER } from '../initializers/constants' 2import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER, THUMBNAILS_SIZE } from '../initializers/constants'
3import { asyncMiddleware, oembedValidator } from '../middlewares' 3import { asyncMiddleware, oembedValidator } from '../middlewares'
4import { accountNameWithHostGetValidator } from '../middlewares/validators' 4import { accountNameWithHostGetValidator } from '../middlewares/validators'
5import { MChannelSummary } from '@server/types/models'
5 6
6const servicesRouter = express.Router() 7const servicesRouter = express.Router()
7 8
@@ -23,23 +24,73 @@ export {
23// --------------------------------------------------------------------------- 24// ---------------------------------------------------------------------------
24 25
25function generateOEmbed (req: express.Request, res: express.Response) { 26function generateOEmbed (req: express.Request, res: express.Response) {
27 if (res.locals.videoAll) return generateVideoOEmbed(req, res)
28
29 return generatePlaylistOEmbed(req, res)
30}
31
32function generatePlaylistOEmbed (req: express.Request, res: express.Response) {
33 const playlist = res.locals.videoPlaylistSummary
34
35 const json = buildOEmbed({
36 channel: playlist.VideoChannel,
37 title: playlist.name,
38 embedPath: playlist.getEmbedStaticPath(),
39 previewPath: playlist.getThumbnailStaticPath(),
40 previewSize: THUMBNAILS_SIZE,
41 req
42 })
43
44 return res.json(json)
45}
46
47function generateVideoOEmbed (req: express.Request, res: express.Response) {
26 const video = res.locals.videoAll 48 const video = res.locals.videoAll
49
50 const json = buildOEmbed({
51 channel: video.VideoChannel,
52 title: video.name,
53 embedPath: video.getEmbedStaticPath(),
54 previewPath: video.getPreviewStaticPath(),
55 previewSize: PREVIEWS_SIZE,
56 req
57 })
58
59 return res.json(json)
60}
61
62function buildOEmbed (options: {
63 req: express.Request
64 title: string
65 channel: MChannelSummary
66 previewPath: string | null
67 embedPath: string
68 previewSize: {
69 height: number
70 width: number
71 }
72}) {
73 const { req, previewSize, previewPath, title, channel, embedPath } = options
74
27 const webserverUrl = WEBSERVER.URL 75 const webserverUrl = WEBSERVER.URL
28 const maxHeight = parseInt(req.query.maxheight, 10) 76 const maxHeight = parseInt(req.query.maxheight, 10)
29 const maxWidth = parseInt(req.query.maxwidth, 10) 77 const maxWidth = parseInt(req.query.maxwidth, 10)
30 78
31 const embedUrl = webserverUrl + video.getEmbedStaticPath() 79 const embedUrl = webserverUrl + embedPath
32 let thumbnailUrl = webserverUrl + video.getPreviewStaticPath()
33 let embedWidth = EMBED_SIZE.width 80 let embedWidth = EMBED_SIZE.width
34 let embedHeight = EMBED_SIZE.height 81 let embedHeight = EMBED_SIZE.height
35 82
83 let thumbnailUrl = previewPath
84 ? webserverUrl + previewPath
85 : undefined
86
36 if (maxHeight < embedHeight) embedHeight = maxHeight 87 if (maxHeight < embedHeight) embedHeight = maxHeight
37 if (maxWidth < embedWidth) embedWidth = maxWidth 88 if (maxWidth < embedWidth) embedWidth = maxWidth
38 89
39 // Our thumbnail is too big for the consumer 90 // Our thumbnail is too big for the consumer
40 if ( 91 if (
41 (maxHeight !== undefined && maxHeight < PREVIEWS_SIZE.height) || 92 (maxHeight !== undefined && maxHeight < previewSize.height) ||
42 (maxWidth !== undefined && maxWidth < PREVIEWS_SIZE.width) 93 (maxWidth !== undefined && maxWidth < previewSize.width)
43 ) { 94 ) {
44 thumbnailUrl = undefined 95 thumbnailUrl = undefined
45 } 96 }
@@ -53,20 +104,20 @@ function generateOEmbed (req: express.Request, res: express.Response) {
53 html, 104 html,
54 width: embedWidth, 105 width: embedWidth,
55 height: embedHeight, 106 height: embedHeight,
56 title: video.name, 107 title: title,
57 author_name: video.VideoChannel.Account.name, 108 author_name: channel.name,
58 author_url: video.VideoChannel.Account.Actor.url, 109 author_url: channel.Actor.url,
59 provider_name: 'PeerTube', 110 provider_name: 'PeerTube',
60 provider_url: webserverUrl 111 provider_url: webserverUrl
61 } 112 }
62 113
63 if (thumbnailUrl !== undefined) { 114 if (thumbnailUrl !== undefined) {
64 json.thumbnail_url = thumbnailUrl 115 json.thumbnail_url = thumbnailUrl
65 json.thumbnail_width = PREVIEWS_SIZE.width 116 json.thumbnail_width = previewSize.width
66 json.thumbnail_height = PREVIEWS_SIZE.height 117 json.thumbnail_height = previewSize.height
67 } 118 }
68 119
69 return res.json(json) 120 return json
70} 121}
71 122
72function redirectToAccountUrl (req: express.Request, res: express.Response, next: express.NextFunction) { 123function redirectToAccountUrl (req: express.Request, res: express.Response, next: express.NextFunction) {
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index d8ae73b5d..85fced10d 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -23,6 +23,33 @@ import { CONFIG } from '../initializers/config'
23import { logger } from '../helpers/logger' 23import { logger } from '../helpers/logger'
24import { MAccountActor, MChannelActor } from '../types/models' 24import { MAccountActor, MChannelActor } from '../types/models'
25 25
26type Tags = {
27 ogType: string
28 twitterCard: string
29 schemaType: string
30
31 list?: {
32 numberOfItems: number
33 }
34
35 title: string
36 url: string
37 description: string
38
39 embed?: {
40 url: string
41 createdAt: string
42 duration?: string
43 views?: number
44 }
45
46 image: {
47 url: string
48 width?: number
49 height?: number
50 }
51}
52
26export class ClientHtml { 53export class ClientHtml {
27 54
28 private static htmlCache: { [path: string]: string } = {} 55 private static htmlCache: { [path: string]: string } = {}
@@ -118,15 +145,20 @@ export class ClientHtml {
118 url: videoPlaylist.getThumbnailUrl() 145 url: videoPlaylist.getThumbnailUrl()
119 } 146 }
120 147
148 const embed = {
149 url: WEBSERVER.URL + videoPlaylist.getEmbedStaticPath(),
150 createdAt: videoPlaylist.createdAt.toISOString()
151 }
152
121 const list = { 153 const list = {
122 numberOfItems: videoPlaylist.get('videosLength') 154 numberOfItems: videoPlaylist.get('videosLength') as number
123 } 155 }
124 156
125 const ogType = 'video' 157 const ogType = 'video'
126 const twitterCard = 'summary' 158 const twitterCard = CONFIG.SERVICES.TWITTER.WHITELISTED ? 'player' : 'summary'
127 const schemaType = 'ItemList' 159 const schemaType = 'ItemList'
128 160
129 customHtml = ClientHtml.addTags(customHtml, { url, title, description, image, list, ogType, twitterCard, schemaType }) 161 customHtml = ClientHtml.addTags(customHtml, { url, embed, title, description, image, list, ogType, twitterCard, schemaType })
130 162
131 return customHtml 163 return customHtml
132 } 164 }
@@ -268,7 +300,7 @@ export class ClientHtml {
268 return htmlStringPage.replace('</head>', linkTag + '</head>') 300 return htmlStringPage.replace('</head>', linkTag + '</head>')
269 } 301 }
270 302
271 private static generateOpenGraphMetaTags (tags) { 303 private static generateOpenGraphMetaTags (tags: Tags) {
272 const metaTags = { 304 const metaTags = {
273 'og:type': tags.ogType, 305 'og:type': tags.ogType,
274 'og:title': tags.title, 306 'og:title': tags.title,
@@ -294,7 +326,7 @@ export class ClientHtml {
294 return metaTags 326 return metaTags
295 } 327 }
296 328
297 private static generateStandardMetaTags (tags) { 329 private static generateStandardMetaTags (tags: Tags) {
298 return { 330 return {
299 name: tags.title, 331 name: tags.title,
300 description: tags.description, 332 description: tags.description,
@@ -302,7 +334,7 @@ export class ClientHtml {
302 } 334 }
303 } 335 }
304 336
305 private static generateTwitterCardMetaTags (tags) { 337 private static generateTwitterCardMetaTags (tags: Tags) {
306 const metaTags = { 338 const metaTags = {
307 'twitter:card': tags.twitterCard, 339 'twitter:card': tags.twitterCard,
308 'twitter:site': CONFIG.SERVICES.TWITTER.USERNAME, 340 'twitter:site': CONFIG.SERVICES.TWITTER.USERNAME,
@@ -319,7 +351,7 @@ export class ClientHtml {
319 return metaTags 351 return metaTags
320 } 352 }
321 353
322 private static generateSchemaTags (tags) { 354 private static generateSchemaTags (tags: Tags) {
323 const schema = { 355 const schema = {
324 '@context': 'http://schema.org', 356 '@context': 'http://schema.org',
325 '@type': tags.schemaType, 357 '@type': tags.schemaType,
@@ -337,8 +369,10 @@ export class ClientHtml {
337 if (tags.embed) { 369 if (tags.embed) {
338 schema['embedUrl'] = tags.embed.url 370 schema['embedUrl'] = tags.embed.url
339 schema['uploadDate'] = tags.embed.createdAt 371 schema['uploadDate'] = tags.embed.createdAt
340 schema['duration'] = tags.embed.duration 372
341 schema['iterationCount'] = tags.embed.views 373 if (tags.embed.duration) schema['duration'] = tags.embed.duration
374 if (tags.embed.views) schema['iterationCount'] = tags.embed.views
375
342 schema['thumbnailUrl'] = tags.image.url 376 schema['thumbnailUrl'] = tags.image.url
343 schema['contentUrl'] = tags.url 377 schema['contentUrl'] = tags.url
344 } 378 }
@@ -346,7 +380,7 @@ export class ClientHtml {
346 return schema 380 return schema
347 } 381 }
348 382
349 private static addTags (htmlStringPage: string, tagsValues: any) { 383 private static addTags (htmlStringPage: string, tagsValues: Tags) {
350 const openGraphMetaTags = this.generateOpenGraphMetaTags(tagsValues) 384 const openGraphMetaTags = this.generateOpenGraphMetaTags(tagsValues)
351 const standardMetaTags = this.generateStandardMetaTags(tagsValues) 385 const standardMetaTags = this.generateStandardMetaTags(tagsValues)
352 const twitterCardMetaTags = this.generateTwitterCardMetaTags(tagsValues) 386 const twitterCardMetaTags = this.generateTwitterCardMetaTags(tagsValues)
@@ -354,7 +388,7 @@ export class ClientHtml {
354 388
355 const { url, title, embed } = tagsValues 389 const { url, title, embed } = tagsValues
356 390
357 const oembedLinkTags = [] 391 const oembedLinkTags: { type: string, href: string, title: string }[] = []
358 392
359 if (embed) { 393 if (embed) {
360 oembedLinkTags.push({ 394 oembedLinkTags.push({
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts
index ab4dbb4d1..c9f9ea0c0 100644
--- a/server/middlewares/validators/oembed.ts
+++ b/server/middlewares/validators/oembed.ts
@@ -1,15 +1,19 @@
1import * as express from 'express' 1import * as express from 'express'
2import { query } from 'express-validator' 2import { query } from 'express-validator'
3import { join } from 'path' 3import { join } from 'path'
4import { fetchVideo } from '@server/helpers/video'
5import { VideoPlaylistModel } from '@server/models/video/video-playlist'
6import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
4import { isTestInstance } from '../../helpers/core-utils' 7import { isTestInstance } from '../../helpers/core-utils'
5import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' 8import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
6import { logger } from '../../helpers/logger' 9import { logger } from '../../helpers/logger'
7import { areValidationErrors } from './utils'
8import { WEBSERVER } from '../../initializers/constants' 10import { WEBSERVER } from '../../initializers/constants'
9import { doesVideoExist } from '../../helpers/middlewares' 11import { areValidationErrors } from './utils'
10 12
11const urlShouldStartWith = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch') + '/' 13const startVideoPlaylistsURL = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch', 'playlist') + '/'
12const videoWatchRegex = new RegExp('([^/]+)$') 14const startVideosURL = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch') + '/'
15
16const watchRegex = new RegExp('([^/]+)$')
13const isURLOptions = { 17const isURLOptions = {
14 require_host: true, 18 require_host: true,
15 require_tld: true 19 require_tld: true
@@ -33,32 +37,63 @@ const oembedValidator = [
33 37
34 if (req.query.format !== undefined && req.query.format !== 'json') { 38 if (req.query.format !== undefined && req.query.format !== 'json') {
35 return res.status(501) 39 return res.status(501)
36 .json({ error: 'Requested format is not implemented on server.' }) 40 .json({ error: 'Requested format is not implemented on server.' })
37 .end()
38 } 41 }
39 42
40 const url = req.query.url as string 43 const url = req.query.url as string
41 44
42 const startIsOk = url.startsWith(urlShouldStartWith) 45 const isPlaylist = url.startsWith(startVideoPlaylistsURL)
43 const matches = videoWatchRegex.exec(url) 46 const isVideo = isPlaylist ? false : url.startsWith(startVideosURL)
47
48 const startIsOk = isVideo || isPlaylist
49
50 const matches = watchRegex.exec(url)
44 51
45 if (startIsOk === false || matches === null) { 52 if (startIsOk === false || matches === null) {
46 return res.status(400) 53 return res.status(400)
47 .json({ error: 'Invalid url.' }) 54 .json({ error: 'Invalid url.' })
48 .end()
49 } 55 }
50 56
51 const videoId = matches[1] 57 const elementId = matches[1]
52 if (isIdOrUUIDValid(videoId) === false) { 58 if (isIdOrUUIDValid(elementId) === false) {
53 return res.status(400) 59 return res.status(400)
54 .json({ error: 'Invalid video id.' }) 60 .json({ error: 'Invalid video or playlist id.' })
55 .end()
56 } 61 }
57 62
58 if (!await doesVideoExist(videoId, res)) return 63 if (isVideo) {
64 const video = await fetchVideo(elementId, 'all')
65
66 if (!video) {
67 return res.status(404)
68 .json({ error: 'Video not found' })
69 }
59 70
71 if (video.privacy !== VideoPrivacy.PUBLIC) {
72 return res.status(403)
73 .json({ error: 'Video is not public' })
74 }
75
76 res.locals.videoAll = video
77 return next()
78 }
79
80 // Is playlist
81
82 const videoPlaylist = await VideoPlaylistModel.loadWithAccountAndChannelSummary(elementId, undefined)
83 if (!videoPlaylist) {
84 return res.status(404)
85 .json({ error: 'Video playlist not found' })
86 }
87
88 if (videoPlaylist.privacy !== VideoPlaylistPrivacy.PUBLIC) {
89 return res.status(403)
90 .json({ error: 'Playlist is not public' })
91 }
92
93 res.locals.videoPlaylistSummary = videoPlaylist
60 return next() 94 return next()
61 } 95 }
96
62] 97]
63 98
64// --------------------------------------------------------------------------- 99// ---------------------------------------------------------------------------
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts
index b38cf9c6a..f935bf4f0 100644
--- a/server/models/video/video-playlist.ts
+++ b/server/models/video/video-playlist.ts
@@ -494,6 +494,10 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
494 return WEBSERVER.URL + '/videos/watch/playlist/' + this.uuid 494 return WEBSERVER.URL + '/videos/watch/playlist/' + this.uuid
495 } 495 }
496 496
497 getEmbedStaticPath () {
498 return '/video-playlists/embed/' + this.uuid
499 }
500
497 setAsRefreshed () { 501 setAsRefreshed () {
498 this.changed('updatedAt', true) 502 this.changed('updatedAt', true)
499 503
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index 457adfaab..e57edd9e4 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -8,11 +8,15 @@ import {
8 makeGetRequest, 8 makeGetRequest,
9 ServerInfo, 9 ServerInfo,
10 setAccessTokensToServers, 10 setAccessTokensToServers,
11 uploadVideo 11 uploadVideo,
12 createVideoPlaylist,
13 setDefaultVideoChannel
12} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
15import { VideoPlaylistPrivacy } from '@shared/models'
13 16
14describe('Test services API validators', function () { 17describe('Test services API validators', function () {
15 let server: ServerInfo 18 let server: ServerInfo
19 let playlistUUID: string
16 20
17 // --------------------------------------------------------------- 21 // ---------------------------------------------------------------
18 22
@@ -21,9 +25,26 @@ describe('Test services API validators', function () {
21 25
22 server = await flushAndRunServer(1) 26 server = await flushAndRunServer(1)
23 await setAccessTokensToServers([ server ]) 27 await setAccessTokensToServers([ server ])
24 28 await setDefaultVideoChannel([ server ])
25 const res = await uploadVideo(server.url, server.accessToken, { name: 'my super name' }) 29
26 server.video = res.body.video 30 {
31 const res = await uploadVideo(server.url, server.accessToken, { name: 'my super name' })
32 server.video = res.body.video
33 }
34
35 {
36 const res = await createVideoPlaylist({
37 url: server.url,
38 token: server.accessToken,
39 playlistAttrs: {
40 displayName: 'super playlist',
41 privacy: VideoPlaylistPrivacy.PUBLIC,
42 videoChannelId: server.videoChannel.id
43 }
44 })
45
46 playlistUUID = res.body.videoPlaylist.uuid
47 }
27 }) 48 })
28 49
29 describe('Test oEmbed API validators', function () { 50 describe('Test oEmbed API validators', function () {
@@ -38,12 +59,12 @@ describe('Test services API validators', function () {
38 await checkParamEmbed(server, embedUrl) 59 await checkParamEmbed(server, embedUrl)
39 }) 60 })
40 61
41 it('Should fail with an invalid video id', async function () { 62 it('Should fail with an invalid element id', async function () {
42 const embedUrl = `http://localhost:${server.port}/videos/watch/blabla` 63 const embedUrl = `http://localhost:${server.port}/videos/watch/blabla`
43 await checkParamEmbed(server, embedUrl) 64 await checkParamEmbed(server, embedUrl)
44 }) 65 })
45 66
46 it('Should fail with an unknown video', async function () { 67 it('Should fail with an unknown element', async function () {
47 const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c` 68 const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c`
48 await checkParamEmbed(server, embedUrl, 404) 69 await checkParamEmbed(server, embedUrl, 404)
49 }) 70 })
@@ -78,7 +99,7 @@ describe('Test services API validators', function () {
78 await checkParamEmbed(server, embedUrl, 501, { format: 'xml' }) 99 await checkParamEmbed(server, embedUrl, 501, { format: 'xml' })
79 }) 100 })
80 101
81 it('Should succeed with the correct params', async function () { 102 it('Should succeed with the correct params with a video', async function () {
82 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 103 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
83 const query = { 104 const query = {
84 format: 'json', 105 format: 'json',
@@ -88,6 +109,17 @@ describe('Test services API validators', function () {
88 109
89 await checkParamEmbed(server, embedUrl, 200, query) 110 await checkParamEmbed(server, embedUrl, 200, query)
90 }) 111 })
112
113 it('Should succeed with the correct params with a playlist', async function () {
114 const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${playlistUUID}`
115 const query = {
116 format: 'json',
117 maxheight: 400,
118 maxwidth: 400
119 }
120
121 await checkParamEmbed(server, embedUrl, 200, query)
122 })
91 }) 123 })
92 124
93 after(async function () { 125 after(async function () {
diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts
index 5505a845a..897f37c04 100644
--- a/server/tests/api/videos/services.ts
+++ b/server/tests/api/videos/services.ts
@@ -1,14 +1,25 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
5import { getOEmbed, getVideosList, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils/index' 4import * as chai from 'chai'
5import {
6 getOEmbed,
7 getVideosList,
8 ServerInfo,
9 setAccessTokensToServers,
10 setDefaultVideoChannel,
11 uploadVideo,
12 createVideoPlaylist,
13 addVideoInPlaylist
14} from '../../../../shared/extra-utils'
6import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers' 15import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
16import { VideoPlaylistPrivacy } from '@shared/models'
7 17
8const expect = chai.expect 18const expect = chai.expect
9 19
10describe('Test services', function () { 20describe('Test services', function () {
11 let server: ServerInfo = null 21 let server: ServerInfo = null
22 let playlistUUID: string
12 23
13 before(async function () { 24 before(async function () {
14 this.timeout(30000) 25 this.timeout(30000)
@@ -16,17 +27,43 @@ describe('Test services', function () {
16 server = await flushAndRunServer(1) 27 server = await flushAndRunServer(1)
17 28
18 await setAccessTokensToServers([ server ]) 29 await setAccessTokensToServers([ server ])
30 await setDefaultVideoChannel([ server ])
19 31
20 const videoAttributes = { 32 {
21 name: 'my super name' 33 const videoAttributes = {
34 name: 'my super name'
35 }
36 await uploadVideo(server.url, server.accessToken, videoAttributes)
37
38 const res = await getVideosList(server.url)
39 server.video = res.body.data[0]
22 } 40 }
23 await uploadVideo(server.url, server.accessToken, videoAttributes)
24 41
25 const res = await getVideosList(server.url) 42 {
26 server.video = res.body.data[0] 43 const res = await createVideoPlaylist({
44 url: server.url,
45 token: server.accessToken,
46 playlistAttrs: {
47 displayName: 'The Life and Times of Scrooge McDuck',
48 privacy: VideoPlaylistPrivacy.PUBLIC,
49 videoChannelId: server.videoChannel.id
50 }
51 })
52
53 playlistUUID = res.body.videoPlaylist.uuid
54
55 await addVideoInPlaylist({
56 url: server.url,
57 token: server.accessToken,
58 playlistId: res.body.videoPlaylist.id,
59 elementAttrs: {
60 videoId: server.video.id
61 }
62 })
63 }
27 }) 64 })
28 65
29 it('Should have a valid oEmbed response', async function () { 66 it('Should have a valid oEmbed video response', async function () {
30 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid 67 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid
31 68
32 const res = await getOEmbed(server.url, oembedUrl) 69 const res = await getOEmbed(server.url, oembedUrl)
@@ -37,7 +74,7 @@ describe('Test services', function () {
37 74
38 expect(res.body.html).to.equal(expectedHtml) 75 expect(res.body.html).to.equal(expectedHtml)
39 expect(res.body.title).to.equal(server.video.name) 76 expect(res.body.title).to.equal(server.video.name)
40 expect(res.body.author_name).to.equal(server.video.account.name) 77 expect(res.body.author_name).to.equal(server.videoChannel.displayName)
41 expect(res.body.width).to.equal(560) 78 expect(res.body.width).to.equal(560)
42 expect(res.body.height).to.equal(315) 79 expect(res.body.height).to.equal(315)
43 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) 80 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
@@ -45,6 +82,24 @@ describe('Test services', function () {
45 expect(res.body.thumbnail_height).to.equal(480) 82 expect(res.body.thumbnail_height).to.equal(480)
46 }) 83 })
47 84
85 it('Should have a valid playlist oEmbed response', async function () {
86 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/playlist/' + playlistUUID
87
88 const res = await getOEmbed(server.url, oembedUrl)
89 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
90 `src="http://localhost:${server.port}/video-playlists/embed/${playlistUUID}" ` +
91 'frameborder="0" allowfullscreen></iframe>'
92
93 expect(res.body.html).to.equal(expectedHtml)
94 expect(res.body.title).to.equal('The Life and Times of Scrooge McDuck')
95 expect(res.body.author_name).to.equal(server.videoChannel.displayName)
96 expect(res.body.width).to.equal(560)
97 expect(res.body.height).to.equal(315)
98 expect(res.body.thumbnail_url).exist
99 expect(res.body.thumbnail_width).to.equal(223)
100 expect(res.body.thumbnail_height).to.equal(122)
101 })
102
48 it('Should have a valid oEmbed response with small max height query', async function () { 103 it('Should have a valid oEmbed response with small max height query', async function () {
49 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid 104 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid
50 const format = 'json' 105 const format = 'json'
@@ -58,7 +113,7 @@ describe('Test services', function () {
58 113
59 expect(res.body.html).to.equal(expectedHtml) 114 expect(res.body.html).to.equal(expectedHtml)
60 expect(res.body.title).to.equal(server.video.name) 115 expect(res.body.title).to.equal(server.video.name)
61 expect(res.body.author_name).to.equal(server.video.account.name) 116 expect(res.body.author_name).to.equal(server.videoChannel.displayName)
62 expect(res.body.height).to.equal(50) 117 expect(res.body.height).to.equal(50)
63 expect(res.body.width).to.equal(50) 118 expect(res.body.width).to.equal(50)
64 expect(res.body).to.not.have.property('thumbnail_url') 119 expect(res.body).to.not.have.property('thumbnail_url')
diff --git a/server/tests/client.ts b/server/tests/client.ts
index f55859b6f..96821eb6f 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -94,204 +94,230 @@ describe('Test a client controllers', function () {
94 account = resAccountRequest.body 94 account = resAccountRequest.body
95 }) 95 })
96 96
97 it('Should have valid Open Graph tags on the watch page with video id', async function () { 97 describe('oEmbed', function () {
98 const res = await request(server.url) 98 it('Should have valid oEmbed discovery tags for videos', async function () {
99 .get('/videos/watch/' + server.video.id) 99 const path = '/videos/watch/' + server.video.uuid
100 .set('Accept', 'text/html') 100 const res = await request(server.url)
101 .expect(200) 101 .get(path)
102 102 .set('Accept', 'text/html')
103 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`) 103 .expect(200)
104 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescription}" />`)
105 expect(res.text).to.contain('<meta property="og:type" content="video" />')
106 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`)
107 })
108 104
109 it('Should have valid Open Graph tags on the watch page with video uuid', async function () { 105 const port = server.port
110 const res = await request(server.url)
111 .get('/videos/watch/' + server.video.uuid)
112 .set('Accept', 'text/html')
113 .expect(200)
114 106
115 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`) 107 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' +
116 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescription}" />`) 108 `url=http%3A%2F%2Flocalhost%3A${port}%2Fvideos%2Fwatch%2F${server.video.uuid}" ` +
117 expect(res.text).to.contain('<meta property="og:type" content="video" />') 109 `title="${server.video.name}" />`
118 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`)
119 })
120 110
121 it('Should have valid Open Graph tags on the watch playlist page', async function () { 111 expect(res.text).to.contain(expectedLink)
122 const res = await request(server.url) 112 })
123 .get('/videos/watch/playlist/' + playlistUUID)
124 .set('Accept', 'text/html')
125 .expect(200)
126 113
127 expect(res.text).to.contain(`<meta property="og:title" content="${playlistName}" />`) 114 it('Should have valid oEmbed discovery tags for a playlist', async function () {
128 expect(res.text).to.contain(`<meta property="og:description" content="${playlistDescription}" />`) 115 const res = await request(server.url)
129 expect(res.text).to.contain('<meta property="og:type" content="video" />') 116 .get('/videos/watch/playlist/' + playlistUUID)
130 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/playlist/${playlistUUID}" />`) 117 .set('Accept', 'text/html')
131 }) 118 .expect(200)
119
120 const port = server.port
132 121
133 it('Should have valid Open Graph tags on the account page', async function () { 122 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' +
134 const res = await request(server.url) 123 `url=http%3A%2F%2Flocalhost%3A${port}%2Fvideos%2Fwatch%2Fplaylist%2F${playlistUUID}" ` +
135 .get('/accounts/' + server.user.username) 124 `title="${playlistName}" />`
136 .set('Accept', 'text/html')
137 .expect(200)
138 125
139 expect(res.text).to.contain(`<meta property="og:title" content="${account.displayName}" />`) 126 expect(res.text).to.contain(expectedLink)
140 expect(res.text).to.contain(`<meta property="og:description" content="${account.description}" />`) 127 })
141 expect(res.text).to.contain('<meta property="og:type" content="website" />')
142 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/accounts/${server.user.username}" />`)
143 }) 128 })
144 129
145 it('Should have valid Open Graph tags on the channel page', async function () { 130 describe('Open Graph', function () {
146 const res = await request(server.url)
147 .get('/video-channels/' + server.videoChannel.name)
148 .set('Accept', 'text/html')
149 .expect(200)
150 131
151 expect(res.text).to.contain(`<meta property="og:title" content="${server.videoChannel.displayName}" />`) 132 it('Should have valid Open Graph tags on the account page', async function () {
152 expect(res.text).to.contain(`<meta property="og:description" content="${channelDescription}" />`) 133 const res = await request(server.url)
153 expect(res.text).to.contain('<meta property="og:type" content="website" />') 134 .get('/accounts/' + server.user.username)
154 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/video-channels/${server.videoChannel.name}" />`) 135 .set('Accept', 'text/html')
155 }) 136 .expect(200)
156 137
157 it('Should have valid oEmbed discovery tags', async function () { 138 expect(res.text).to.contain(`<meta property="og:title" content="${account.displayName}" />`)
158 const path = '/videos/watch/' + server.video.uuid 139 expect(res.text).to.contain(`<meta property="og:description" content="${account.description}" />`)
159 const res = await request(server.url) 140 expect(res.text).to.contain('<meta property="og:type" content="website" />')
160 .get(path) 141 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/accounts/${server.user.username}" />`)
161 .set('Accept', 'text/html') 142 })
162 .expect(200)
163 143
164 const port = server.port 144 it('Should have valid Open Graph tags on the channel page', async function () {
145 const res = await request(server.url)
146 .get('/video-channels/' + server.videoChannel.name)
147 .set('Accept', 'text/html')
148 .expect(200)
165 149
166 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' + 150 expect(res.text).to.contain(`<meta property="og:title" content="${server.videoChannel.displayName}" />`)
167 `url=http%3A%2F%2Flocalhost%3A${port}%2Fvideos%2Fwatch%2F${server.video.uuid}" ` + 151 expect(res.text).to.contain(`<meta property="og:description" content="${channelDescription}" />`)
168 `title="${server.video.name}" />` 152 expect(res.text).to.contain('<meta property="og:type" content="website" />')
153 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/video-channels/${server.videoChannel.name}" />`)
154 })
169 155
170 expect(res.text).to.contain(expectedLink) 156 it('Should have valid Open Graph tags on the watch page with video id', async function () {
171 }) 157 const res = await request(server.url)
158 .get('/videos/watch/' + server.video.id)
159 .set('Accept', 'text/html')
160 .expect(200)
172 161
173 it('Should have valid twitter card on the watch video page', async function () { 162 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`)
174 const res = await request(server.url) 163 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescription}" />`)
175 .get('/videos/watch/' + server.video.uuid) 164 expect(res.text).to.contain('<meta property="og:type" content="video" />')
176 .set('Accept', 'text/html') 165 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`)
177 .expect(200) 166 })
178 167
179 expect(res.text).to.contain('<meta property="twitter:card" content="summary_large_image" />') 168 it('Should have valid Open Graph tags on the watch page with video uuid', async function () {
180 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 169 const res = await request(server.url)
181 expect(res.text).to.contain(`<meta property="twitter:title" content="${videoName}" />`) 170 .get('/videos/watch/' + server.video.uuid)
182 expect(res.text).to.contain(`<meta property="twitter:description" content="${videoDescription}" />`) 171 .set('Accept', 'text/html')
183 }) 172 .expect(200)
184 173
185 it('Should have valid twitter card on the watch playlist page', async function () { 174 expect(res.text).to.contain(`<meta property="og:title" content="${videoName}" />`)
186 const res = await request(server.url) 175 expect(res.text).to.contain(`<meta property="og:description" content="${videoDescription}" />`)
187 .get('/videos/watch/playlist/' + playlistUUID) 176 expect(res.text).to.contain('<meta property="og:type" content="video" />')
188 .set('Accept', 'text/html') 177 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/${server.video.uuid}" />`)
189 .expect(200) 178 })
190 179
191 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') 180 it('Should have valid Open Graph tags on the watch playlist page', async function () {
192 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 181 const res = await request(server.url)
193 expect(res.text).to.contain(`<meta property="twitter:title" content="${playlistName}" />`) 182 .get('/videos/watch/playlist/' + playlistUUID)
194 expect(res.text).to.contain(`<meta property="twitter:description" content="${playlistDescription}" />`) 183 .set('Accept', 'text/html')
184 .expect(200)
185
186 expect(res.text).to.contain(`<meta property="og:title" content="${playlistName}" />`)
187 expect(res.text).to.contain(`<meta property="og:description" content="${playlistDescription}" />`)
188 expect(res.text).to.contain('<meta property="og:type" content="video" />')
189 expect(res.text).to.contain(`<meta property="og:url" content="${server.url}/videos/watch/playlist/${playlistUUID}" />`)
190 })
195 }) 191 })
196 192
197 it('Should have valid twitter card on the account page', async function () { 193 describe('Twitter card', async function () {
198 const res = await request(server.url)
199 .get('/accounts/' + account.name)
200 .set('Accept', 'text/html')
201 .expect(200)
202 194
203 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') 195 it('Should have valid twitter card on the watch video page', async function () {
204 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 196 const res = await request(server.url)
205 expect(res.text).to.contain(`<meta property="twitter:title" content="${account.name}" />`) 197 .get('/videos/watch/' + server.video.uuid)
206 expect(res.text).to.contain(`<meta property="twitter:description" content="${account.description}" />`) 198 .set('Accept', 'text/html')
207 }) 199 .expect(200)
208 200
209 it('Should have valid twitter card on the channel page', async function () { 201 expect(res.text).to.contain('<meta property="twitter:card" content="summary_large_image" />')
210 const res = await request(server.url) 202 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
211 .get('/video-channels/' + server.videoChannel.name) 203 expect(res.text).to.contain(`<meta property="twitter:title" content="${videoName}" />`)
212 .set('Accept', 'text/html') 204 expect(res.text).to.contain(`<meta property="twitter:description" content="${videoDescription}" />`)
213 .expect(200) 205 })
214 206
215 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />') 207 it('Should have valid twitter card on the watch playlist page', async function () {
216 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 208 const res = await request(server.url)
217 expect(res.text).to.contain(`<meta property="twitter:title" content="${server.videoChannel.displayName}" />`) 209 .get('/videos/watch/playlist/' + playlistUUID)
218 expect(res.text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`) 210 .set('Accept', 'text/html')
219 }) 211 .expect(200)
220 212
221 it('Should have valid twitter card if Twitter is whitelisted', async function () { 213 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
222 const res1 = await getCustomConfig(server.url, server.accessToken) 214 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
223 const config = res1.body 215 expect(res.text).to.contain(`<meta property="twitter:title" content="${playlistName}" />`)
224 config.services.twitter = { 216 expect(res.text).to.contain(`<meta property="twitter:description" content="${playlistDescription}" />`)
225 username: '@Kuja', 217 })
226 whitelisted: true
227 }
228 await updateCustomConfig(server.url, server.accessToken, config)
229 218
230 const resVideoRequest = await request(server.url) 219 it('Should have valid twitter card on the account page', async function () {
231 .get('/videos/watch/' + server.video.uuid) 220 const res = await request(server.url)
232 .set('Accept', 'text/html') 221 .get('/accounts/' + account.name)
233 .expect(200) 222 .set('Accept', 'text/html')
223 .expect(200)
234 224
235 expect(resVideoRequest.text).to.contain('<meta property="twitter:card" content="player" />') 225 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
236 expect(resVideoRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 226 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
227 expect(res.text).to.contain(`<meta property="twitter:title" content="${account.name}" />`)
228 expect(res.text).to.contain(`<meta property="twitter:description" content="${account.description}" />`)
229 })
237 230
238 const resVideoPlaylistRequest = await request(server.url) 231 it('Should have valid twitter card on the channel page', async function () {
239 .get('/videos/watch/playlist/' + playlistUUID) 232 const res = await request(server.url)
240 .set('Accept', 'text/html') 233 .get('/video-channels/' + server.videoChannel.name)
241 .expect(200) 234 .set('Accept', 'text/html')
235 .expect(200)
242 236
243 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:card" content="summary" />') 237 expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
244 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 238 expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
239 expect(res.text).to.contain(`<meta property="twitter:title" content="${server.videoChannel.displayName}" />`)
240 expect(res.text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`)
241 })
245 242
246 const resAccountRequest = await request(server.url) 243 it('Should have valid twitter card if Twitter is whitelisted', async function () {
247 .get('/accounts/' + account.name) 244 const res1 = await getCustomConfig(server.url, server.accessToken)
248 .set('Accept', 'text/html') 245 const config = res1.body
249 .expect(200) 246 config.services.twitter = {
247 username: '@Kuja',
248 whitelisted: true
249 }
250 await updateCustomConfig(server.url, server.accessToken, config)
250 251
251 expect(resAccountRequest.text).to.contain('<meta property="twitter:card" content="summary" />') 252 const resVideoRequest = await request(server.url)
252 expect(resAccountRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 253 .get('/videos/watch/' + server.video.uuid)
254 .set('Accept', 'text/html')
255 .expect(200)
253 256
254 const resChannelRequest = await request(server.url) 257 expect(resVideoRequest.text).to.contain('<meta property="twitter:card" content="player" />')
255 .get('/video-channels/' + server.videoChannel.name) 258 expect(resVideoRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
256 .set('Accept', 'text/html')
257 .expect(200)
258 259
259 expect(resChannelRequest.text).to.contain('<meta property="twitter:card" content="summary" />') 260 const resVideoPlaylistRequest = await request(server.url)
260 expect(resChannelRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />') 261 .get('/videos/watch/playlist/' + playlistUUID)
261 }) 262 .set('Accept', 'text/html')
263 .expect(200)
262 264
263 it('Should have valid index html tags (title, description...)', async function () { 265 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:card" content="player" />')
264 const res = await makeHTMLRequest(server.url, '/videos/trending') 266 expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
265 267
266 const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' 268 const resAccountRequest = await request(server.url)
267 checkIndexTags(res.text, 'PeerTube', description, '') 269 .get('/accounts/' + account.name)
270 .set('Accept', 'text/html')
271 .expect(200)
272
273 expect(resAccountRequest.text).to.contain('<meta property="twitter:card" content="summary" />')
274 expect(resAccountRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
275
276 const resChannelRequest = await request(server.url)
277 .get('/video-channels/' + server.videoChannel.name)
278 .set('Accept', 'text/html')
279 .expect(200)
280
281 expect(resChannelRequest.text).to.contain('<meta property="twitter:card" content="summary" />')
282 expect(resChannelRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
283 })
268 }) 284 })
269 285
270 it('Should update the customized configuration and have the correct index html tags', async function () { 286 describe('Index HTML', function () {
271 await updateCustomSubConfig(server.url, server.accessToken, { 287
272 instance: { 288 it('Should have valid index html tags (title, description...)', async function () {
273 name: 'PeerTube updated', 289 const res = await makeHTMLRequest(server.url, '/videos/trending')
274 shortDescription: 'my short description', 290
275 description: 'my super description', 291 const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'
276 terms: 'my super terms', 292 checkIndexTags(res.text, 'PeerTube', description, '')
277 defaultClientRoute: '/videos/recently-added',
278 defaultNSFWPolicy: 'blur',
279 customizations: {
280 javascript: 'alert("coucou")',
281 css: 'body { background-color: red; }'
282 }
283 }
284 }) 293 })
285 294
286 const res = await makeHTMLRequest(server.url, '/videos/trending') 295 it('Should update the customized configuration and have the correct index html tags', async function () {
296 await updateCustomSubConfig(server.url, server.accessToken, {
297 instance: {
298 name: 'PeerTube updated',
299 shortDescription: 'my short description',
300 description: 'my super description',
301 terms: 'my super terms',
302 defaultClientRoute: '/videos/recently-added',
303 defaultNSFWPolicy: 'blur',
304 customizations: {
305 javascript: 'alert("coucou")',
306 css: 'body { background-color: red; }'
307 }
308 }
309 })
287 310
288 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }') 311 const res = await makeHTMLRequest(server.url, '/videos/trending')
289 }) 312
313 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
314 })
290 315
291 it('Should have valid index html updated tags (title, description...)', async function () { 316 it('Should have valid index html updated tags (title, description...)', async function () {
292 const res = await makeHTMLRequest(server.url, '/videos/trending') 317 const res = await makeHTMLRequest(server.url, '/videos/trending')
293 318
294 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }') 319 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
320 })
295 }) 321 })
296 322
297 after(async function () { 323 after(async function () {