]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/plugins/filter-hooks.ts
Translated using Weblate (French (France) (fr_FR))
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / filter-hooks.ts
index 02915f08cb2f8199f383cdb778b618544f014c68..52ba396e559e9a255c500d7914fda3c99a1b7017 100644 (file)
@@ -2,19 +2,19 @@
 
 import 'mocha'
 import * as chai from 'chai'
+import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
 import {
   cleanupTests,
   createMultipleServers,
   doubleFollow,
-  FIXTURE_URLS,
   makeRawRequest,
   PeerTubeServer,
   PluginsCommand,
   setAccessTokensToServers,
   setDefaultVideoChannel,
   waitJobs
-} from '@shared/extra-utils'
-import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
+} from '@shared/server-commands'
+import { FIXTURE_URLS } from '../shared'
 
 const expect = chai.expect
 
@@ -537,6 +537,75 @@ describe('Test plugin filter hooks', function () {
     })
   })
 
+  describe('Upload/import/live attributes filters', function () {
+
+    before(async function () {
+      await servers[0].config.enableLive({ transcoding: false, allowReplay: false })
+      await servers[0].config.enableImports()
+      await servers[0].config.disableTranscoding()
+    })
+
+    it('Should run filter:api.video.upload.video-attribute.result', async function () {
+      for (const mode of [ 'legacy' as 'legacy', 'resumable' as 'resumable' ]) {
+        const { id } = await servers[0].videos.upload({ attributes: { name: 'video', description: 'upload' }, mode })
+
+        const video = await servers[0].videos.get({ id })
+        expect(video.description).to.equal('upload - filter:api.video.upload.video-attribute.result')
+      }
+    })
+
+    it('Should run filter:api.video.import-url.video-attribute.result', async function () {
+      const attributes = {
+        name: 'video',
+        description: 'import url',
+        channelId: servers[0].store.channel.id,
+        targetUrl: FIXTURE_URLS.goodVideo,
+        privacy: VideoPrivacy.PUBLIC
+      }
+      const { video: { id } } = await servers[0].imports.importVideo({ attributes })
+
+      const video = await servers[0].videos.get({ id })
+      expect(video.description).to.equal('import url - filter:api.video.import-url.video-attribute.result')
+    })
+
+    it('Should run filter:api.video.import-torrent.video-attribute.result', async function () {
+      const attributes = {
+        name: 'video',
+        description: 'import torrent',
+        channelId: servers[0].store.channel.id,
+        magnetUri: FIXTURE_URLS.magnet,
+        privacy: VideoPrivacy.PUBLIC
+      }
+      const { video: { id } } = await servers[0].imports.importVideo({ attributes })
+
+      const video = await servers[0].videos.get({ id })
+      expect(video.description).to.equal('import torrent - filter:api.video.import-torrent.video-attribute.result')
+    })
+
+    it('Should run filter:api.video.live.video-attribute.result', async function () {
+      const fields = {
+        name: 'live',
+        description: 'live',
+        channelId: servers[0].store.channel.id,
+        privacy: VideoPrivacy.PUBLIC
+      }
+      const { id } = await servers[0].live.create({ fields })
+
+      const video = await servers[0].videos.get({ id })
+      expect(video.description).to.equal('live - filter:api.video.live.video-attribute.result')
+    })
+  })
+
+  describe('Stats filters', function () {
+
+    it('Should run filter:api.server.stats.get.result', async function () {
+      const data = await servers[0].stats.get()
+
+      expect((data as any).customStats).to.equal(14)
+    })
+
+  })
+
   after(async function () {
     await cleanupTests(servers)
   })