diff options
author | Chocobozzz <me@florianbigard.com> | 2021-01-20 15:28:34 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-01-20 15:28:34 +0100 |
commit | a4d2ca071514b4838544f2fd7229d2e8cb9da0d4 (patch) | |
tree | 3fd3b95b38e3032197303d794d505ec9754b95e6 /server/tests | |
parent | 70fdff3d4e140d19587e7ea9e40c021185b06a9a (diff) | |
download | PeerTube-a4d2ca071514b4838544f2fd7229d2e8cb9da0d4.tar.gz PeerTube-a4d2ca071514b4838544f2fd7229d2e8cb9da0d4.tar.zst PeerTube-a4d2ca071514b4838544f2fd7229d2e8cb9da0d4.zip |
Add user video list hooks
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test/main.js | 10 | ||||
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 15 |
2 files changed, 25 insertions, 0 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js index e5a9f8df5..305d92002 100644 --- a/server/tests/fixtures/peertube-plugin-test/main.js +++ b/server/tests/fixtures/peertube-plugin-test/main.js | |||
@@ -60,6 +60,16 @@ async function register ({ registerHook, registerSetting, settingsManager, stora | |||
60 | }) | 60 | }) |
61 | 61 | ||
62 | registerHook({ | 62 | registerHook({ |
63 | target: 'filter:api.user.me.videos.list.params', | ||
64 | handler: obj => addToCount(obj, 4) | ||
65 | }) | ||
66 | |||
67 | registerHook({ | ||
68 | target: 'filter:api.user.me.videos.list.result', | ||
69 | handler: obj => addToTotal(obj, 4) | ||
70 | }) | ||
71 | |||
72 | registerHook({ | ||
63 | target: 'filter:api.video.get.result', | 73 | target: 'filter:api.video.get.result', |
64 | handler: video => { | 74 | handler: video => { |
65 | video.name += ' <3' | 75 | video.name += ' <3' |
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index cdde6cd30..d88170201 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -10,6 +10,7 @@ import { | |||
10 | doubleFollow, | 10 | doubleFollow, |
11 | getAccountVideos, | 11 | getAccountVideos, |
12 | getConfig, | 12 | getConfig, |
13 | getMyVideos, | ||
13 | getPluginTestPath, | 14 | getPluginTestPath, |
14 | getVideo, | 15 | getVideo, |
15 | getVideoChannelVideos, | 16 | getVideoChannelVideos, |
@@ -121,6 +122,20 @@ describe('Test plugin filter hooks', function () { | |||
121 | expect(res.body.total).to.equal(13) | 122 | expect(res.body.total).to.equal(13) |
122 | }) | 123 | }) |
123 | 124 | ||
125 | it('Should run filter:api.user.me.videos.list.params', async function () { | ||
126 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 2) | ||
127 | |||
128 | // 1 plugin do +4 to the count parameter | ||
129 | expect(res.body.data).to.have.lengthOf(6) | ||
130 | }) | ||
131 | |||
132 | it('Should run filter:api.user.me.videos.list.result', async function () { | ||
133 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 2) | ||
134 | |||
135 | // Plugin do +4 to the total result | ||
136 | expect(res.body.total).to.equal(14) | ||
137 | }) | ||
138 | |||
124 | it('Should run filter:api.video.get.result', async function () { | 139 | it('Should run filter:api.video.get.result', async function () { |
125 | const res = await getVideo(servers[0].url, videoUUID) | 140 | const res = await getVideo(servers[0].url, videoUUID) |
126 | 141 | ||