]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/plugins/filter-hooks.ts
Add filter:api.server.stats.get.result hook
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / filter-hooks.ts
index ba84dd27a16b061451e0de7e1350610aab5279c5..80014566bf53883f3e6fa4ae0ea60c05466f2142 100644 (file)
@@ -2,7 +2,6 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/models'
 import {
   cleanupTests,
   createMultipleServers,
@@ -15,7 +14,7 @@ import {
   setDefaultVideoChannel,
   waitJobs
 } from '@shared/extra-utils'
-import { VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
+import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
 
 const expect = chai.expect
 
@@ -256,6 +255,14 @@ describe('Test plugin filter hooks', function () {
     expect(thread.comment.text.endsWith(' <3')).to.be.true
   })
 
+  it('Should run filter:api.overviews.videos.list.{params,result}', async function () {
+    await servers[0].overviews.getVideos({ page: 1 })
+
+    // 3 because we get 3 samples per page
+    await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.params', 3)
+    await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.result', 3)
+  })
+
   describe('Should run filter:video.auto-blacklist.result', function () {
 
     async function checkIsBlacklisted (id: number | string, value: boolean) {
@@ -530,6 +537,16 @@ describe('Test plugin filter hooks', function () {
     })
   })
 
+  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)
   })