]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/utils/videos/videos.ts
Change video abuse API response
[github/Chocobozzz/PeerTube.git] / server / tests / utils / videos / videos.ts
index 9d4267db84c00898d5f2ff8f73920c9538dc6078..ec40c546512f2ccffe37a176d398388586638b36 100644 (file)
@@ -3,7 +3,7 @@
 import { expect } from 'chai'
 import { existsSync, readFile } from 'fs'
 import * as parseTorrent from 'parse-torrent'
-import { extname, isAbsolute, join } from 'path'
+import { extname, join } from 'path'
 import * as request from 'supertest'
 import {
   buildAbsoluteFixturePath,
@@ -248,6 +248,7 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg
     channelId: defaultChannelId,
     nsfw: true,
     description: 'my super description',
+    support: 'my super support text',
     tags: [ 'tag' ],
     privacy: VideoPrivacy.PUBLIC,
     commentsEnabled: true,
@@ -277,6 +278,10 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg
     req.field('licence', attributes.licence.toString())
   }
 
+  for (let i = 0; i < attributes.tags.length; i++) {
+    req.field('tags[' + i + ']', attributes.tags[i])
+  }
+
   if (attributes.thumbnailfile !== undefined) {
     req.attach('thumbnailfile', buildAbsoluteFixturePath(attributes.thumbnailfile))
   }
@@ -284,10 +289,6 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg
     req.attach('previewfile', buildAbsoluteFixturePath(attributes.previewfile))
   }
 
-  for (let i = 0; i < attributes.tags.length; i++) {
-    req.field('tags[' + i + ']', attributes.tags[i])
-  }
-
   return req.attach('videofile', buildAbsoluteFixturePath(attributes.fixture))
             .expect(specialStatus)
 }
@@ -366,8 +367,11 @@ async function completeVideoCheck (
     nsfw: boolean
     commentsEnabled: boolean
     description: string
-    host: string
-    account: string
+    support: string
+    account: {
+      name: string
+      host: string
+    }
     isLocal: boolean,
     tags: string[],
     privacy: number,
@@ -400,8 +404,8 @@ async function completeVideoCheck (
   expect(video.languageLabel).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown')
   expect(video.nsfw).to.equal(attributes.nsfw)
   expect(video.description).to.equal(attributes.description)
-  expect(video.serverHost).to.equal(attributes.host)
-  expect(video.accountName).to.equal(attributes.account)
+  expect(video.account.host).to.equal(attributes.account.host)
+  expect(video.account.name).to.equal(attributes.account.name)
   expect(video.likes).to.equal(attributes.likes)
   expect(video.dislikes).to.equal(attributes.dislikes)
   expect(video.isLocal).to.equal(attributes.isLocal)
@@ -416,7 +420,8 @@ async function completeVideoCheck (
   expect(videoDetails.tags).to.deep.equal(attributes.tags)
   expect(videoDetails.privacy).to.deep.equal(attributes.privacy)
   expect(videoDetails.privacyLabel).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy])
-  expect(videoDetails.account.name).to.equal(attributes.account)
+  expect(videoDetails.account.name).to.equal(attributes.account.name)
+  expect(videoDetails.account.host).to.equal(attributes.account.host)
   expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled)
 
   expect(videoDetails.channel.displayName).to.equal(attributes.channel.name)
@@ -431,12 +436,12 @@ async function completeVideoCheck (
 
     let extension = extname(attributes.fixture)
     // Transcoding enabled on server 2, extension will always be .mp4
-    if (attributes.host === 'localhost:9002') extension = '.mp4'
+    if (attributes.account.host === 'localhost:9002') extension = '.mp4'
 
     const magnetUri = file.magnetUri
     expect(file.magnetUri).to.have.lengthOf.above(2)
-    expect(file.torrentUrl).to.equal(`http://${attributes.host}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
-    expect(file.fileUrl).to.equal(`http://${attributes.host}/static/webseed/${videoDetails.uuid}-${file.resolution}${extension}`)
+    expect(file.torrentUrl).to.equal(`http://${attributes.account.host}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
+    expect(file.fileUrl).to.equal(`http://${attributes.account.host}/static/webseed/${videoDetails.uuid}-${file.resolution}${extension}`)
     expect(file.resolution).to.equal(attributeFile.resolution)
     expect(file.resolutionLabel).to.equal(attributeFile.resolution + 'p')
 
@@ -445,13 +450,11 @@ async function completeVideoCheck (
     expect(file.size).to.be.above(minSize).and.below(maxSize)
 
     {
-      const test = await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath)
-      expect(test).to.equal(true)
+      await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath)
     }
 
     if (attributes.previewfile) {
-      const test = await testImage(url, attributes.previewfile, videoDetails.previewPath)
-      expect(test).to.equal(true)
+      await testImage(url, attributes.previewfile, videoDetails.previewPath)
     }
 
     const torrent = await webtorrentAdd(magnetUri, true)