From e2e0b645cdac3c705b1988fbb0eff723ad5e885d Mon Sep 17 00:00:00 2001 From: kontrollanten <6680299+kontrollanten@users.noreply.github.com> Date: Mon, 28 Jun 2021 09:22:15 +0200 Subject: Add video-playlist-element.created hook (#4196) * add playlists.videos.list.params/results hooks closes #4192 * Revert "add playlists.videos.list.params/results hooks" This reverts commit ebd822ca0b769d88dbc5ae0062b286238cbced92. * add video-playlist-element.created hook closes #4192 * test: add playlist-element.created * Fix tests Co-authored-by: Chocobozzz --- server/tests/plugins/action-hooks.ts | 40 +++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'server/tests/plugins/action-hooks.ts') diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts index ac9f2cea5..0f57ef7fe 100644 --- a/server/tests/plugins/action-hooks.ts +++ b/server/tests/plugins/action-hooks.ts @@ -1,13 +1,15 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' -import { ServerHookName, VideoPrivacy } from '@shared/models' +import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' import { addVideoCommentReply, addVideoCommentThread, + addVideoInPlaylist, blockUser, createLive, createUser, + createVideoPlaylist, deleteVideoComment, getPluginTestPath, installPlugin, @@ -69,6 +71,7 @@ describe('Test plugin action hooks', function () { }) describe('Videos hooks', function () { + it('Should run action:api.video.uploaded', async function () { const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' }) videoUUID = res.body.video.uuid @@ -177,6 +180,41 @@ describe('Test plugin action hooks', function () { }) }) + describe('Playlist hooks', function () { + let playlistId: number + let videoId: number + + before(async function () { + { + const res = await createVideoPlaylist({ + url: servers[0].url, + token: servers[0].accessToken, + playlistAttrs: { + displayName: 'My playlist', + privacy: VideoPlaylistPrivacy.PRIVATE + } + }) + playlistId = res.body.videoPlaylist.id + } + + { + const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'my super name' }) + videoId = res.body.video.id + } + }) + + it('Should run action:api.video-playlist-element.created', async function () { + await addVideoInPlaylist({ + url: servers[0].url, + token: servers[0].accessToken, + playlistId, + elementAttrs: { videoId } + }) + + await checkHook('action:api.video-playlist-element.created') + }) + }) + after(async function () { await cleanupTests(servers) }) -- cgit v1.2.3