]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/client.ts
Add tests
[github/Chocobozzz/PeerTube.git] / server / tests / client.ts
index 6dd4b7cf6096a0dab8e2c0f628f14e946be219de..7bcb999eacd09520dffb3a7e0fd647d7ba78e697 100644 (file)
@@ -8,19 +8,20 @@ import {
   addVideoInPlaylist,
   cleanupTests,
   createVideoPlaylist,
-  flushAndRunServer,
   getAccount,
   getCustomConfig,
   getVideosList,
   makeHTMLRequest,
   ServerInfo,
-  serverLogin,
   setDefaultVideoChannel,
   updateCustomConfig,
   updateCustomSubConfig,
   uploadVideo,
   updateMyUser,
-  updateVideoChannel
+  updateVideoChannel,
+  doubleFollow,
+  flushAndRunMultipleServers,
+  setAccessTokensToServers
 } from '../../shared/extra-utils'
 import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
 
@@ -33,8 +34,11 @@ function checkIndexTags (html: string, title: string, description: string, css:
 }
 
 describe('Test a client controllers', function () {
+  let servers: ServerInfo[] = []
   let server: ServerInfo
   let account: Account
+  let videoUUID: string
+  let videoOriginalUrl: string
 
   const videoName = 'my super name for server 1'
   const videoDescription = 'my super description for server 1'
@@ -48,8 +52,19 @@ describe('Test a client controllers', function () {
   before(async function () {
     this.timeout(120000)
 
-    server = await flushAndRunServer(1)
-    server.accessToken = await serverLogin(server)
+    servers = await flushAndRunMultipleServers(2)
+    const server = servers[0]
+
+    await setAccessTokensToServers(servers)
+
+    {
+      const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' })
+      videoUUID = res.body.video.uuid
+      videoOriginalUrl = res.body.video.url
+    }
+
+    await doubleFollow(servers[0], servers[1])
+
     await setDefaultVideoChannel([ server ])
 
     await updateVideoChannel(server.url, server.accessToken, server.videoChannel.name, { description: channelDescription })
@@ -319,6 +334,11 @@ describe('Test a client controllers', function () {
 
       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/' + videoUUID)
+      expect(res.text).to.contain(`<link rel="canonical" href="${videoOriginalUrl}" />`)
+    })
   })
 
   after(async function () {