From d1aed103539e2e53418a44716f8f2b1603cd339f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 21 Jul 2021 16:13:20 +0200 Subject: Add overviews filter hook tests --- server/tests/fixtures/peertube-plugin-test/main.js | 9 ++++++--- server/tests/plugins/filter-hooks.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'server/tests') diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js index f8e6f0b98..db405ff31 100644 --- a/server/tests/fixtures/peertube-plugin-test/main.js +++ b/server/tests/fixtures/peertube-plugin-test/main.js @@ -234,7 +234,7 @@ async function register ({ registerHook, registerSetting, settingsManager, stora }) { - const searchHooks = [ + const filterHooks = [ 'filter:api.search.videos.local.list.params', 'filter:api.search.videos.local.list.result', 'filter:api.search.videos.index.list.params', @@ -246,10 +246,13 @@ async function register ({ registerHook, registerSetting, settingsManager, stora 'filter:api.search.video-playlists.local.list.params', 'filter:api.search.video-playlists.local.list.result', 'filter:api.search.video-playlists.index.list.params', - 'filter:api.search.video-playlists.index.list.result' + 'filter:api.search.video-playlists.index.list.result', + + 'filter:api.overviews.videos.list.params', + 'filter:api.overviews.videos.list.result' ] - for (const h of searchHooks) { + for (const h of filterHooks) { registerHook({ target: h, handler: (obj) => { diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index c00ac8f91..02915f08c 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts @@ -255,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) { -- cgit v1.2.3