+ it('Should have valid twitter card on the watch video page', async function () {
+ const res = await request(servers[0].url)
+ .get('/videos/watch/' + servers[0].video.uuid)
+ .set('Accept', 'text/html')
+ .expect(HttpStatusCode.OK_200)
+
+ expect(res.text).to.contain('<meta property="twitter:card" content="summary_large_image" />')
+ expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
+ expect(res.text).to.contain(`<meta property="twitter:title" content="${videoName}" />`)
+ expect(res.text).to.contain(`<meta property="twitter:description" content="${videoDescription}" />`)
+ })
+
+ it('Should have valid twitter card on the watch playlist page', async function () {
+ const res = await request(servers[0].url)
+ .get('/videos/watch/playlist/' + playlistUUID)
+ .set('Accept', 'text/html')
+ .expect(HttpStatusCode.OK_200)
+
+ expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
+ expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
+ expect(res.text).to.contain(`<meta property="twitter:title" content="${playlistName}" />`)
+ expect(res.text).to.contain(`<meta property="twitter:description" content="${playlistDescription}" />`)
+ })
+
+ it('Should have valid twitter card on the account page', async function () {
+ const res = await request(servers[0].url)
+ .get('/accounts/' + account.name)
+ .set('Accept', 'text/html')
+ .expect(HttpStatusCode.OK_200)
+
+ expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
+ expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
+ expect(res.text).to.contain(`<meta property="twitter:title" content="${account.name}" />`)
+ expect(res.text).to.contain(`<meta property="twitter:description" content="${account.description}" />`)
+ })
+
+ it('Should have valid twitter card on the channel page', async function () {
+ const res = await request(servers[0].url)
+ .get('/video-channels/' + servers[0].videoChannel.name)
+ .set('Accept', 'text/html')
+ .expect(HttpStatusCode.OK_200)
+
+ expect(res.text).to.contain('<meta property="twitter:card" content="summary" />')
+ expect(res.text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
+ expect(res.text).to.contain(`<meta property="twitter:title" content="${servers[0].videoChannel.displayName}" />`)
+ expect(res.text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`)
+ })
+
+ it('Should have valid twitter card if Twitter is whitelisted', async function () {
+ const res1 = await getCustomConfig(servers[0].url, servers[0].accessToken)
+ const config = res1.body
+ config.services.twitter = {
+ username: '@Kuja',
+ whitelisted: true
+ }
+ await updateCustomConfig(servers[0].url, servers[0].accessToken, config)
+
+ const resVideoRequest = await request(servers[0].url)
+ .get('/videos/watch/' + servers[0].video.uuid)
+ .set('Accept', 'text/html')
+ .expect(HttpStatusCode.OK_200)
+
+ expect(resVideoRequest.text).to.contain('<meta property="twitter:card" content="player" />')
+ expect(resVideoRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
+
+ const resVideoPlaylistRequest = await request(servers[0].url)
+ .get('/videos/watch/playlist/' + playlistUUID)
+ .set('Accept', 'text/html')
+ .expect(HttpStatusCode.OK_200)
+
+ expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:card" content="player" />')
+ expect(resVideoPlaylistRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
+
+ const resAccountRequest = await request(servers[0].url)
+ .get('/accounts/' + account.name)
+ .set('Accept', 'text/html')
+ .expect(HttpStatusCode.OK_200)
+
+ expect(resAccountRequest.text).to.contain('<meta property="twitter:card" content="summary" />')
+ expect(resAccountRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
+
+ const resChannelRequest = await request(servers[0].url)
+ .get('/video-channels/' + servers[0].videoChannel.name)
+ .set('Accept', 'text/html')
+ .expect(HttpStatusCode.OK_200)
+
+ expect(resChannelRequest.text).to.contain('<meta property="twitter:card" content="summary" />')
+ expect(resChannelRequest.text).to.contain('<meta property="twitter:site" content="@Kuja" />')
+ })
+ })
+
+ describe('Index HTML', function () {
+
+ it('Should have valid index html tags (title, description...)', async function () {
+ const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
+
+ const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'
+ checkIndexTags(res.text, 'PeerTube', description, '')
+ })
+
+ it('Should update the customized configuration and have the correct index html tags', async function () {
+ await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
+ instance: {
+ name: 'PeerTube updated',
+ shortDescription: 'my short description',
+ description: 'my super description',
+ terms: 'my super terms',
+ defaultNSFWPolicy: 'blur',
+ defaultClientRoute: '/videos/recently-added',
+ customizations: {
+ javascript: 'alert("coucou")',
+ css: 'body { background-color: red; }'
+ }
+ }
+ })
+
+ const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
+
+ checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
+ })
+
+ it('Should have valid index html updated tags (title, description...)', async function () {
+ const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
+
+ checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
+ })
+
+ it('Should use the original video URL for the canonical tag', async function () {
+ const res = await makeHTMLRequest(servers[1].url, '/videos/watch/' + servers[0].video.uuid)
+ expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/videos/watch/${servers[0].video.uuid}" />`)
+ })
+
+ it('Should use the original account URL for the canonical tag', async function () {
+ const res = await makeHTMLRequest(servers[1].url, '/accounts/root@' + servers[0].host)
+ expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/accounts/root" />`)
+ })
+
+ it('Should use the original channel URL for the canonical tag', async function () {
+ const res = await makeHTMLRequest(servers[1].url, '/video-channels/root_channel@' + servers[0].host)
+ expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-channels/root_channel" />`)
+ })
+
+ it('Should use the original playlist URL for the canonical tag', async function () {
+ const res = await makeHTMLRequest(servers[1].url, '/videos/watch/playlist/' + playlistUUID)
+ expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-playlists/${playlistUUID}" />`)
+ })
+ })
+
+ after(async function () {
+ await cleanupTests(servers)