]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/utils/videos.ts
Design second video upload step
[github/Chocobozzz/PeerTube.git] / server / tests / utils / videos.ts
index dababe9249e9c87c5d83a48cfb8fff9b8e521bc6..bdf3368ac87d460401348eaead2596c7287f6d2a 100644 (file)
@@ -55,6 +55,15 @@ function getVideo (url: string, id: number | string, expectedStatus = 200) {
           .expect(expectedStatus)
 }
 
+function viewVideo (url: string, id: number | string, expectedStatus = 204) {
+  const path = '/api/v1/videos/' + id + '/views'
+
+  return request(url)
+    .post(path)
+    .set('Accept', 'application/json')
+    .expect(expectedStatus)
+}
+
 function getVideoWithToken (url: string, token: string, id: number | string, expectedStatus = 200) {
   const path = '/api/v1/videos/' + id
 
@@ -136,26 +145,25 @@ function removeVideo (url: string, token: string, id: number, expectedStatus = 2
           .expect(expectedStatus)
 }
 
-function searchVideo (url: string, search: string, field?: string) {
+function searchVideo (url: string, search: string) {
   const path = '/api/v1/videos'
   const req = request(url)
-                .get(path + '/search/' + search)
-                .set('Accept', 'application/json')
-
-  if (field) req.query({ field })
+    .get(path + '/search')
+    .query({ search })
+    .set('Accept', 'application/json')
 
   return req.expect(200)
-            .expect('Content-Type', /json/)
+    .expect('Content-Type', /json/)
 }
 
-function searchVideoWithPagination (url: string, search: string, field: string, start: number, count: number, sort?: string) {
+function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) {
   const path = '/api/v1/videos'
 
   const req = request(url)
-                .get(path + '/search/' + search)
+                .get(path + '/search')
                 .query({ start })
+                .query({ search })
                 .query({ count })
-                .query({ field })
 
   if (sort) req.query({ sort })
 
@@ -168,7 +176,8 @@ function searchVideoWithSort (url: string, search: string, sort: string) {
   const path = '/api/v1/videos'
 
   return request(url)
-          .get(path + '/search/' + search)
+          .get(path + '/search')
+          .query({ search })
           .query({ sort })
           .set('Accept', 'application/json')
           .expect(200)
@@ -192,7 +201,7 @@ async function testVideoImage (url: string, imageName: string, imagePath: string
   }
 }
 
-async function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 204) {
+async function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 201) {
   const path = '/api/v1/videos/upload'
   let defaultChannelId = '1'
 
@@ -313,5 +322,6 @@ export {
   uploadVideo,
   updateVideo,
   rateVideo,
+  viewVideo,
   parseTorrentVideo
 }