Browse Source

Fix config test with parallel tests

Chocobozzz 1 month ago
parent
commit
7eb0189b73
1 changed files with 211 additions and 209 deletions
  1. 211 209
      packages/tests/src/api/server/config.ts

+ 211 - 209
packages/tests/src/api/server/config.ts

@@ -56,7 +56,7 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) {
   expect(data.signup.requiresApproval).to.be.false
   expect(data.signup.requiresEmailVerification).to.be.false
 
-  expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com')
+  expect(data.admin.email).to.equal(`admin${server.internalServerNumber}@example.com`)
   expect(data.contactForm.enabled).to.be.true
 
   expect(data.user.history.videos.enabled).to.be.true
@@ -136,248 +136,250 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) {
   expect(data.export.users.maxUserVideoQuota).to.equal(10737418240)
 }
 
-const newCustomConfig: CustomConfig = {
-  instance: {
-    name: 'PeerTube updated',
-    shortDescription: 'my short description',
-    description: 'my super description',
-    terms: 'my super terms',
-    codeOfConduct: 'my super coc',
-
-    creationReason: 'my super creation reason',
-    moderationInformation: 'my super moderation information',
-    administrator: 'Kuja',
-    maintenanceLifetime: 'forever',
-    businessModel: 'my super business model',
-    hardwareInformation: '2vCore 3GB RAM',
-
-    languages: [ 'en', 'es' ],
-    categories: [ 1, 2 ],
-
-    isNSFW: true,
-    defaultNSFWPolicy: 'blur' as 'blur',
-
-    defaultClientRoute: '/videos/recently-added',
-
-    customizations: {
-      javascript: 'alert("coucou")',
-      css: 'body { background-color: red; }'
-    }
-  },
-  theme: {
-    default: 'default'
-  },
-  services: {
-    twitter: {
-      username: '@Kuja'
-    }
-  },
-  client: {
-    videos: {
-      miniature: {
-        preferAuthorDisplayName: true
-      }
-    },
-    menu: {
-      login: {
-        redirectOnSingleExternalAuth: true
+function buildNewCustomConfig (server: PeerTubeServer): CustomConfig {
+  return {
+    instance: {
+      name: 'PeerTube updated',
+      shortDescription: 'my short description',
+      description: 'my super description',
+      terms: 'my super terms',
+      codeOfConduct: 'my super coc',
+
+      creationReason: 'my super creation reason',
+      moderationInformation: 'my super moderation information',
+      administrator: 'Kuja',
+      maintenanceLifetime: 'forever',
+      businessModel: 'my super business model',
+      hardwareInformation: '2vCore 3GB RAM',
+
+      languages: [ 'en', 'es' ],
+      categories: [ 1, 2 ],
+
+      isNSFW: true,
+      defaultNSFWPolicy: 'blur' as 'blur',
+
+      defaultClientRoute: '/videos/recently-added',
+
+      customizations: {
+        javascript: 'alert("coucou")',
+        css: 'body { background-color: red; }'
       }
-    }
-  },
-  cache: {
-    previews: {
-      size: 2
     },
-    captions: {
-      size: 3
+    theme: {
+      default: 'default'
     },
-    torrents: {
-      size: 4
+    services: {
+      twitter: {
+        username: '@Kuja'
+      }
     },
-    storyboards: {
-      size: 5
-    }
-  },
-  signup: {
-    enabled: false,
-    limit: 5,
-    requiresApproval: false,
-    requiresEmailVerification: false,
-    minimumAge: 10
-  },
-  admin: {
-    email: 'superadmin1@example.com'
-  },
-  contactForm: {
-    enabled: false
-  },
-  user: {
-    history: {
+    client: {
       videos: {
-        enabled: false
+        miniature: {
+          preferAuthorDisplayName: true
+        }
+      },
+      menu: {
+        login: {
+          redirectOnSingleExternalAuth: true
+        }
       }
     },
-    videoQuota: 5242881,
-    videoQuotaDaily: 318742,
-    defaultChannelName: 'Main $1 channel'
-  },
-  videoChannels: {
-    maxPerUser: 24
-  },
-  transcoding: {
-    enabled: true,
-    remoteRunners: {
-      enabled: true
-    },
-    originalFile: {
-      keep: true
+    cache: {
+      previews: {
+        size: 2
+      },
+      captions: {
+        size: 3
+      },
+      torrents: {
+        size: 4
+      },
+      storyboards: {
+        size: 5
+      }
     },
-    allowAdditionalExtensions: true,
-    allowAudioFiles: true,
-    threads: 1,
-    concurrency: 3,
-    profile: 'vod_profile',
-    resolutions: {
-      '0p': false,
-      '144p': false,
-      '240p': false,
-      '360p': true,
-      '480p': true,
-      '720p': false,
-      '1080p': false,
-      '1440p': false,
-      '2160p': false
+    signup: {
+      enabled: false,
+      limit: 5,
+      requiresApproval: false,
+      requiresEmailVerification: false,
+      minimumAge: 10
     },
-    alwaysTranscodeOriginalResolution: false,
-    webVideos: {
-      enabled: true
+    admin: {
+      email: `admin${server.internalServerNumber}@example.com`
     },
-    hls: {
-      enabled: false
-    }
-  },
-  live: {
-    enabled: true,
-    allowReplay: true,
-    latencySetting: {
+    contactForm: {
       enabled: false
     },
-    maxDuration: 5000,
-    maxInstanceLives: -1,
-    maxUserLives: 10,
+    user: {
+      history: {
+        videos: {
+          enabled: false
+        }
+      },
+      videoQuota: 5242881,
+      videoQuotaDaily: 318742,
+      defaultChannelName: 'Main $1 channel'
+    },
+    videoChannels: {
+      maxPerUser: 24
+    },
     transcoding: {
       enabled: true,
       remoteRunners: {
         enabled: true
       },
-      threads: 4,
-      profile: 'live_profile',
+      originalFile: {
+        keep: true
+      },
+      allowAdditionalExtensions: true,
+      allowAudioFiles: true,
+      threads: 1,
+      concurrency: 3,
+      profile: 'vod_profile',
       resolutions: {
-        '144p': true,
-        '240p': true,
+        '0p': false,
+        '144p': false,
+        '240p': false,
         '360p': true,
         '480p': true,
-        '720p': true,
-        '1080p': true,
-        '1440p': true,
-        '2160p': true
+        '720p': false,
+        '1080p': false,
+        '1440p': false,
+        '2160p': false
       },
-      alwaysTranscodeOriginalResolution: false
-    }
-  },
-  videoStudio: {
-    enabled: true,
-    remoteRunners: {
-      enabled: true
-    }
-  },
-  videoFile: {
-    update: {
-      enabled: true
-    }
-  },
-  import: {
-    videos: {
-      concurrency: 4,
-      http: {
-        enabled: false
+      alwaysTranscodeOriginalResolution: false,
+      webVideos: {
+        enabled: true
       },
-      torrent: {
+      hls: {
         enabled: false
       }
     },
-    videoChannelSynchronization: {
-      enabled: false,
-      maxPerUser: 10
-    },
-    users: {
-      enabled: false
-    }
-  },
-  trending: {
-    videos: {
-      algorithms: {
-        enabled: [ 'hot', 'most-viewed', 'most-liked' ],
-        default: 'hot'
+    live: {
+      enabled: true,
+      allowReplay: true,
+      latencySetting: {
+        enabled: false
+      },
+      maxDuration: 5000,
+      maxInstanceLives: -1,
+      maxUserLives: 10,
+      transcoding: {
+        enabled: true,
+        remoteRunners: {
+          enabled: true
+        },
+        threads: 4,
+        profile: 'live_profile',
+        resolutions: {
+          '144p': true,
+          '240p': true,
+          '360p': true,
+          '480p': true,
+          '720p': true,
+          '1080p': true,
+          '1440p': true,
+          '2160p': true
+        },
+        alwaysTranscodeOriginalResolution: false
       }
-    }
-  },
-  autoBlacklist: {
-    videos: {
-      ofUsers: {
+    },
+    videoStudio: {
+      enabled: true,
+      remoteRunners: {
         enabled: true
       }
-    }
-  },
-  followers: {
-    instance: {
-      enabled: false,
-      manualApproval: true
-    }
-  },
-  followings: {
-    instance: {
-      autoFollowBack: {
+    },
+    videoFile: {
+      update: {
         enabled: true
+      }
+    },
+    import: {
+      videos: {
+        concurrency: 4,
+        http: {
+          enabled: false
+        },
+        torrent: {
+          enabled: false
+        }
       },
-      autoFollowIndex: {
-        enabled: true,
-        indexUrl: 'https://updated.example.com'
+      videoChannelSynchronization: {
+        enabled: false,
+        maxPerUser: 10
+      },
+      users: {
+        enabled: false
+      }
+    },
+    trending: {
+      videos: {
+        algorithms: {
+          enabled: [ 'hot', 'most-viewed', 'most-liked' ],
+          default: 'hot'
+        }
       }
-    }
-  },
-  broadcastMessage: {
-    enabled: true,
-    level: 'error',
-    message: 'super bad message',
-    dismissable: true
-  },
-  search: {
-    remoteUri: {
-      anonymous: true,
-      users: true
     },
-    searchIndex: {
+    autoBlacklist: {
+      videos: {
+        ofUsers: {
+          enabled: true
+        }
+      }
+    },
+    followers: {
+      instance: {
+        enabled: false,
+        manualApproval: true
+      }
+    },
+    followings: {
+      instance: {
+        autoFollowBack: {
+          enabled: true
+        },
+        autoFollowIndex: {
+          enabled: true,
+          indexUrl: 'https://updated.example.com'
+        }
+      }
+    },
+    broadcastMessage: {
       enabled: true,
-      url: 'https://search.joinpeertube.org',
-      disableLocalSearch: true,
-      isDefaultSearch: true
-    }
-  },
-  storyboards: {
-    enabled: false
-  },
-  export: {
-    users: {
-      enabled: false,
-      exportExpiration: 43,
-      maxUserVideoQuota: 42
+      level: 'error',
+      message: 'super bad message',
+      dismissable: true
+    },
+    search: {
+      remoteUri: {
+        anonymous: true,
+        users: true
+      },
+      searchIndex: {
+        enabled: true,
+        url: 'https://search.joinpeertube.org',
+        disableLocalSearch: true,
+        isDefaultSearch: true
+      }
+    },
+    storyboards: {
+      enabled: false
+    },
+    export: {
+      users: {
+        enabled: false,
+        exportExpiration: 43,
+        maxUserVideoQuota: 42
+      }
     }
   }
 }
 
 describe('Test static config', function () {
-  let server: PeerTubeServer = null
+  let server: PeerTubeServer
 
   before(async function () {
     this.timeout(30000)
@@ -393,7 +395,7 @@ describe('Test static config', function () {
   })
 
   it('Should error when client tries to update', async function () {
-    await server.config.updateCustomConfig({ newCustomConfig, expectedStatus: 405 })
+    await server.config.updateCustomConfig({ newCustomConfig: buildNewCustomConfig(server), expectedStatus: 405 })
   })
 
   after(async function () {
@@ -464,10 +466,10 @@ describe('Test config', function () {
     })
 
     it('Should update the customized configuration', async function () {
-      await server.config.updateCustomConfig({ newCustomConfig })
+      await server.config.updateCustomConfig({ newCustomConfig: buildNewCustomConfig(server) })
 
       const data = await server.config.getCustomConfig()
-      expect(data).to.deep.equal(newCustomConfig)
+      expect(data).to.deep.equal(buildNewCustomConfig(server))
     })
 
     it('Should have the correct updated video allowed extensions', async function () {
@@ -499,7 +501,7 @@ describe('Test config', function () {
 
       const data = await server.config.getCustomConfig()
 
-      expect(data).to.deep.equal(newCustomConfig)
+      expect(data).to.deep.equal(buildNewCustomConfig(server))
     })
 
     it('Should fetch the about information', async function () {