]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/plugins/filter-hooks.ts
Shorter live methods
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / filter-hooks.ts
index e2ec5457b8951485c8614cee5f21cb1fa13777a2..e938663da43435b566cba21722ab5d1db592356a 100644 (file)
@@ -7,14 +7,11 @@ import {
   addVideoCommentReply,
   addVideoCommentThread,
   cleanupTests,
-  createLive,
   createVideoPlaylist,
   doubleFollow,
   flushAndRunMultipleServers,
   getAccountVideos,
-  getConfig,
   getMyVideos,
-  getPluginTestPath,
   getVideo,
   getVideoChannelVideos,
   getVideoCommentThreads,
@@ -23,13 +20,12 @@ import {
   getVideosListPagination,
   getVideoThreadComments,
   getVideoWithToken,
-  installPlugin,
   makeRawRequest,
+  PluginsCommand,
   registerUser,
   ServerInfo,
   setAccessTokensToServers,
   setDefaultVideoChannel,
-  updateCustomSubConfig,
   updateVideo,
   uploadVideo,
   uploadVideoAndGetId,
@@ -38,7 +34,6 @@ import {
 } from '@shared/extra-utils'
 import { getGoodVideoUrl, getMyVideoImports, importVideo } from '@shared/extra-utils/videos/video-imports'
 import {
-  ServerConfig,
   VideoCommentThreadTree,
   VideoDetails,
   VideoImport,
@@ -63,17 +58,8 @@ describe('Test plugin filter hooks', function () {
     await setDefaultVideoChannel(servers)
     await doubleFollow(servers[0], servers[1])
 
-    await installPlugin({
-      url: servers[0].url,
-      accessToken: servers[0].accessToken,
-      path: getPluginTestPath()
-    })
-
-    await installPlugin({
-      url: servers[0].url,
-      accessToken: servers[0].accessToken,
-      path: getPluginTestPath('-filter-translations')
-    })
+    await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() })
+    await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
 
     for (let i = 0; i < 10; i++) {
       await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'default video ' + i })
@@ -82,13 +68,15 @@ describe('Test plugin filter hooks', function () {
     const res = await getVideosList(servers[0].url)
     videoUUID = res.body.data[0].uuid
 
-    await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
-      live: { enabled: true },
-      signup: { enabled: true },
-      import: {
-        videos: {
-          http: { enabled: true },
-          torrent: { enabled: true }
+    await servers[0].configCommand.updateCustomSubConfig({
+      newConfig: {
+        live: { enabled: true },
+        signup: { enabled: true },
+        import: {
+          videos: {
+            http: { enabled: true },
+            torrent: { enabled: true }
+          }
         }
       }
     })
@@ -167,7 +155,7 @@ describe('Test plugin filter hooks', function () {
       channelId: servers[0].videoChannel.id
     }
 
-    await createLive(servers[0].url, servers[0].accessToken, attributes, HttpStatusCode.FORBIDDEN_403)
+    await servers[0].liveCommand.create({ fields: attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
   })
 
   it('Should run filter:api.video.pre-import-url.accept.result', async function () {
@@ -354,8 +342,8 @@ describe('Test plugin filter hooks', function () {
   describe('Should run filter:api.user.signup.allowed.result', function () {
 
     it('Should run on config endpoint', async function () {
-      const res = await getConfig(servers[0].url)
-      expect((res.body as ServerConfig).signup.allowed).to.be.true
+      const body = await servers[0].configCommand.getConfig()
+      expect(body.signup.allowed).to.be.true
     })
 
     it('Should allow a signup', async function () {
@@ -375,13 +363,15 @@ describe('Test plugin filter hooks', function () {
     before(async function () {
       this.timeout(120000)
 
-      await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
-        transcoding: {
-          webtorrent: {
-            enabled: true
-          },
-          hls: {
-            enabled: true
+      await servers[0].configCommand.updateCustomSubConfig({
+        newConfig: {
+          transcoding: {
+            webtorrent: {
+              enabled: true
+            },
+            hls: {
+              enabled: true
+            }
           }
         }
       })
@@ -437,9 +427,11 @@ describe('Test plugin filter hooks', function () {
     before(async function () {
       this.timeout(60000)
 
-      await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
-        transcoding: {
-          enabled: false
+      await servers[0].configCommand.updateCustomSubConfig({
+        newConfig: {
+          transcoding: {
+            enabled: false
+          }
         }
       })
 
@@ -474,12 +466,14 @@ describe('Test plugin filter hooks', function () {
   describe('Search filters', function () {
 
     before(async function () {
-      await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
-        search: {
-          searchIndex: {
-            enabled: true,
-            isDefaultSearch: false,
-            disableLocalSearch: false
+      await servers[0].configCommand.updateCustomSubConfig({
+        newConfig: {
+          search: {
+            searchIndex: {
+              enabled: true,
+              isDefaultSearch: false,
+              disableLocalSearch: false
+            }
           }
         }
       })