aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/plugins')
-rw-r--r--server/tests/plugins/action-hooks.ts43
-rw-r--r--server/tests/plugins/filter-hooks.ts23
2 files changed, 56 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')
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index 4d354b68e..9939b8e6e 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -6,6 +6,7 @@ import { ServerConfig } from '@shared/models'
6import { 6import {
7 addVideoCommentReply, 7 addVideoCommentReply,
8 addVideoCommentThread, 8 addVideoCommentThread,
9 createLive,
9 doubleFollow, 10 doubleFollow,
10 getConfig, 11 getConfig,
11 getPluginTestPath, 12 getPluginTestPath,
@@ -19,6 +20,7 @@ import {
19 registerUser, 20 registerUser,
20 setAccessTokensToServers, 21 setAccessTokensToServers,
21 setDefaultVideoChannel, 22 setDefaultVideoChannel,
23 updateCustomSubConfig,
22 updateVideo, 24 updateVideo,
23 uploadVideo, 25 uploadVideo,
24 waitJobs 26 waitJobs
@@ -61,6 +63,17 @@ describe('Test plugin filter hooks', function () {
61 63
62 const res = await getVideosList(servers[0].url) 64 const res = await getVideosList(servers[0].url)
63 videoUUID = res.body.data[0].uuid 65 videoUUID = res.body.data[0].uuid
66
67 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
68 live: { enabled: true },
69 signup: { enabled: true },
70 import: {
71 videos: {
72 http: { enabled: true },
73 torrent: { enabled: true }
74 }
75 }
76 })
64 }) 77 })
65 78
66 it('Should run filter:api.videos.list.params', async function () { 79 it('Should run filter:api.videos.list.params', async function () {
@@ -87,6 +100,16 @@ describe('Test plugin filter hooks', function () {
87 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video with bad word' }, 403) 100 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video with bad word' }, 403)
88 }) 101 })
89 102
103 it('Should run filter:api.live-video.create.accept.result', async function () {
104 const attributes = {
105 name: 'video with bad word',
106 privacy: VideoPrivacy.PUBLIC,
107 channelId: servers[0].videoChannel.id
108 }
109
110 await createLive(servers[0].url, servers[0].accessToken, attributes, 403)
111 })
112
90 it('Should run filter:api.video.pre-import-url.accept.result', async function () { 113 it('Should run filter:api.video.pre-import-url.accept.result', async function () {
91 const baseAttributes = { 114 const baseAttributes = {
92 name: 'normal title', 115 name: 'normal title',