diff options
author | Chocobozzz <me@florianbigard.com> | 2023-03-10 15:08:56 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-03-10 15:19:33 +0100 |
commit | 96d00a997b9847f6796c02dbff01bca2c99385c6 (patch) | |
tree | db3048042f83b0b5f529bdb4723f1f99202c3a96 /server/tests | |
parent | 866b5d3f5230204d611a556260102996c1aefe10 (diff) | |
download | PeerTube-96d00a997b9847f6796c02dbff01bca2c99385c6.tar.gz PeerTube-96d00a997b9847f6796c02dbff01bca2c99385c6.tar.zst PeerTube-96d00a997b9847f6796c02dbff01bca2c99385c6.zip |
Add test on AP hooks
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test/main.js | 12 | ||||
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 17 |
2 files changed, 29 insertions, 0 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js index 8b918b634..89ca52625 100644 --- a/server/tests/fixtures/peertube-plugin-test/main.js +++ b/server/tests/fixtures/peertube-plugin-test/main.js | |||
@@ -208,6 +208,18 @@ async function register ({ registerHook, registerSetting, settingsManager, stora | |||
208 | // --------------------------------------------------------------------------- | 208 | // --------------------------------------------------------------------------- |
209 | 209 | ||
210 | registerHook({ | 210 | registerHook({ |
211 | target: 'filter:activity-pub.activity.context.build.result', | ||
212 | handler: context => context.concat([ 'https://example.com/new-context' ]) | ||
213 | }) | ||
214 | |||
215 | registerHook({ | ||
216 | target: 'filter:activity-pub.video.json-ld.build.result', | ||
217 | handler: (jsonld, { video }) => ({ ...jsonld, videoName: video.name }) | ||
218 | }) | ||
219 | |||
220 | // --------------------------------------------------------------------------- | ||
221 | |||
222 | registerHook({ | ||
211 | target: 'filter:api.video-threads.list.params', | 223 | target: 'filter:api.video-threads.list.params', |
212 | handler: obj => addToCount(obj) | 224 | handler: obj => addToCount(obj) |
213 | }) | 225 | }) |
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 6bd38cf65..3577fc022 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -14,6 +14,7 @@ import { | |||
14 | cleanupTests, | 14 | cleanupTests, |
15 | createMultipleServers, | 15 | createMultipleServers, |
16 | doubleFollow, | 16 | doubleFollow, |
17 | makeActivityPubGetRequest, | ||
17 | makeGetRequest, | 18 | makeGetRequest, |
18 | makeRawRequest, | 19 | makeRawRequest, |
19 | PeerTubeServer, | 20 | PeerTubeServer, |
@@ -846,6 +847,22 @@ describe('Test plugin filter hooks', function () { | |||
846 | }) | 847 | }) |
847 | }) | 848 | }) |
848 | 849 | ||
850 | describe('Activity Pub', function () { | ||
851 | |||
852 | it('Should run filter:activity-pub.activity.context.build.result', async function () { | ||
853 | const { body } = await makeActivityPubGetRequest(servers[0].url, '/w/' + videoUUID) | ||
854 | expect(body.type).to.equal('Video') | ||
855 | |||
856 | expect(body['@context'].some(c => c === 'https://example.com/new-context')).to.be.true | ||
857 | }) | ||
858 | |||
859 | it('Should run filter:activity-pub.video.json-ld.build.result', async function () { | ||
860 | const { body } = await makeActivityPubGetRequest(servers[0].url, '/w/' + videoUUID) | ||
861 | expect(body.name).to.equal('default video 0') | ||
862 | expect(body.videoName).to.equal('default video 0') | ||
863 | }) | ||
864 | }) | ||
865 | |||
849 | after(async function () { | 866 | after(async function () { |
850 | await cleanupTests(servers) | 867 | await cleanupTests(servers) |
851 | }) | 868 | }) |