diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-19 17:30:41 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | 89cd12756035a146bbcc4db78cd3cd64f2f3d88d (patch) | |
tree | 896cd9fca1e0baa969b1f7a5b398ec1602761661 /server/tests/plugins/action-hooks.ts | |
parent | 09071200c73f5358e1d0bfb61a274e4f2c4ec52b (diff) | |
download | PeerTube-89cd12756035a146bbcc4db78cd3cd64f2f3d88d.tar.gz PeerTube-89cd12756035a146bbcc4db78cd3cd64f2f3d88d.tar.zst PeerTube-89cd12756035a146bbcc4db78cd3cd64f2f3d88d.zip |
Add hook filters tests
Diffstat (limited to 'server/tests/plugins/action-hooks.ts')
-rw-r--r-- | server/tests/plugins/action-hooks.ts | 91 |
1 files changed, 83 insertions, 8 deletions
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts index 93dc57d09..2a941148a 100644 --- a/server/tests/plugins/action-hooks.ts +++ b/server/tests/plugins/action-hooks.ts | |||
@@ -2,26 +2,101 @@ | |||
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, | ||
16 | installPlugin, removeVideo, | ||
17 | setAccessTokensToServers, | ||
18 | updateVideo, | ||
19 | uploadVideo, | ||
20 | viewVideo | ||
21 | } from '../../../shared/extra-utils' | ||
7 | 22 | ||
8 | const expect = chai.expect | 23 | const expect = chai.expect |
9 | 24 | ||
10 | describe('Test plugin action hooks', function () { | 25 | describe('Test plugin action hooks', function () { |
11 | let server: ServerInfo | 26 | let servers: ServerInfo[] |
27 | let videoUUID: string | ||
28 | let threadId: number | ||
29 | |||
30 | function checkHook (hook: string) { | ||
31 | return waitUntilLog(servers[0], 'Run hook ' + hook) | ||
32 | } | ||
12 | 33 | ||
13 | before(async function () { | 34 | before(async function () { |
14 | this.timeout(30000) | 35 | this.timeout(30000) |
15 | server = await flushAndRunServer(1) | ||
16 | 36 | ||
17 | await setAccessTokensToServers([ server ]) | 37 | servers = await flushAndRunMultipleServers(2) |
38 | await setAccessTokensToServers(servers) | ||
39 | |||
40 | await installPlugin({ | ||
41 | url: servers[0].url, | ||
42 | accessToken: servers[0].accessToken, | ||
43 | path: getPluginTestPath() | ||
44 | }) | ||
45 | |||
46 | await killallServers([ servers[0] ]) | ||
47 | |||
48 | await reRunServer(servers[0]) | ||
18 | }) | 49 | }) |
19 | 50 | ||
20 | it('Should execute ', async function () { | 51 | it('Should run action:application.listening', async function () { |
21 | // empty | 52 | await checkHook('action:application.listening') |
53 | }) | ||
54 | |||
55 | it('Should run action:api.video.uploaded', async function () { | ||
56 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' }) | ||
57 | videoUUID = res.body.video.uuid | ||
58 | |||
59 | await checkHook('action:api.video.uploaded') | ||
60 | }) | ||
61 | |||
62 | it('Should run action:api.video.updated', async function () { | ||
63 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video updated' }) | ||
64 | |||
65 | await checkHook('action:api.video.updated') | ||
66 | }) | ||
67 | |||
68 | it('Should run action:api.video.viewed', async function () { | ||
69 | await viewVideo(servers[0].url, videoUUID) | ||
70 | |||
71 | await checkHook('action:api.video.viewed') | ||
72 | }) | ||
73 | |||
74 | it('Should run action:api.video-thread.created', async function () { | ||
75 | const res = await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'thread') | ||
76 | threadId = res.body.comment.id | ||
77 | |||
78 | await checkHook('action:api.video-thread.created') | ||
79 | }) | ||
80 | |||
81 | it('Should run action:api.video-comment-reply.created', async function () { | ||
82 | await addVideoCommentReply(servers[0].url, servers[0].accessToken, videoUUID, threadId, 'reply') | ||
83 | |||
84 | await checkHook('action:api.video-comment-reply.created') | ||
85 | }) | ||
86 | |||
87 | it('Should run action:api.video-comment.deleted', async function () { | ||
88 | await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId) | ||
89 | |||
90 | await checkHook('action:api.video-comment.deleted') | ||
91 | }) | ||
92 | |||
93 | it('Should run action:api.video.deleted', async function () { | ||
94 | await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) | ||
95 | |||
96 | await checkHook('action:api.video.deleted') | ||
22 | }) | 97 | }) |
23 | 98 | ||
24 | after(async function () { | 99 | after(async function () { |
25 | await cleanupTests([ server ]) | 100 | await cleanupTests(servers) |
26 | }) | 101 | }) |
27 | }) | 102 | }) |