diff options
Diffstat (limited to 'server/tests/plugins')
-rw-r--r-- | server/tests/plugins/action-hooks.ts | 40 | ||||
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 32 | ||||
-rw-r--r-- | server/tests/plugins/html-injection.ts | 2 | ||||
-rw-r--r-- | server/tests/plugins/plugin-helpers.ts | 2 | ||||
-rw-r--r-- | server/tests/plugins/translations.ts | 8 | ||||
-rw-r--r-- | server/tests/plugins/video-constants.ts | 6 |
6 files changed, 76 insertions, 14 deletions
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 | }) |
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 7d4f7abb4..644b41dea 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -8,6 +8,7 @@ import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-code | |||
8 | import { | 8 | import { |
9 | addVideoCommentReply, | 9 | addVideoCommentReply, |
10 | addVideoCommentThread, | 10 | addVideoCommentThread, |
11 | advancedVideoPlaylistSearch, | ||
11 | advancedVideosSearch, | 12 | advancedVideosSearch, |
12 | createLive, | 13 | createLive, |
13 | createVideoPlaylist, | 14 | createVideoPlaylist, |
@@ -38,6 +39,7 @@ import { | |||
38 | import { cleanupTests, flushAndRunMultipleServers, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' | 39 | import { cleanupTests, flushAndRunMultipleServers, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' |
39 | import { getGoodVideoUrl, getMyVideoImports, importVideo } from '../../../shared/extra-utils/videos/video-imports' | 40 | import { getGoodVideoUrl, getMyVideoImports, importVideo } from '../../../shared/extra-utils/videos/video-imports' |
40 | import { | 41 | import { |
42 | VideoCommentThreadTree, | ||
41 | VideoDetails, | 43 | VideoDetails, |
42 | VideoImport, | 44 | VideoImport, |
43 | VideoImportState, | 45 | VideoImportState, |
@@ -45,7 +47,6 @@ import { | |||
45 | VideoPlaylistPrivacy, | 47 | VideoPlaylistPrivacy, |
46 | VideoPrivacy | 48 | VideoPrivacy |
47 | } from '../../../shared/models/videos' | 49 | } from '../../../shared/models/videos' |
48 | import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model' | ||
49 | 50 | ||
50 | const expect = chai.expect | 51 | const expect = chai.expect |
51 | 52 | ||
@@ -71,7 +72,7 @@ describe('Test plugin filter hooks', function () { | |||
71 | await installPlugin({ | 72 | await installPlugin({ |
72 | url: servers[0].url, | 73 | url: servers[0].url, |
73 | accessToken: servers[0].accessToken, | 74 | accessToken: servers[0].accessToken, |
74 | path: getPluginTestPath('-two') | 75 | path: getPluginTestPath('-filter-translations') |
75 | }) | 76 | }) |
76 | 77 | ||
77 | for (let i = 0; i < 10; i++) { | 78 | for (let i = 0; i < 10; i++) { |
@@ -326,7 +327,7 @@ describe('Test plugin filter hooks', function () { | |||
326 | }) | 327 | }) |
327 | 328 | ||
328 | it('Should blacklist on remote upload', async function () { | 329 | it('Should blacklist on remote upload', async function () { |
329 | this.timeout(60000) | 330 | this.timeout(120000) |
330 | 331 | ||
331 | const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'remote please blacklist me' }) | 332 | const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'remote please blacklist me' }) |
332 | await waitJobs(servers) | 333 | await waitJobs(servers) |
@@ -335,7 +336,7 @@ describe('Test plugin filter hooks', function () { | |||
335 | }) | 336 | }) |
336 | 337 | ||
337 | it('Should blacklist on remote update', async function () { | 338 | it('Should blacklist on remote update', async function () { |
338 | this.timeout(60000) | 339 | this.timeout(120000) |
339 | 340 | ||
340 | const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video' }) | 341 | const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video' }) |
341 | await waitJobs(servers) | 342 | await waitJobs(servers) |
@@ -372,7 +373,7 @@ describe('Test plugin filter hooks', function () { | |||
372 | const downloadVideos: VideoDetails[] = [] | 373 | const downloadVideos: VideoDetails[] = [] |
373 | 374 | ||
374 | before(async function () { | 375 | before(async function () { |
375 | this.timeout(60000) | 376 | this.timeout(120000) |
376 | 377 | ||
377 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { | 378 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { |
378 | transcoding: { | 379 | transcoding: { |
@@ -525,6 +526,27 @@ describe('Test plugin filter hooks', function () { | |||
525 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.params', 1) | 526 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.params', 1) |
526 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.result', 1) | 527 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.result', 1) |
527 | }) | 528 | }) |
529 | |||
530 | it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () { | ||
531 | await advancedVideoPlaylistSearch(servers[0].url, { | ||
532 | search: 'Sun Jian' | ||
533 | }) | ||
534 | |||
535 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1) | ||
536 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.result', 1) | ||
537 | }) | ||
538 | |||
539 | it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () { | ||
540 | await advancedVideoPlaylistSearch(servers[0].url, { | ||
541 | search: 'Sun Jian', | ||
542 | searchTarget: 'search-index' | ||
543 | }) | ||
544 | |||
545 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1) | ||
546 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.result', 1) | ||
547 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.index.list.params', 1) | ||
548 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.index.list.result', 1) | ||
549 | }) | ||
528 | }) | 550 | }) |
529 | 551 | ||
530 | after(async function () { | 552 | after(async function () { |
diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts index 293c1df21..4fa8caa3a 100644 --- a/server/tests/plugins/html-injection.ts +++ b/server/tests/plugins/html-injection.ts | |||
@@ -15,7 +15,7 @@ import { | |||
15 | 15 | ||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
18 | describe('Test plugins HTML inection', function () { | 18 | describe('Test plugins HTML injection', function () { |
19 | let server: ServerInfo = null | 19 | let server: ServerInfo = null |
20 | 20 | ||
21 | before(async function () { | 21 | before(async function () { |
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index f72de8229..0296d6eb7 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts | |||
@@ -144,7 +144,7 @@ describe('Test plugin helpers', function () { | |||
144 | let videoUUIDServer1: string | 144 | let videoUUIDServer1: string |
145 | 145 | ||
146 | before(async function () { | 146 | before(async function () { |
147 | this.timeout(30000) | 147 | this.timeout(60000) |
148 | 148 | ||
149 | { | 149 | { |
150 | const res = await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' }) | 150 | const res = await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' }) |
diff --git a/server/tests/plugins/translations.ts b/server/tests/plugins/translations.ts index 8dc2043b8..9fd2ba1c5 100644 --- a/server/tests/plugins/translations.ts +++ b/server/tests/plugins/translations.ts | |||
@@ -31,7 +31,7 @@ describe('Test plugin translations', function () { | |||
31 | await installPlugin({ | 31 | await installPlugin({ |
32 | url: server.url, | 32 | url: server.url, |
33 | accessToken: server.accessToken, | 33 | accessToken: server.accessToken, |
34 | path: getPluginTestPath('-two') | 34 | path: getPluginTestPath('-filter-translations') |
35 | }) | 35 | }) |
36 | }) | 36 | }) |
37 | 37 | ||
@@ -48,7 +48,7 @@ describe('Test plugin translations', function () { | |||
48 | 'peertube-plugin-test': { | 48 | 'peertube-plugin-test': { |
49 | Hi: 'Coucou' | 49 | Hi: 'Coucou' |
50 | }, | 50 | }, |
51 | 'peertube-plugin-test-two': { | 51 | 'peertube-plugin-test-filter-translations': { |
52 | 'Hello world': 'Bonjour le monde' | 52 | 'Hello world': 'Bonjour le monde' |
53 | } | 53 | } |
54 | }) | 54 | }) |
@@ -58,14 +58,14 @@ describe('Test plugin translations', function () { | |||
58 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) | 58 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) |
59 | 59 | ||
60 | expect(res.body).to.deep.equal({ | 60 | expect(res.body).to.deep.equal({ |
61 | 'peertube-plugin-test-two': { | 61 | 'peertube-plugin-test-filter-translations': { |
62 | 'Hello world': 'Ciao, mondo!' | 62 | 'Hello world': 'Ciao, mondo!' |
63 | } | 63 | } |
64 | }) | 64 | }) |
65 | }) | 65 | }) |
66 | 66 | ||
67 | it('Should remove the plugin and remove the locales', async function () { | 67 | it('Should remove the plugin and remove the locales', async function () { |
68 | await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-two' }) | 68 | await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-filter-translations' }) |
69 | 69 | ||
70 | { | 70 | { |
71 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) | 71 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) |
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts index 5ee41fee1..eb014c596 100644 --- a/server/tests/plugins/video-constants.ts +++ b/server/tests/plugins/video-constants.ts | |||
@@ -32,7 +32,7 @@ describe('Test plugin altering video constants', function () { | |||
32 | await installPlugin({ | 32 | await installPlugin({ |
33 | url: server.url, | 33 | url: server.url, |
34 | accessToken: server.accessToken, | 34 | accessToken: server.accessToken, |
35 | path: getPluginTestPath('-three') | 35 | path: getPluginTestPath('-video-constants') |
36 | }) | 36 | }) |
37 | }) | 37 | }) |
38 | 38 | ||
@@ -45,6 +45,7 @@ describe('Test plugin altering video constants', function () { | |||
45 | 45 | ||
46 | expect(languages['al_bhed']).to.equal('Al Bhed') | 46 | expect(languages['al_bhed']).to.equal('Al Bhed') |
47 | expect(languages['al_bhed2']).to.equal('Al Bhed 2') | 47 | expect(languages['al_bhed2']).to.equal('Al Bhed 2') |
48 | expect(languages['al_bhed3']).to.not.exist | ||
48 | }) | 49 | }) |
49 | 50 | ||
50 | it('Should have updated categories', async function () { | 51 | it('Should have updated categories', async function () { |
@@ -116,7 +117,7 @@ describe('Test plugin altering video constants', function () { | |||
116 | }) | 117 | }) |
117 | 118 | ||
118 | it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () { | 119 | it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () { |
119 | await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-three' }) | 120 | await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-video-constants' }) |
120 | 121 | ||
121 | { | 122 | { |
122 | const res = await getVideoLanguages(server.url) | 123 | const res = await getVideoLanguages(server.url) |
@@ -127,6 +128,7 @@ describe('Test plugin altering video constants', function () { | |||
127 | 128 | ||
128 | expect(languages['al_bhed']).to.not.exist | 129 | expect(languages['al_bhed']).to.not.exist |
129 | expect(languages['al_bhed2']).to.not.exist | 130 | expect(languages['al_bhed2']).to.not.exist |
131 | expect(languages['al_bhed3']).to.not.exist | ||
130 | } | 132 | } |
131 | 133 | ||
132 | { | 134 | { |