diff options
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 | }) |