aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-10 13:49:19 +0100
committerChocobozzz <me@florianbigard.com>2021-12-10 13:51:44 +0100
commitd17d743051c5716e1e08cd8870d718cfd6a57f0c (patch)
tree2f8c8d1a08467f35c5ede18001fc18cb2bafafef /server/tests
parent8cf43a6524d354fbfa0f0eaf789e8d4756bd25d6 (diff)
downloadPeerTube-d17d743051c5716e1e08cd8870d718cfd6a57f0c.tar.gz
PeerTube-d17d743051c5716e1e08cd8870d718cfd6a57f0c.tar.zst
PeerTube-d17d743051c5716e1e08cd8870d718cfd6a57f0c.zip
Add upload/import/go live video attributes hooks
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/fixtures/peertube-plugin-test/main.js15
-rw-r--r--server/tests/plugins/filter-hooks.ts59
2 files changed, 74 insertions, 0 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js
index aba415d1e..04e059848 100644
--- a/server/tests/fixtures/peertube-plugin-test/main.js
+++ b/server/tests/fixtures/peertube-plugin-test/main.js
@@ -240,6 +240,21 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
240 } 240 }
241 }) 241 })
242 242
243 // Upload/import/live attributes
244 for (const target of [
245 'filter:api.video.upload.video-attribute.result',
246 'filter:api.video.import-url.video-attribute.result',
247 'filter:api.video.import-torrent.video-attribute.result',
248 'filter:api.video.live.video-attribute.result'
249 ]) {
250 registerHook({
251 target,
252 handler: (result) => {
253 return { ...result, description: result.description + ' - ' + target }
254 }
255 })
256 }
257
243 { 258 {
244 const filterHooks = [ 259 const filterHooks = [
245 'filter:api.search.videos.local.list.params', 260 'filter:api.search.videos.local.list.params',
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index 80014566b..ff2afc56b 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -537,6 +537,65 @@ describe('Test plugin filter hooks', function () {
537 }) 537 })
538 }) 538 })
539 539
540 describe('Upload/import/live attributes filters', function () {
541
542 before(async function () {
543 await servers[0].config.enableLive({ transcoding: false, allowReplay: false })
544 await servers[0].config.enableImports()
545 await servers[0].config.disableTranscoding()
546 })
547
548 it('Should run filter:api.video.upload.video-attribute.result', async function () {
549 for (const mode of [ 'legacy' as 'legacy', 'resumable' as 'resumable' ]) {
550 const { id } = await servers[0].videos.upload({ attributes: { name: 'video', description: 'upload' }, mode })
551
552 const video = await servers[0].videos.get({ id })
553 expect(video.description).to.equal('upload - filter:api.video.upload.video-attribute.result')
554 }
555 })
556
557 it('Should run filter:api.video.import-url.video-attribute.result', async function () {
558 const attributes = {
559 name: 'video',
560 description: 'import url',
561 channelId: servers[0].store.channel.id,
562 targetUrl: FIXTURE_URLS.goodVideo,
563 privacy: VideoPrivacy.PUBLIC
564 }
565 const { video: { id } } = await servers[0].imports.importVideo({ attributes })
566
567 const video = await servers[0].videos.get({ id })
568 expect(video.description).to.equal('import url - filter:api.video.import-url.video-attribute.result')
569 })
570
571 it('Should run filter:api.video.import-torrent.video-attribute.result', async function () {
572 const attributes = {
573 name: 'video',
574 description: 'import torrent',
575 channelId: servers[0].store.channel.id,
576 magnetUri: FIXTURE_URLS.magnet,
577 privacy: VideoPrivacy.PUBLIC
578 }
579 const { video: { id } } = await servers[0].imports.importVideo({ attributes })
580
581 const video = await servers[0].videos.get({ id })
582 expect(video.description).to.equal('import torrent - filter:api.video.import-torrent.video-attribute.result')
583 })
584
585 it('Should run filter:api.video.live.video-attribute.result', async function () {
586 const fields = {
587 name: 'live',
588 description: 'live',
589 channelId: servers[0].store.channel.id,
590 privacy: VideoPrivacy.PUBLIC
591 }
592 const { id } = await servers[0].live.create({ fields })
593
594 const video = await servers[0].videos.get({ id })
595 expect(video.description).to.equal('live - filter:api.video.live.video-attribute.result')
596 })
597 })
598
540 describe('Stats filters', function () { 599 describe('Stats filters', function () {
541 600
542 it('Should run filter:api.server.stats.get.result', async function () { 601 it('Should run filter:api.server.stats.get.result', async function () {