diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-16 16:49:43 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-16 16:49:43 +0100 |
commit | 2e9c7877eb3a3c5d64cc5c3383f0a7c0b51f5481 (patch) | |
tree | 9003b67f56f13267aa373e0d0314c9893ad38fb6 /server/tests/plugins | |
parent | 2b6af10e9f37ccd104a9cc179e32c530a6655964 (diff) | |
download | PeerTube-2e9c7877eb3a3c5d64cc5c3383f0a7c0b51f5481.tar.gz PeerTube-2e9c7877eb3a3c5d64cc5c3383f0a7c0b51f5481.tar.zst PeerTube-2e9c7877eb3a3c5d64cc5c3383f0a7c0b51f5481.zip |
Add videos.getFiles plugin helper
Diffstat (limited to 'server/tests/plugins')
-rw-r--r-- | server/tests/plugins/plugin-helpers.ts | 52 |
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 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { pathExists } from 'fs-extra' | ||
5 | import { | 6 | import { |
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' |
17 | import { HttpStatusCode } from '@shared/models' | 19 | import { HttpStatusCode, ThumbnailType } from '@shared/models' |
18 | 20 | ||
19 | function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) { | 21 | function 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 () { |