]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/video-change-ownership.ts
emit more specific status codes on video upload (#3423)
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-change-ownership.ts
index 3a3add71b099cd744ca44e3d56fc309f7e71edbd..fad4c8b1fb036c8934a8a32dc6cfebb29e0bd1b7 100644 (file)
@@ -1,4 +1,4 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import * as chai from 'chai'
 import 'mocha'
@@ -23,6 +23,7 @@ import {
 import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
 import { User } from '../../../../shared/models/users'
 import { VideoDetails } from '../../../../shared/models/videos'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
 
 const expect = chai.expect
 
@@ -38,7 +39,7 @@ describe('Test video change ownership - nominal', function () {
   }
   let firstUserAccessToken = ''
   let secondUserAccessToken = ''
-  let lastRequestChangeOwnershipId = undefined
+  let lastRequestChangeOwnershipId = ''
 
   before(async function () {
     this.timeout(50000)
@@ -48,15 +49,15 @@ describe('Test video change ownership - nominal', function () {
 
     const videoQuota = 42000000
     await createUser({
-      url: servers[ 0 ].url,
-      accessToken: servers[ 0 ].accessToken,
+      url: servers[0].url,
+      accessToken: servers[0].accessToken,
       username: firstUser.username,
       password: firstUser.password,
       videoQuota: videoQuota
     })
     await createUser({
-      url: servers[ 0 ].url,
-      accessToken: servers[ 0 ].accessToken,
+      url: servers[0].url,
+      accessToken: servers[0].accessToken,
       username: secondUser.username,
       password: secondUser.password,
       videoQuota: videoQuota
@@ -140,7 +141,7 @@ describe('Test video change ownership - nominal', function () {
   it('Should not be possible to refuse the change of ownership from first user', async function () {
     this.timeout(10000)
 
-    await refuseChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, 403)
+    await refuseChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, HttpStatusCode.FORBIDDEN_403)
   })
 
   it('Should be possible to refuse the change of ownership from second user', async function () {
@@ -177,7 +178,7 @@ describe('Test video change ownership - nominal', function () {
     const secondUserInformationResponse = await getMyUserInformation(servers[0].url, secondUserAccessToken)
     const secondUserInformation: User = secondUserInformationResponse.body
     const channelId = secondUserInformation.videoChannels[0].id
-    await acceptChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, channelId, 403)
+    await acceptChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, channelId, HttpStatusCode.FORBIDDEN_403)
   })
 
   it('Should be possible to accept the change of ownership from second user', async function () {
@@ -191,7 +192,7 @@ describe('Test video change ownership - nominal', function () {
     await waitJobs(servers)
   })
 
-  it('Should have video channel updated', async function () {
+  it('Should have the channel of the video updated', async function () {
     for (const server of servers) {
       const res = await getVideo(server.url, servers[0].video.uuid)
 
@@ -209,7 +210,7 @@ describe('Test video change ownership - nominal', function () {
 })
 
 describe('Test video change ownership - quota too small', function () {
-  let server: ServerInfo = undefined
+  let server: ServerInfo
   const firstUser = {
     username: 'first',
     password: 'My great password'
@@ -220,14 +221,14 @@ describe('Test video change ownership - quota too small', function () {
   }
   let firstUserAccessToken = ''
   let secondUserAccessToken = ''
-  let lastRequestChangeOwnershipId = undefined
+  let lastRequestChangeOwnershipId = ''
 
   before(async function () {
     this.timeout(50000)
 
     // Run one server
     server = await flushAndRunServer(1)
-    await setAccessTokensToServers([server])
+    await setAccessTokensToServers([ server ])
 
     const videoQuota = 42000000
     const limitedVideoQuota = 10
@@ -294,7 +295,14 @@ describe('Test video change ownership - quota too small', function () {
     const secondUserInformationResponse = await getMyUserInformation(server.url, secondUserAccessToken)
     const secondUserInformation: User = secondUserInformationResponse.body
     const channelId = secondUserInformation.videoChannels[0].id
-    await acceptChangeOwnership(server.url, secondUserAccessToken, lastRequestChangeOwnershipId, channelId, 403)
+
+    await acceptChangeOwnership(
+      server.url,
+      secondUserAccessToken,
+      lastRequestChangeOwnershipId,
+      channelId,
+      HttpStatusCode.PAYLOAD_TOO_LARGE_413
+    )
   })
 
   after(async function () {