]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/config.ts
Merge branch 'feature/parallel-tests' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / config.ts
index b9f05e952b9dc1d8d65fe3384797e43b4686c45b..ca389b7b6b64c126d249464809024556ddfa0127 100644 (file)
@@ -5,23 +5,23 @@ import * as chai from 'chai'
 import { About } from '../../../../shared/models/server/about.model'
 import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
 import {
+  cleanupTests,
   deleteCustomConfig,
+  flushAndRunServer,
   getAbout,
-  killallServers,
-  reRunServer,
-  flushTests,
   getConfig,
   getCustomConfig,
+  killallServers, parallelTests,
   registerUser,
-  runServer,
+  reRunServer, ServerInfo,
   setAccessTokensToServers,
   updateCustomConfig
-} from '../../../../shared/utils'
+} from '../../../../shared/extra-utils'
 import { ServerConfig } from '../../../../shared/models'
 
 const expect = chai.expect
 
-function checkInitialConfig (data: CustomConfig) {
+function checkInitialConfig (server: ServerInfo, data: CustomConfig) {
   expect(data.instance.name).to.equal('PeerTube')
   expect(data.instance.shortDescription).to.equal(
     'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' +
@@ -45,7 +45,7 @@ function checkInitialConfig (data: CustomConfig) {
   expect(data.signup.limit).to.equal(4)
   expect(data.signup.requiresEmailVerification).to.be.false
 
-  expect(data.admin.email).to.equal('admin1@example.com')
+  expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com')
   expect(data.contactForm.enabled).to.be.true
 
   expect(data.user.videoQuota).to.equal(5242880)
@@ -63,6 +63,9 @@ function checkInitialConfig (data: CustomConfig) {
   expect(data.import.videos.http.enabled).to.be.true
   expect(data.import.videos.torrent.enabled).to.be.true
   expect(data.autoBlacklist.videos.ofUsers.enabled).to.be.false
+
+  expect(data.followers.instance.enabled).to.be.true
+  expect(data.followers.instance.manualApproval).to.be.false
 }
 
 function checkUpdatedConfig (data: CustomConfig) {
@@ -86,7 +89,11 @@ function checkUpdatedConfig (data: CustomConfig) {
   expect(data.signup.limit).to.equal(5)
   expect(data.signup.requiresEmailVerification).to.be.false
 
-  expect(data.admin.email).to.equal('superadmin1@example.com')
+  // We override admin email in parallel tests, so skip this exception
+  if (parallelTests() === false) {
+    expect(data.admin.email).to.equal('superadmin1@example.com')
+  }
+
   expect(data.contactForm.enabled).to.be.false
 
   expect(data.user.videoQuota).to.equal(5242881)
@@ -105,6 +112,9 @@ function checkUpdatedConfig (data: CustomConfig) {
   expect(data.import.videos.http.enabled).to.be.false
   expect(data.import.videos.torrent.enabled).to.be.false
   expect(data.autoBlacklist.videos.ofUsers.enabled).to.be.true
+
+  expect(data.followers.instance.enabled).to.be.false
+  expect(data.followers.instance.manualApproval).to.be.true
 }
 
 describe('Test config', function () {
@@ -113,8 +123,7 @@ describe('Test config', function () {
   before(async function () {
     this.timeout(30000)
 
-    await flushTests()
-    server = await runServer(1)
+    server = await flushAndRunServer(1)
     await setAccessTokensToServers([ server ])
   })
 
@@ -156,7 +165,7 @@ describe('Test config', function () {
     const res = await getCustomConfig(server.url, server.accessToken)
     const data = res.body as CustomConfig
 
-    checkInitialConfig(data)
+    checkInitialConfig(server, data)
   })
 
   it('Should update the customized configuration', async function () {
@@ -234,6 +243,12 @@ describe('Test config', function () {
             enabled: true
           }
         }
+      },
+      followers: {
+        instance: {
+          enabled: false,
+          manualApproval: true
+        }
       }
     }
     await updateCustomConfig(server.url, server.accessToken, newCustomConfig)
@@ -287,10 +302,10 @@ describe('Test config', function () {
     const res = await getCustomConfig(server.url, server.accessToken)
     const data = res.body
 
-    checkInitialConfig(data)
+    checkInitialConfig(server, data)
   })
 
   after(async function () {
-    killallServers([ server ])
+    await cleanupTests([ server ])
   })
 })