diff options
author | kontrollanten <6680299+kontrollanten@users.noreply.github.com> | 2021-06-28 09:22:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-28 09:22:15 +0200 |
commit | e2e0b645cdac3c705b1988fbb0eff723ad5e885d (patch) | |
tree | 0e8d7d5d7bfbd5815f89e1444b693d5a7662a6a7 /server/tests | |
parent | 3e84ae325088320c49dd07de2d3a0d020151002e (diff) | |
download | PeerTube-e2e0b645cdac3c705b1988fbb0eff723ad5e885d.tar.gz PeerTube-e2e0b645cdac3c705b1988fbb0eff723ad5e885d.tar.zst PeerTube-e2e0b645cdac3c705b1988fbb0eff723ad5e885d.zip |
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 <me@florianbigard.com>
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test/main.js | 4 | ||||
-rw-r--r-- | server/tests/plugins/action-hooks.ts | 40 |
2 files changed, 42 insertions, 2 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js index 5e922ad1f..f8e6f0b98 100644 --- a/server/tests/fixtures/peertube-plugin-test/main.js +++ b/server/tests/fixtures/peertube-plugin-test/main.js | |||
@@ -19,7 +19,9 @@ async function register ({ registerHook, registerSetting, settingsManager, stora | |||
19 | 'action:api.user.created', | 19 | 'action:api.user.created', |
20 | 'action:api.user.deleted', | 20 | 'action:api.user.deleted', |
21 | 'action:api.user.updated', | 21 | 'action:api.user.updated', |
22 | 'action:api.user.oauth2-got-token' | 22 | 'action:api.user.oauth2-got-token', |
23 | |||
24 | 'action:api.video-playlist-element.created' | ||
23 | ] | 25 | ] |
24 | 26 | ||
25 | for (const h of actionHooks) { | 27 | for (const h of actionHooks) { |
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 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { ServerHookName, VideoPrivacy } from '@shared/models' | 4 | import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' |
5 | import { | 5 | import { |
6 | addVideoCommentReply, | 6 | addVideoCommentReply, |
7 | addVideoCommentThread, | 7 | addVideoCommentThread, |
8 | addVideoInPlaylist, | ||
8 | blockUser, | 9 | blockUser, |
9 | createLive, | 10 | createLive, |
10 | createUser, | 11 | createUser, |
12 | createVideoPlaylist, | ||
11 | deleteVideoComment, | 13 | deleteVideoComment, |
12 | getPluginTestPath, | 14 | getPluginTestPath, |
13 | installPlugin, | 15 | installPlugin, |
@@ -69,6 +71,7 @@ describe('Test plugin action hooks', function () { | |||
69 | }) | 71 | }) |
70 | 72 | ||
71 | describe('Videos hooks', function () { | 73 | describe('Videos hooks', function () { |
74 | |||
72 | it('Should run action:api.video.uploaded', async function () { | 75 | it('Should run action:api.video.uploaded', async function () { |
73 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' }) | 76 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' }) |
74 | videoUUID = res.body.video.uuid | 77 | videoUUID = res.body.video.uuid |
@@ -177,6 +180,41 @@ describe('Test plugin action hooks', function () { | |||
177 | }) | 180 | }) |
178 | }) | 181 | }) |
179 | 182 | ||
183 | describe('Playlist hooks', function () { | ||
184 | let playlistId: number | ||
185 | let videoId: number | ||
186 | |||
187 | before(async function () { | ||
188 | { | ||
189 | const res = await createVideoPlaylist({ | ||
190 | url: servers[0].url, | ||
191 | token: servers[0].accessToken, | ||
192 | playlistAttrs: { | ||
193 | displayName: 'My playlist', | ||
194 | privacy: VideoPlaylistPrivacy.PRIVATE | ||
195 | } | ||
196 | }) | ||
197 | playlistId = res.body.videoPlaylist.id | ||
198 | } | ||
199 | |||
200 | { | ||
201 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'my super name' }) | ||
202 | videoId = res.body.video.id | ||
203 | } | ||
204 | }) | ||
205 | |||
206 | it('Should run action:api.video-playlist-element.created', async function () { | ||
207 | await addVideoInPlaylist({ | ||
208 | url: servers[0].url, | ||
209 | token: servers[0].accessToken, | ||
210 | playlistId, | ||
211 | elementAttrs: { videoId } | ||
212 | }) | ||
213 | |||
214 | await checkHook('action:api.video-playlist-element.created') | ||
215 | }) | ||
216 | }) | ||
217 | |||
180 | after(async function () { | 218 | after(async function () { |
181 | await cleanupTests(servers) | 219 | await cleanupTests(servers) |
182 | }) | 220 | }) |