]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/utils/videos/videos.ts
Begin advanced search
[github/Chocobozzz/PeerTube.git] / server / tests / utils / videos / videos.ts
index 2c1d20ef10dff61cf119d5a51eb0417312b1dbf4..a42d0f0431642041bd7fdc364ea26ba1c52d89fd 100644 (file)
@@ -35,6 +35,10 @@ type VideoAttributes = {
   fixture?: string
   thumbnailfile?: string
   previewfile?: string
+  scheduleUpdate?: {
+    updateAt: string
+    privacy?: VideoPrivacy
+  }
 }
 
 function getVideoCategories (url: string) {
@@ -244,9 +248,9 @@ function removeVideo (url: string, token: string, id: number | string, expectedS
 }
 
 function searchVideo (url: string, search: string) {
-  const path = '/api/v1/videos'
+  const path = '/api/v1/search/videos'
   const req = request(url)
-    .get(path + '/search')
+    .get(path)
     .query({ search })
     .set('Accept', 'application/json')
 
@@ -267,10 +271,10 @@ function searchVideoWithToken (url: string, search: string, token: string) {
 }
 
 function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) {
-  const path = '/api/v1/videos'
+  const path = '/api/v1/search/videos'
 
   const req = request(url)
-                .get(path + '/search')
+                .get(path)
                 .query({ start })
                 .query({ search })
                 .query({ count })
@@ -283,10 +287,10 @@ function searchVideoWithPagination (url: string, search: string, start: number,
 }
 
 function searchVideoWithSort (url: string, search: string, sort: string) {
-  const path = '/api/v1/videos'
+  const path = '/api/v1/search/videos'
 
   return request(url)
-          .get(path + '/search')
+          .get(path)
           .query({ search })
           .query({ sort })
           .set('Accept', 'application/json')
@@ -297,7 +301,7 @@ function searchVideoWithSort (url: string, search: string, sort: string) {
 async function checkVideoFilesWereRemoved (videoUUID: string, serverNumber: number) {
   const testDirectory = 'test' + serverNumber
 
-  for (const directory of [ 'videos', 'thumbnails', 'torrents', 'previews' ]) {
+  for (const directory of [ 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ]) {
     const directoryPath = join(root(), testDirectory, directory)
 
     const directoryExists = existsSync(directoryPath)
@@ -371,6 +375,14 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg
     req.attach('previewfile', buildAbsoluteFixturePath(attributes.previewfile))
   }
 
+  if (attributes.scheduleUpdate) {
+    req.field('scheduleUpdate[updateAt]', attributes.scheduleUpdate.updateAt)
+
+    if (attributes.scheduleUpdate.privacy) {
+      req.field('scheduleUpdate[privacy]', attributes.scheduleUpdate.privacy)
+    }
+  }
+
   return req.attach('videofile', buildAbsoluteFixturePath(attributes.fixture))
             .expect(specialStatus)
 }
@@ -389,6 +401,7 @@ function updateVideo (url: string, accessToken: string, id: number | string, att
   if (attributes.tags) body['tags'] = attributes.tags
   if (attributes.privacy) body['privacy'] = attributes.privacy
   if (attributes.channelId) body['channelId'] = attributes.channelId
+  if (attributes.scheduleUpdate) body['scheduleUpdate'] = attributes.scheduleUpdate
 
   // Upload request
   if (attributes.thumbnailfile || attributes.previewfile) {