]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/utils/videos/videos.ts
Fix videos tests
[github/Chocobozzz/PeerTube.git] / server / tests / utils / videos / videos.ts
index 6de1b8c92c9d1d00b59a1333f7a02837c5f475aa..7393942534b831be1da5fa0b5a5edb050ef2eedf 100644 (file)
@@ -21,25 +21,41 @@ type VideoAttributes = {
 function getVideoCategories (url: string) {
   const path = '/api/v1/videos/categories'
 
-  return makeGetRequest(url, path)
+  return makeGetRequest({
+    url,
+    path,
+    statusCodeExpected: 200
+  })
 }
 
 function getVideoLicences (url: string) {
   const path = '/api/v1/videos/licences'
 
-  return makeGetRequest(url, path)
+  return makeGetRequest({
+    url,
+    path,
+    statusCodeExpected: 200
+  })
 }
 
 function getVideoLanguages (url: string) {
   const path = '/api/v1/videos/languages'
 
-  return makeGetRequest(url, path)
+  return makeGetRequest({
+    url,
+    path,
+    statusCodeExpected: 200
+  })
 }
 
 function getVideoPrivacies (url: string) {
   const path = '/api/v1/videos/privacies'
 
-  return makeGetRequest(url, path)
+  return makeGetRequest({
+    url,
+    path,
+    statusCodeExpected: 200
+  })
 }
 
 function getVideo (url: string, id: number | string, expectedStatus = 200) {
@@ -131,7 +147,7 @@ function getVideosListSort (url: string, sort: string) {
           .expect('Content-Type', /json/)
 }
 
-function removeVideo (url: string, token: string, id: number, expectedStatus = 204) {
+function removeVideo (url: string, token: string, id: number | string, expectedStatus = 204) {
   const path = '/api/v1/videos'
 
   return request(url)
@@ -188,7 +204,7 @@ async function testVideoImage (url: string, imageName: string, imagePath: string
                         .get(imagePath)
                         .expect(200)
 
-    const data = await readFilePromise(join(__dirname, '..', 'api', 'fixtures', imageName + '.jpg'))
+    const data = await readFilePromise(join(__dirname, '..', '..', 'api', 'fixtures', imageName + '.jpg'))
 
     return data.equals(res.body)
   } else {
@@ -245,7 +261,7 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg
   if (isAbsolute(attributes.fixture)) {
     filePath = attributes.fixture
   } else {
-    filePath = join(__dirname, '..', 'api', 'fixtures', attributes.fixture)
+    filePath = join(__dirname, '..', '..', 'api', 'fixtures', attributes.fixture)
   }
 
   return req.attach('videofile', filePath)
@@ -287,7 +303,7 @@ function rateVideo (url: string, accessToken: string, id: number, rating: string
 function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) {
   return new Promise<any>((res, rej) => {
     const torrentName = videoUUID + '-' + resolution + '.torrent'
-    const torrentPath = join(__dirname, '..', '..', '..', 'test' + server.serverNumber, 'torrents', torrentName)
+    const torrentPath = join(__dirname, '..', '..', '..', '..', 'test' + server.serverNumber, 'torrents', torrentName)
     readFile(torrentPath, (err, data) => {
       if (err) return rej(err)