]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/config.ts
Use an object to represent a server
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / config.ts
index 9549070ef1b71b69524da96796b72d01ffa8e848..1756d58eecdc1e70d8ad7be7bf019dfd74c2b8ba 100644 (file)
@@ -1,26 +1,22 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import { omit } from 'lodash'
 import 'mocha'
-import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
-
+import { omit } from 'lodash'
+import { HttpStatusCode } from '@shared/core-utils'
 import {
   cleanupTests,
-  createUser,
-  flushAndRunServer,
-  immutableAssign,
+  createSingleServer,
   makeDeleteRequest,
   makeGetRequest,
   makePutBodyRequest,
-  ServerInfo,
-  setAccessTokensToServers,
-  userLogin
-} from '../../../../shared/extra-utils'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+  PeerTubeServer,
+  setAccessTokensToServers
+} from '@shared/extra-utils'
+import { CustomConfig } from '@shared/models'
 
 describe('Test config API validators', function () {
   const path = '/api/v1/config/custom'
-  let server: ServerInfo
+  let server: PeerTubeServer
   let userAccessToken: string
   const updateParams: CustomConfig = {
     instance: {
@@ -201,7 +197,7 @@ describe('Test config API validators', function () {
   before(async function () {
     this.timeout(30000)
 
-    server = await flushAndRunServer(1)
+    server = await createSingleServer(1)
 
     await setAccessTokensToServers([ server ])
 
@@ -209,8 +205,8 @@ describe('Test config API validators', function () {
       username: 'user1',
       password: 'password'
     }
-    await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
-    userAccessToken = await userLogin(server, user)
+    await server.users.create({ username: user.username, password: user.password })
+    userAccessToken = await server.login.getAccessToken(user)
   })
 
   describe('When getting the configuration', function () {
@@ -265,11 +261,13 @@ describe('Test config API validators', function () {
     })
 
     it('Should fail with a bad default NSFW policy', async function () {
-      const newUpdateParams = immutableAssign(updateParams, {
+      const newUpdateParams = {
+        ...updateParams,
+
         instance: {
           defaultNSFWPolicy: 'hello'
         }
-      })
+      }
 
       await makePutBodyRequest({
         url: server.url,
@@ -282,13 +280,15 @@ describe('Test config API validators', function () {
 
     it('Should fail if email disabled and signup requires email verification', async function () {
       // opposite scenario - success when enable enabled - covered via tests/api/users/user-verification.ts
-      const newUpdateParams = immutableAssign(updateParams, {
+      const newUpdateParams = {
+        ...updateParams,
+
         signup: {
           enabled: true,
           limit: 5,
           requiresEmailVerification: true
         }
-      })
+      }
 
       await makePutBodyRequest({
         url: server.url,
@@ -300,7 +300,9 @@ describe('Test config API validators', function () {
     })
 
     it('Should fail with a disabled webtorrent & hls transcoding', async function () {
-      const newUpdateParams = immutableAssign(updateParams, {
+      const newUpdateParams = {
+        ...updateParams,
+
         transcoding: {
           hls: {
             enabled: false
@@ -309,7 +311,7 @@ describe('Test config API validators', function () {
             enabled: false
           }
         }
-      })
+      }
 
       await makePutBodyRequest({
         url: server.url,