aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins/plugin-helpers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/plugins/plugin-helpers.ts')
-rw-r--r--server/tests/plugins/plugin-helpers.ts57
1 files changed, 23 insertions, 34 deletions
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts
index cbb6887eb..509aba13d 100644
--- a/server/tests/plugins/plugin-helpers.ts
+++ b/server/tests/plugins/plugin-helpers.ts
@@ -8,15 +8,11 @@ import {
8 cleanupTests, 8 cleanupTests,
9 doubleFollow, 9 doubleFollow,
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
11 getVideo,
12 getVideosList,
13 makeGetRequest, 11 makeGetRequest,
14 makePostBodyRequest, 12 makePostBodyRequest,
15 PluginsCommand, 13 PluginsCommand,
16 ServerInfo, 14 ServerInfo,
17 setAccessTokensToServers, 15 setAccessTokensToServers,
18 uploadVideoAndGetId,
19 viewVideo,
20 waitJobs 16 waitJobs
21} from '@shared/extra-utils' 17} from '@shared/extra-utils'
22 18
@@ -144,59 +140,54 @@ describe('Test plugin helpers', function () {
144 this.timeout(60000) 140 this.timeout(60000)
145 141
146 { 142 {
147 const res = await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' }) 143 const res = await await servers[0].videosCommand.quickUpload({ name: 'video server 1' })
148 videoUUIDServer1 = res.uuid 144 videoUUIDServer1 = res.uuid
149 } 145 }
150 146
151 { 147 {
152 await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' }) 148 await await servers[1].videosCommand.quickUpload({ name: 'video server 2' })
153 } 149 }
154 150
155 await waitJobs(servers) 151 await waitJobs(servers)
156 152
157 const res = await getVideosList(servers[0].url) 153 const { data } = await servers[0].videosCommand.list()
158 const videos = res.body.data
159 154
160 expect(videos).to.have.lengthOf(2) 155 expect(data).to.have.lengthOf(2)
161 }) 156 })
162 157
163 it('Should mute server 2', async function () { 158 it('Should mute server 2', async function () {
164 this.timeout(10000) 159 this.timeout(10000)
165 await postCommand(servers[0], 'blockServer', { hostToBlock: `localhost:${servers[1].port}` }) 160 await postCommand(servers[0], 'blockServer', { hostToBlock: `localhost:${servers[1].port}` })
166 161
167 const res = await getVideosList(servers[0].url) 162 const { data } = await servers[0].videosCommand.list()
168 const videos = res.body.data
169 163
170 expect(videos).to.have.lengthOf(1) 164 expect(data).to.have.lengthOf(1)
171 expect(videos[0].name).to.equal('video server 1') 165 expect(data[0].name).to.equal('video server 1')
172 }) 166 })
173 167
174 it('Should unmute server 2', async function () { 168 it('Should unmute server 2', async function () {
175 await postCommand(servers[0], 'unblockServer', { hostToUnblock: `localhost:${servers[1].port}` }) 169 await postCommand(servers[0], 'unblockServer', { hostToUnblock: `localhost:${servers[1].port}` })
176 170
177 const res = await getVideosList(servers[0].url) 171 const { data } = await servers[0].videosCommand.list()
178 const videos = res.body.data
179 172
180 expect(videos).to.have.lengthOf(2) 173 expect(data).to.have.lengthOf(2)
181 }) 174 })
182 175
183 it('Should mute account of server 2', async function () { 176 it('Should mute account of server 2', async function () {
184 await postCommand(servers[0], 'blockAccount', { handleToBlock: `root@localhost:${servers[1].port}` }) 177 await postCommand(servers[0], 'blockAccount', { handleToBlock: `root@localhost:${servers[1].port}` })
185 178
186 const res = await getVideosList(servers[0].url) 179 const { data } = await servers[0].videosCommand.list()
187 const videos = res.body.data
188 180
189 expect(videos).to.have.lengthOf(1) 181 expect(data).to.have.lengthOf(1)
190 expect(videos[0].name).to.equal('video server 1') 182 expect(data[0].name).to.equal('video server 1')
191 }) 183 })
192 184
193 it('Should unmute account of server 2', async function () { 185 it('Should unmute account of server 2', async function () {
194 await postCommand(servers[0], 'unblockAccount', { handleToUnblock: `root@localhost:${servers[1].port}` }) 186 await postCommand(servers[0], 'unblockAccount', { handleToUnblock: `root@localhost:${servers[1].port}` })
195 187
196 const res = await getVideosList(servers[0].url) 188 const { data } = await servers[0].videosCommand.list()
197 const videos = res.body.data
198 189
199 expect(videos).to.have.lengthOf(2) 190 expect(data).to.have.lengthOf(2)
200 }) 191 })
201 192
202 it('Should blacklist video', async function () { 193 it('Should blacklist video', async function () {
@@ -207,11 +198,10 @@ describe('Test plugin helpers', function () {
207 await waitJobs(servers) 198 await waitJobs(servers)
208 199
209 for (const server of servers) { 200 for (const server of servers) {
210 const res = await getVideosList(server.url) 201 const { data } = await server.videosCommand.list()
211 const videos = res.body.data
212 202
213 expect(videos).to.have.lengthOf(1) 203 expect(data).to.have.lengthOf(1)
214 expect(videos[0].name).to.equal('video server 2') 204 expect(data[0].name).to.equal('video server 2')
215 } 205 }
216 }) 206 })
217 207
@@ -223,10 +213,9 @@ describe('Test plugin helpers', function () {
223 await waitJobs(servers) 213 await waitJobs(servers)
224 214
225 for (const server of servers) { 215 for (const server of servers) {
226 const res = await getVideosList(server.url) 216 const { data } = await server.videosCommand.list()
227 const videos = res.body.data
228 217
229 expect(videos).to.have.lengthOf(2) 218 expect(data).to.have.lengthOf(2)
230 } 219 }
231 }) 220 })
232 }) 221 })
@@ -235,7 +224,7 @@ describe('Test plugin helpers', function () {
235 let videoUUID: string 224 let videoUUID: string
236 225
237 before(async () => { 226 before(async () => {
238 const res = await uploadVideoAndGetId({ server: servers[0], videoName: 'video1' }) 227 const res = await await servers[0].videosCommand.quickUpload({ name: 'video1' })
239 videoUUID = res.uuid 228 videoUUID = res.uuid
240 }) 229 })
241 230
@@ -243,15 +232,15 @@ describe('Test plugin helpers', function () {
243 this.timeout(40000) 232 this.timeout(40000)
244 233
245 // Should not throw -> video exists 234 // Should not throw -> video exists
246 await getVideo(servers[0].url, videoUUID) 235 await servers[0].videosCommand.get({ id: videoUUID })
247 // Should delete the video 236 // Should delete the video
248 await viewVideo(servers[0].url, videoUUID) 237 await servers[0].videosCommand.view({ id: videoUUID })
249 238
250 await servers[0].serversCommand.waitUntilLog('Video deleted by plugin four.') 239 await servers[0].serversCommand.waitUntilLog('Video deleted by plugin four.')
251 240
252 try { 241 try {
253 // Should throw because the video should have been deleted 242 // Should throw because the video should have been deleted
254 await getVideo(servers[0].url, videoUUID) 243 await servers[0].videosCommand.get({ id: videoUUID })
255 throw new Error('Video exists') 244 throw new Error('Video exists')
256 } catch (err) { 245 } catch (err) {
257 if (err.message.includes('exists')) throw err 246 if (err.message.includes('exists')) throw err