]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/videos.ts
Add ability to search a video with an URL
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / videos.ts
index 04bed3b441be808f74f022b0183a48c622246852..904d2287090b12dc3859c4779541d99b1d3ce80a 100644 (file)
@@ -20,7 +20,7 @@ describe('Test videos API validator', function () {
   let userAccessToken = ''
   let accountName: string
   let channelId: number
-  let channelUUID: string
+  let channelName: string
   let videoId
 
   // ---------------------------------------------------------------
@@ -42,7 +42,7 @@ describe('Test videos API validator', function () {
     {
       const res = await getMyUserInformation(server.url, server.accessToken)
       channelId = res.body.videoChannels[ 0 ].id
-      channelUUID = res.body.videoChannels[ 0 ].uuid
+      channelName = res.body.videoChannels[ 0 ].name
       accountName = res.body.account.name + '@' + res.body.account.host
     }
   })
@@ -140,7 +140,7 @@ describe('Test videos API validator', function () {
     let path: string
 
     before(async function () {
-      path = '/api/v1/video-channels/' + channelUUID + '/videos'
+      path = '/api/v1/video-channels/' + channelName + '/videos'
     })
 
     it('Should fail with a bad start pagination', async function () {
@@ -291,6 +291,23 @@ describe('Test videos API validator', function () {
       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
+    it('Should fail with a bad schedule update (miss updateAt)', async function () {
+      const fields = immutableAssign(baseCorrectParams, { 'scheduleUpdate[privacy]': VideoPrivacy.PUBLIC })
+      const attaches = baseCorrectAttaches
+
+      await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
+    })
+
+    it('Should fail with a bad schedule update (wrong updateAt)', async function () {
+      const fields = immutableAssign(baseCorrectParams, {
+        'scheduleUpdate[privacy]': VideoPrivacy.PUBLIC,
+        'scheduleUpdate[updateAt]': 'toto'
+      })
+      const attaches = baseCorrectAttaches
+
+      await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
+    })
+
     it('Should fail without an input file', async function () {
       const fields = baseCorrectParams
       const attaches = {}
@@ -309,7 +326,7 @@ describe('Test videos API validator', function () {
       const fields = baseCorrectParams
       const attaches = {
         'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'),
-        'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm')
+        'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
       }
 
       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
@@ -319,7 +336,7 @@ describe('Test videos API validator', function () {
       const fields = baseCorrectParams
       const attaches = {
         'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'),
-        'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm')
+        'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
       }
 
       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
@@ -329,7 +346,7 @@ describe('Test videos API validator', function () {
       const fields = baseCorrectParams
       const attaches = {
         'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'),
-        'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm')
+        'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
       }
 
       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
@@ -339,7 +356,7 @@ describe('Test videos API validator', function () {
       const fields = baseCorrectParams
       const attaches = {
         'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'),
-        'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm')
+        'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
       }
 
       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
@@ -494,6 +511,18 @@ describe('Test videos API validator', function () {
       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
     })
 
+    it('Should fail with a bad schedule update (miss updateAt)', async function () {
+      const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } })
+
+      await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
+    })
+
+    it('Should fail with a bad schedule update (wrong updateAt)', async function () {
+      const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } })
+
+      await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
+    })
+
     it('Should fail with an incorrect thumbnail file', async function () {
       const fields = baseCorrectParams
       const attaches = {