diff options
Diffstat (limited to 'server/tests/plugins/filter-hooks.ts')
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 500728712..4fc2c437b 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -2,26 +2,79 @@ | |||
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' | 5 | import { |
6 | import { setAccessTokensToServers } from '../../../shared/extra-utils' | 6 | cleanupTests, |
7 | flushAndRunMultipleServers, | ||
8 | flushAndRunServer, killallServers, reRunServer, | ||
9 | ServerInfo, | ||
10 | waitUntilLog | ||
11 | } from '../../../shared/extra-utils/server/servers' | ||
12 | import { | ||
13 | addVideoCommentReply, | ||
14 | addVideoCommentThread, deleteVideoComment, | ||
15 | getPluginTestPath, getVideosList, | ||
16 | installPlugin, removeVideo, | ||
17 | setAccessTokensToServers, | ||
18 | updateVideo, | ||
19 | uploadVideo, | ||
20 | viewVideo, | ||
21 | getVideosListPagination, getVideo | ||
22 | } from '../../../shared/extra-utils' | ||
7 | 23 | ||
8 | const expect = chai.expect | 24 | const expect = chai.expect |
9 | 25 | ||
10 | describe('Test plugin filter hooks', function () { | 26 | describe('Test plugin filter hooks', function () { |
11 | let server: ServerInfo | 27 | let servers: ServerInfo[] |
28 | let videoUUID: string | ||
29 | let threadId: number | ||
12 | 30 | ||
13 | before(async function () { | 31 | before(async function () { |
14 | this.timeout(30000) | 32 | this.timeout(30000) |
15 | server = await flushAndRunServer(1) | ||
16 | 33 | ||
17 | await setAccessTokensToServers([ server ]) | 34 | servers = await flushAndRunMultipleServers(2) |
35 | await setAccessTokensToServers(servers) | ||
36 | |||
37 | await installPlugin({ | ||
38 | url: servers[0].url, | ||
39 | accessToken: servers[0].accessToken, | ||
40 | path: getPluginTestPath() | ||
41 | }) | ||
42 | |||
43 | await installPlugin({ | ||
44 | url: servers[0].url, | ||
45 | accessToken: servers[0].accessToken, | ||
46 | path: getPluginTestPath('-two') | ||
47 | }) | ||
48 | |||
49 | for (let i = 0; i < 10; i++) { | ||
50 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'default video ' + i }) | ||
51 | } | ||
52 | |||
53 | const res = await getVideosList(servers[0].url) | ||
54 | videoUUID = res.body.data[0].uuid | ||
18 | }) | 55 | }) |
19 | 56 | ||
20 | it('Should execute ', async function () { | 57 | it('Should run filter:api.videos.list.params hook', async function () { |
21 | // empty | 58 | const res = await getVideosListPagination(servers[0].url, 0, 2) |
59 | |||
60 | // 2 plugins do +1 to the count parameter | ||
61 | expect(res.body.data).to.have.lengthOf(4) | ||
62 | }) | ||
63 | |||
64 | it('Should run filter:api.videos.list.result', async function () { | ||
65 | const res = await getVideosListPagination(servers[0].url, 0, 0) | ||
66 | |||
67 | // Plugin do +1 to the total result | ||
68 | expect(res.body.total).to.equal(11) | ||
69 | }) | ||
70 | |||
71 | it('Should run filter:api.video.get.result', async function () { | ||
72 | const res = await getVideo(servers[0].url, videoUUID) | ||
73 | |||
74 | expect(res.body.name).to.contain('<3') | ||
22 | }) | 75 | }) |
23 | 76 | ||
24 | after(async function () { | 77 | after(async function () { |
25 | await cleanupTests([ server ]) | 78 | await cleanupTests(servers) |
26 | }) | 79 | }) |
27 | }) | 80 | }) |