aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins/action-hooks.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-13 14:23:01 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (patch)
tree7a166515e4d57a06eb3c08be569f106ed049988b /server/tests/plugins/action-hooks.ts
parentd0a0fa429d4651710ed951a3c11af0219e408964 (diff)
downloadPeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.tar.gz
PeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.tar.zst
PeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.zip
Introduce user command
Diffstat (limited to 'server/tests/plugins/action-hooks.ts')
-rw-r--r--server/tests/plugins/action-hooks.ts41
1 files changed, 14 insertions, 27 deletions
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts
index 84f4e8501..b156f6b60 100644
--- a/server/tests/plugins/action-hooks.ts
+++ b/server/tests/plugins/action-hooks.ts
@@ -1,28 +1,20 @@
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 { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
5import { 4import {
6 blockUser, 5 cleanupTests,
7 createUser, 6 flushAndRunMultipleServers,
7 killallServers,
8 PluginsCommand, 8 PluginsCommand,
9 registerUser, 9 reRunServer,
10 removeUser, 10 ServerInfo,
11 setAccessTokensToServers, 11 setAccessTokensToServers,
12 setDefaultVideoChannel, 12 setDefaultVideoChannel,
13 unblockUser,
14 updateUser,
15 updateVideo, 13 updateVideo,
16 uploadVideo, 14 uploadVideo,
17 viewVideo 15 viewVideo
18} from '../../../shared/extra-utils' 16} from '@shared/extra-utils'
19import { 17import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
20 cleanupTests,
21 flushAndRunMultipleServers,
22 killallServers,
23 reRunServer,
24 ServerInfo
25} from '../../../shared/extra-utils/server/servers'
26 18
27describe('Test plugin action hooks', function () { 19describe('Test plugin action hooks', function () {
28 let servers: ServerInfo[] 20 let servers: ServerInfo[]
@@ -119,19 +111,14 @@ describe('Test plugin action hooks', function () {
119 let userId: number 111 let userId: number
120 112
121 it('Should run action:api.user.registered', async function () { 113 it('Should run action:api.user.registered', async function () {
122 await registerUser(servers[0].url, 'registered_user', 'super_password') 114 await servers[0].usersCommand.register({ username: 'registered_user' })
123 115
124 await checkHook('action:api.user.registered') 116 await checkHook('action:api.user.registered')
125 }) 117 })
126 118
127 it('Should run action:api.user.created', async function () { 119 it('Should run action:api.user.created', async function () {
128 const res = await createUser({ 120 const user = await servers[0].usersCommand.create({ username: 'created_user' })
129 url: servers[0].url, 121 userId = user.id
130 accessToken: servers[0].accessToken,
131 username: 'created_user',
132 password: 'super_password'
133 })
134 userId = res.body.user.id
135 122
136 await checkHook('action:api.user.created') 123 await checkHook('action:api.user.created')
137 }) 124 })
@@ -143,25 +130,25 @@ describe('Test plugin action hooks', function () {
143 }) 130 })
144 131
145 it('Should run action:api.user.blocked', async function () { 132 it('Should run action:api.user.blocked', async function () {
146 await blockUser(servers[0].url, userId, servers[0].accessToken) 133 await servers[0].usersCommand.banUser({ userId })
147 134
148 await checkHook('action:api.user.blocked') 135 await checkHook('action:api.user.blocked')
149 }) 136 })
150 137
151 it('Should run action:api.user.unblocked', async function () { 138 it('Should run action:api.user.unblocked', async function () {
152 await unblockUser(servers[0].url, userId, servers[0].accessToken) 139 await servers[0].usersCommand.unbanUser({ userId })
153 140
154 await checkHook('action:api.user.unblocked') 141 await checkHook('action:api.user.unblocked')
155 }) 142 })
156 143
157 it('Should run action:api.user.updated', async function () { 144 it('Should run action:api.user.updated', async function () {
158 await updateUser({ url: servers[0].url, accessToken: servers[0].accessToken, userId, videoQuota: 50 }) 145 await servers[0].usersCommand.update({ userId, videoQuota: 50 })
159 146
160 await checkHook('action:api.user.updated') 147 await checkHook('action:api.user.updated')
161 }) 148 })
162 149
163 it('Should run action:api.user.deleted', async function () { 150 it('Should run action:api.user.deleted', async function () {
164 await removeUser(servers[0].url, userId, servers[0].accessToken) 151 await servers[0].usersCommand.remove({ userId })
165 152
166 await checkHook('action:api.user.deleted') 153 await checkHook('action:api.user.deleted')
167 }) 154 })