+
+ await servers[0].config.updateCustomConfig({ newCustomConfig: config })
+ })
+
+ async function accountPageTest (path: string) {
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
+ const text = res.text
+
+ expect(text).to.contain('<meta property="twitter:card" content="summary" />')
+ expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
+ }
+
+ async function channelPageTest (path: string) {
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
+ const text = res.text
+
+ expect(text).to.contain('<meta property="twitter:card" content="summary" />')
+ expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
+ }
+
+ async function watchVideoPageTest (path: string) {
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
+ const text = res.text
+
+ expect(text).to.contain('<meta property="twitter:card" content="player" />')
+ expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
+ }
+
+ async function watchPlaylistPageTest (path: string) {
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
+ const text = res.text
+
+ expect(text).to.contain('<meta property="twitter:card" content="player" />')
+ expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')
+ }
+
+ it('Should have valid twitter card on the watch video page', async function () {
+ for (const path of watchVideoBasePaths) {
+ for (const id of videoIds) {
+ await watchVideoPageTest(path + id)
+ }
+ }
+ })
+
+ it('Should have valid twitter card on the watch playlist page', async function () {
+ for (const path of watchPlaylistBasePaths) {
+ for (const id of playlistIds) {
+ await watchPlaylistPageTest(path + id)
+ }
+ }
+ })
+
+ it('Should have valid twitter card on the account page', async function () {
+ await accountPageTest('/accounts/' + account.name)
+ await accountPageTest('/a/' + account.name)
+ await accountPageTest('/@' + account.name)
+ })
+
+ it('Should have valid twitter card on the channel page', async function () {
+ await channelPageTest('/video-channels/' + servers[0].store.channel.name)
+ await channelPageTest('/c/' + servers[0].store.channel.name)
+ await channelPageTest('/@' + servers[0].store.channel.name)
+ })
+ })
+ })
+
+ describe('Index HTML', function () {
+
+ it('Should have valid index html tags (title, description...)', async function () {
+ const config = await servers[0].config.getConfig()
+ 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, '', config)
+ })
+
+ it('Should update the customized configuration and have the correct index html tags', async function () {
+ await servers[0].config.updateCustomSubConfig({
+ newConfig: {
+ 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 config = await servers[0].config.getConfig()
+ const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
+
+ checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
+ })
+
+ it('Should have valid index html updated tags (title, description...)', async function () {
+ const config = await servers[0].config.getConfig()
+ const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
+
+ checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
+ })
+
+ it('Should use the original video URL for the canonical tag', async function () {
+ for (const basePath of watchVideoBasePaths) {
+ for (const id of videoIds) {
+ const res = await makeHTMLRequest(servers[1].url, basePath + id)
+ expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/videos/watch/${servers[0].store.video.uuid}" />`)