diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test-four/main.js | 7 | ||||
-rw-r--r-- | server/tests/plugins/plugin-helpers.ts | 52 |
2 files changed, 58 insertions, 1 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test-four/main.js b/server/tests/fixtures/peertube-plugin-test-four/main.js index b9b207b81..edbb883e2 100644 --- a/server/tests/fixtures/peertube-plugin-test-four/main.js +++ b/server/tests/fixtures/peertube-plugin-test-four/main.js | |||
@@ -104,6 +104,13 @@ async function register ({ | |||
104 | isUser | 104 | isUser |
105 | }) | 105 | }) |
106 | }) | 106 | }) |
107 | |||
108 | router.get('/video-files/:id', async (req, res) => { | ||
109 | const details = await peertubeHelpers.videos.getFiles(req.params.id) | ||
110 | if (!details) return res.sendStatus(404) | ||
111 | |||
112 | return res.json(details) | ||
113 | }) | ||
107 | } | 114 | } |
108 | 115 | ||
109 | } | 116 | } |
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 () { |