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.ts52
1 files changed, 51 insertions, 1 deletions
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts
index 5d16b28a4..26f66b0b1 100644
--- a/server/tests/plugins/plugin-helpers.ts
+++ b/server/tests/plugins/plugin-helpers.ts
@@ -2,6 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { pathExists } from 'fs-extra'
5import { 6import {
6 checkVideoFilesWereRemoved, 7 checkVideoFilesWereRemoved,
7 cleanupTests, 8 cleanupTests,
@@ -9,12 +10,13 @@ import {
9 doubleFollow, 10 doubleFollow,
10 makeGetRequest, 11 makeGetRequest,
11 makePostBodyRequest, 12 makePostBodyRequest,
13 makeRawRequest,
12 PeerTubeServer, 14 PeerTubeServer,
13 PluginsCommand, 15 PluginsCommand,
14 setAccessTokensToServers, 16 setAccessTokensToServers,
15 waitJobs 17 waitJobs
16} from '@shared/extra-utils' 18} from '@shared/extra-utils'
17import { HttpStatusCode } from '@shared/models' 19import { HttpStatusCode, ThumbnailType } from '@shared/models'
18 20
19function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) { 21function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) {
20 const body = { command } 22 const body = { command }
@@ -224,8 +226,56 @@ describe('Test plugin helpers', function () {
224 let videoUUID: string 226 let videoUUID: string
225 227
226 before(async () => { 228 before(async () => {
229 this.timeout(240000)
230
231 await servers[0].config.enableTranscoding()
232
227 const res = await servers[0].videos.quickUpload({ name: 'video1' }) 233 const res = await servers[0].videos.quickUpload({ name: 'video1' })
228 videoUUID = res.uuid 234 videoUUID = res.uuid
235
236 await waitJobs(servers)
237 })
238
239 it('Should get video files', async function () {
240 const { body } = await makeGetRequest({
241 url: servers[0].url,
242 path: '/plugins/test-four/router/video-files/' + videoUUID,
243 expectedStatus: HttpStatusCode.OK_200
244 })
245
246 // Video files check
247 {
248 expect(body.webtorrent.videoFiles).to.be.an('array')
249 expect(body.hls.videoFiles).to.be.an('array')
250
251 for (const resolution of [ 144, 240, 360, 480, 720 ]) {
252 for (const files of [ body.webtorrent.videoFiles, body.hls.videoFiles ]) {
253 const file = files.find(f => f.resolution === resolution)
254 expect(file).to.exist
255
256 expect(file.size).to.be.a('number')
257 expect(file.fps).to.equal(25)
258
259 expect(await pathExists(file.path)).to.be.true
260 await makeRawRequest(file.url, HttpStatusCode.OK_200)
261 }
262 }
263 }
264
265 // Thumbnails check
266 {
267 expect(body.thumbnails).to.be.an('array')
268
269 const miniature = body.thumbnails.find(t => t.type === ThumbnailType.MINIATURE)
270 expect(miniature).to.exist
271 expect(await pathExists(miniature.path)).to.be.true
272 await makeRawRequest(miniature.url, HttpStatusCode.OK_200)
273
274 const preview = body.thumbnails.find(t => t.type === ThumbnailType.PREVIEW)
275 expect(preview).to.exist
276 expect(await pathExists(preview.path)).to.be.true
277 await makeRawRequest(preview.url, HttpStatusCode.OK_200)
278 }
229 }) 279 })
230 280
231 it('Should remove a video after a view', async function () { 281 it('Should remove a video after a view', async function () {