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.js10
-rw-r--r--server/tests/plugins/filter-hooks.ts17
2 files changed, 27 insertions, 0 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js
index 5b4d34f15..8b918b634 100644
--- a/server/tests/fixtures/peertube-plugin-test/main.js
+++ b/server/tests/fixtures/peertube-plugin-test/main.js
@@ -90,6 +90,16 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
90 }) 90 })
91 91
92 registerHook({ 92 registerHook({
93 target: 'filter:api.user.me.subscription-videos.list.params',
94 handler: obj => Object.assign({}, obj, { count: 1 })
95 })
96
97 registerHook({
98 target: 'filter:api.user.me.subscription-videos.list.result',
99 handler: obj => addToTotal(obj, 4)
100 })
101
102 registerHook({
93 target: 'filter:api.video.get.result', 103 target: 'filter:api.video.get.result',
94 handler: video => { 104 handler: video => {
95 video.name += ' <3' 105 video.name += ' <3'
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index 37eef6cf3..6bd38cf65 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -71,6 +71,9 @@ describe('Test plugin filter hooks', function () {
71 } 71 }
72 } 72 }
73 }) 73 })
74
75 // Root subscribes to itself
76 await servers[0].subscriptions.add({ targetUri: 'root_channel@' + servers[0].host })
74 }) 77 })
75 78
76 describe('Videos', function () { 79 describe('Videos', function () {
@@ -151,6 +154,20 @@ describe('Test plugin filter hooks', function () {
151 expect(total).to.equal(14) 154 expect(total).to.equal(14)
152 }) 155 })
153 156
157 it('Should run filter:api.user.me.subscription-videos.list.params', async function () {
158 const { data } = await servers[0].subscriptions.listVideos()
159
160 // 1 plugin set the count parameter to 1
161 expect(data).to.have.lengthOf(1)
162 })
163
164 it('Should run filter:api.user.me.subscription-videos.list.result', async function () {
165 const { total } = await servers[0].subscriptions.listVideos()
166
167 // Plugin do +4 to the total result
168 expect(total).to.equal(14)
169 })
170
154 it('Should run filter:api.video.get.result', async function () { 171 it('Should run filter:api.video.get.result', async function () {
155 const video = await servers[0].videos.get({ id: videoUUID }) 172 const video = await servers[0].videos.get({ id: videoUUID })
156 expect(video.name).to.contain('<3') 173 expect(video.name).to.contain('<3')