Verified Commit d1aed103 authored by Chocobozzz's avatar Chocobozzz
Browse files

Add overviews filter hook tests

parent 64f9b91d
......@@ -109,7 +109,7 @@ async function getVideos (
res: express.Response,
where: { videoChannelId?: number, tagsOneOf?: string[], categoryOneOf?: number[] }
) {
let query = Object.assign({
const query = await Hooks.wrapObject({
start: 0,
count: 12,
sort: '-createdAt',
......@@ -117,10 +117,10 @@ async function getVideos (
nsfw: buildNSFWFilter(res),
user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
withFiles: false,
countVideos: false
}, where)
countVideos: false,
query = await Hooks.wrapObject(query, 'filter:api.overviews.videos.list.params')
...where
}, 'filter:api.overviews.videos.list.params')
const { data } = await Hooks.wrapPromiseFun(
VideoModel.listForApi,
......
......@@ -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) => {
......
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment