aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/fixtures/peertube-plugin-test/main.js12
-rw-r--r--server/tests/plugins/action-hooks.ts8
-rw-r--r--server/tests/plugins/filter-hooks.ts19
3 files changed, 38 insertions, 1 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js
index 17032f6d9..e16bf0ca3 100644
--- a/server/tests/fixtures/peertube-plugin-test/main.js
+++ b/server/tests/fixtures/peertube-plugin-test/main.js
@@ -9,6 +9,8 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
9 'action:api.video.uploaded', 9 'action:api.video.uploaded',
10 'action:api.video.viewed', 10 'action:api.video.viewed',
11 11
12 'action:api.video.file-updated',
13
12 'action:api.video-channel.created', 14 'action:api.video-channel.created',
13 'action:api.video-channel.updated', 15 'action:api.video-channel.updated',
14 'action:api.video-channel.deleted', 16 'action:api.video-channel.deleted',
@@ -161,6 +163,16 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
161 } 163 }
162 164
163 registerHook({ 165 registerHook({
166 target: 'filter:api.video.update-file.accept.result',
167 handler: ({ accepted }, { videoFile }) => {
168 if (!accepted) return { accepted: false }
169 if (videoFile.filename.includes('webm')) return { accepted: false, errorMessage: 'no webm' }
170
171 return { accepted: true }
172 }
173 })
174
175 registerHook({
164 target: 'filter:api.video.pre-import-url.accept.result', 176 target: 'filter:api.video.pre-import-url.accept.result',
165 handler: ({ accepted }, { videoImportBody }) => { 177 handler: ({ accepted }, { videoImportBody }) => {
166 if (!accepted) return { accepted: false } 178 if (!accepted) return { accepted: false }
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts
index 34b4e1891..773be0d76 100644
--- a/server/tests/plugins/action-hooks.ts
+++ b/server/tests/plugins/action-hooks.ts
@@ -40,6 +40,8 @@ describe('Test plugin action hooks', function () {
40 } 40 }
41 }) 41 })
42 42
43 await servers[0].config.enableFileUpdate()
44
43 await doubleFollow(servers[0], servers[1]) 45 await doubleFollow(servers[0], servers[1])
44 }) 46 })
45 47
@@ -70,6 +72,12 @@ describe('Test plugin action hooks', function () {
70 await checkHook('action:api.video.viewed') 72 await checkHook('action:api.video.viewed')
71 }) 73 })
72 74
75 it('Should run action:api.video.file-updated', async function () {
76 await servers[0].videos.replaceSourceFile({ videoId: videoUUID, fixture: 'video_short.mp4' })
77
78 await checkHook('action:api.video.file-updated')
79 })
80
73 it('Should run action:api.video.deleted', async function () { 81 it('Should run action:api.video.deleted', async function () {
74 await servers[0].videos.remove({ id: videoUUID }) 82 await servers[0].videos.remove({ id: videoUUID })
75 83
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index a75a8c8fa..8382b400f 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -64,6 +64,11 @@ describe('Test plugin filter hooks', function () {
64 newConfig: { 64 newConfig: {
65 live: { enabled: true }, 65 live: { enabled: true },
66 signup: { enabled: true }, 66 signup: { enabled: true },
67 videoFile: {
68 update: {
69 enabled: true
70 }
71 },
67 import: { 72 import: {
68 videos: { 73 videos: {
69 http: { enabled: true }, 74 http: { enabled: true },
@@ -178,7 +183,19 @@ describe('Test plugin filter hooks', function () {
178 describe('Video/live/import accept', function () { 183 describe('Video/live/import accept', function () {
179 184
180 it('Should run filter:api.video.upload.accept.result', async function () { 185 it('Should run filter:api.video.upload.accept.result', async function () {
181 await servers[0].videos.upload({ attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 186 const options = { attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
187 await servers[0].videos.upload({ mode: 'legacy', ...options })
188 await servers[0].videos.upload({ mode: 'resumable', ...options })
189 })
190
191 it('Should run filter:api.video.update-file.accept.result', async function () {
192 const res = await servers[0].videos.replaceSourceFile({
193 videoId: videoUUID,
194 fixture: 'video_short1.webm',
195 completedExpectedStatus: HttpStatusCode.FORBIDDEN_403
196 })
197
198 expect((res as any)?.error).to.equal('no webm')
182 }) 199 })
183 200
184 it('Should run filter:api.live-video.create.accept.result', async function () { 201 it('Should run filter:api.live-video.create.accept.result', async function () {