aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins/action-hooks.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/plugins/action-hooks.ts')
-rw-r--r--server/tests/plugins/action-hooks.ts43
1 files changed, 33 insertions, 10 deletions
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts
index ca57a4b51..ac9f2cea5 100644
--- a/server/tests/plugins/action-hooks.ts
+++ b/server/tests/plugins/action-hooks.ts
@@ -1,18 +1,12 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { 4import { ServerHookName, VideoPrivacy } from '@shared/models'
5 cleanupTests,
6 flushAndRunMultipleServers,
7 killallServers,
8 reRunServer,
9 ServerInfo,
10 waitUntilLog
11} from '../../../shared/extra-utils/server/servers'
12import { 5import {
13 addVideoCommentReply, 6 addVideoCommentReply,
14 addVideoCommentThread, 7 addVideoCommentThread,
15 blockUser, 8 blockUser,
9 createLive,
16 createUser, 10 createUser,
17 deleteVideoComment, 11 deleteVideoComment,
18 getPluginTestPath, 12 getPluginTestPath,
@@ -20,6 +14,7 @@ import {
20 registerUser, 14 registerUser,
21 removeUser, 15 removeUser,
22 setAccessTokensToServers, 16 setAccessTokensToServers,
17 setDefaultVideoChannel,
23 unblockUser, 18 unblockUser,
24 updateUser, 19 updateUser,
25 updateVideo, 20 updateVideo,
@@ -27,13 +22,21 @@ import {
27 userLogin, 22 userLogin,
28 viewVideo 23 viewVideo
29} from '../../../shared/extra-utils' 24} from '../../../shared/extra-utils'
25import {
26 cleanupTests,
27 flushAndRunMultipleServers,
28 killallServers,
29 reRunServer,
30 ServerInfo,
31 waitUntilLog
32} from '../../../shared/extra-utils/server/servers'
30 33
31describe('Test plugin action hooks', function () { 34describe('Test plugin action hooks', function () {
32 let servers: ServerInfo[] 35 let servers: ServerInfo[]
33 let videoUUID: string 36 let videoUUID: string
34 let threadId: number 37 let threadId: number
35 38
36 function checkHook (hook: string) { 39 function checkHook (hook: ServerHookName) {
37 return waitUntilLog(servers[0], 'Run hook ' + hook) 40 return waitUntilLog(servers[0], 'Run hook ' + hook)
38 } 41 }
39 42
@@ -42,6 +45,7 @@ describe('Test plugin action hooks', function () {
42 45
43 servers = await flushAndRunMultipleServers(2) 46 servers = await flushAndRunMultipleServers(2)
44 await setAccessTokensToServers(servers) 47 await setAccessTokensToServers(servers)
48 await setDefaultVideoChannel(servers)
45 49
46 await installPlugin({ 50 await installPlugin({
47 url: servers[0].url, 51 url: servers[0].url,
@@ -51,7 +55,11 @@ describe('Test plugin action hooks', function () {
51 55
52 killallServers([ servers[0] ]) 56 killallServers([ servers[0] ])
53 57
54 await reRunServer(servers[0]) 58 await reRunServer(servers[0], {
59 live: {
60 enabled: true
61 }
62 })
55 }) 63 })
56 64
57 describe('Application hooks', function () { 65 describe('Application hooks', function () {
@@ -81,6 +89,21 @@ describe('Test plugin action hooks', function () {
81 }) 89 })
82 }) 90 })
83 91
92 describe('Live hooks', function () {
93
94 it('Should run action:api.live-video.created', async function () {
95 const attributes = {
96 name: 'live',
97 privacy: VideoPrivacy.PUBLIC,
98 channelId: servers[0].videoChannel.id
99 }
100
101 await createLive(servers[0].url, servers[0].accessToken, attributes)
102
103 await checkHook('action:api.live-video.created')
104 })
105 })
106
84 describe('Comments hooks', function () { 107 describe('Comments hooks', function () {
85 it('Should run action:api.video-thread.created', async function () { 108 it('Should run action:api.video-thread.created', async function () {
86 const res = await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'thread') 109 const res = await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'thread')