aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-03-24 18:37:55 +0100
committerChocobozzz <me@florianbigard.com>2023-03-24 18:37:55 +0100
commitd91ce83d392801fd592adeb08a7674b4017ffe82 (patch)
tree19d6d629a9b63ce01441e271b654acefcea1b636 /server/tests
parent80d7d180a368dc966bba383f3117ed131f5e0d42 (diff)
downloadPeerTube-d91ce83d392801fd592adeb08a7674b4017ffe82.tar.gz
PeerTube-d91ce83d392801fd592adeb08a7674b4017ffe82.tar.zst
PeerTube-d91ce83d392801fd592adeb08a7674b4017ffe82.zip
Add filter:html.client.json-ld.result hook
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/fixtures/peertube-plugin-test/main.js15
-rw-r--r--server/tests/plugins/filter-hooks.ts21
2 files changed, 36 insertions, 0 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js
index 84b479548..36dd08d27 100644
--- a/server/tests/fixtures/peertube-plugin-test/main.js
+++ b/server/tests/fixtures/peertube-plugin-test/main.js
@@ -312,6 +312,8 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
312 } 312 }
313 }) 313 })
314 314
315 // ---------------------------------------------------------------------------
316
315 registerHook({ 317 registerHook({
316 target: 'filter:html.embed.video.allowed.result', 318 target: 'filter:html.embed.video.allowed.result',
317 handler: (result, params) => { 319 handler: (result, params) => {
@@ -332,6 +334,19 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
332 } 334 }
333 }) 335 })
334 336
337 // ---------------------------------------------------------------------------
338
339 registerHook({
340 target: 'filter:html.client.json-ld.result',
341 handler: (jsonld, context) => {
342 if (!context || !context.video) return jsonld
343
344 return Object.assign(jsonld, { recordedAt: 'http://example.com/recordedAt' })
345 }
346 })
347
348 // ---------------------------------------------------------------------------
349
335 registerHook({ 350 registerHook({
336 target: 'filter:api.server.stats.get.result', 351 target: 'filter:api.server.stats.get.result',
337 handler: (result) => { 352 handler: (result) => {
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index 4d26ff8b7..43749b0b5 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -605,6 +605,27 @@ describe('Test plugin filter hooks', function () {
605 }) 605 })
606 }) 606 })
607 607
608 describe('Client HTML filters', function () {
609 let videoUUID: string
610
611 before(async function () {
612 this.timeout(60000)
613
614 const { uuid } = await servers[0].videos.quickUpload({ name: 'html video' })
615 videoUUID = uuid
616 })
617
618 it('Should run filter:html.client.json-ld.result', async function () {
619 const res = await makeGetRequest({ url: servers[0].url, path: '/w/' + videoUUID, expectedStatus: HttpStatusCode.OK_200 })
620 expect(res.text).to.contain('"recordedAt":"http://example.com/recordedAt"')
621 })
622
623 it('Should not run filter:html.client.json-ld.result with an account', async function () {
624 const res = await makeGetRequest({ url: servers[0].url, path: '/a/root', expectedStatus: HttpStatusCode.OK_200 })
625 expect(res.text).not.to.contain('"recordedAt":"http://example.com/recordedAt"')
626 })
627 })
628
608 describe('Search filters', function () { 629 describe('Search filters', function () {
609 630
610 before(async function () { 631 before(async function () {