diff options
Diffstat (limited to 'server/tests/plugins')
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 42 | ||||
-rw-r--r-- | server/tests/plugins/plugin-transcoding.ts | 10 |
2 files changed, 39 insertions, 13 deletions
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 52ba396e5..e0f25ca26 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -22,6 +22,7 @@ describe('Test plugin filter hooks', function () { | |||
22 | let servers: PeerTubeServer[] | 22 | let servers: PeerTubeServer[] |
23 | let videoUUID: string | 23 | let videoUUID: string |
24 | let threadId: number | 24 | let threadId: number |
25 | let videoPlaylistUUID: string | ||
25 | 26 | ||
26 | before(async function () { | 27 | before(async function () { |
27 | this.timeout(60000) | 28 | this.timeout(60000) |
@@ -33,9 +34,20 @@ describe('Test plugin filter hooks', function () { | |||
33 | 34 | ||
34 | await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath() }) | 35 | await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath() }) |
35 | await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') }) | 36 | await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') }) |
37 | { | ||
38 | ({ uuid: videoPlaylistUUID } = await servers[0].playlists.create({ | ||
39 | attributes: { | ||
40 | displayName: 'my super playlist', | ||
41 | privacy: VideoPlaylistPrivacy.PUBLIC, | ||
42 | description: 'my super description', | ||
43 | videoChannelId: servers[0].store.channel.id | ||
44 | } | ||
45 | })) | ||
46 | } | ||
36 | 47 | ||
37 | for (let i = 0; i < 10; i++) { | 48 | for (let i = 0; i < 10; i++) { |
38 | await servers[0].videos.upload({ attributes: { name: 'default video ' + i } }) | 49 | const video = await servers[0].videos.upload({ attributes: { name: 'default video ' + i } }) |
50 | await servers[0].playlists.addElement({ playlistId: videoPlaylistUUID, attributes: { videoId: video.id } }) | ||
39 | } | 51 | } |
40 | 52 | ||
41 | const { data } = await servers[0].videos.list() | 53 | const { data } = await servers[0].videos.list() |
@@ -69,6 +81,26 @@ describe('Test plugin filter hooks', function () { | |||
69 | expect(total).to.equal(11) | 81 | expect(total).to.equal(11) |
70 | }) | 82 | }) |
71 | 83 | ||
84 | it('Should run filter:api.video-playlist.videos.list.params', async function () { | ||
85 | const { data } = await servers[0].playlists.listVideos({ | ||
86 | count: 2, | ||
87 | playlistId: videoPlaylistUUID | ||
88 | }) | ||
89 | |||
90 | // 1 plugin do +1 to the count parameter | ||
91 | expect(data).to.have.lengthOf(3) | ||
92 | }) | ||
93 | |||
94 | it('Should run filter:api.video-playlist.videos.list.result', async function () { | ||
95 | const { total } = await servers[0].playlists.listVideos({ | ||
96 | count: 0, | ||
97 | playlistId: videoPlaylistUUID | ||
98 | }) | ||
99 | |||
100 | // Plugin do +1 to the total result | ||
101 | expect(total).to.equal(11) | ||
102 | }) | ||
103 | |||
72 | it('Should run filter:api.accounts.videos.list.params', async function () { | 104 | it('Should run filter:api.accounts.videos.list.params', async function () { |
73 | const { data } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }) | 105 | const { data } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }) |
74 | 106 | ||
@@ -410,13 +442,7 @@ describe('Test plugin filter hooks', function () { | |||
410 | before(async function () { | 442 | before(async function () { |
411 | this.timeout(60000) | 443 | this.timeout(60000) |
412 | 444 | ||
413 | await servers[0].config.updateCustomSubConfig({ | 445 | await servers[0].config.disableTranscoding() |
414 | newConfig: { | ||
415 | transcoding: { | ||
416 | enabled: false | ||
417 | } | ||
418 | } | ||
419 | }) | ||
420 | 446 | ||
421 | for (const name of [ 'bad embed', 'good embed' ]) { | 447 | for (const name of [ 'bad embed', 'good embed' ]) { |
422 | { | 448 | { |
diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts index 5ab686472..49569f1fa 100644 --- a/server/tests/plugins/plugin-transcoding.ts +++ b/server/tests/plugins/plugin-transcoding.ts | |||
@@ -2,7 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' | 5 | import { getAudioStream, getVideoStreamFPS, getVideoStream } from '@server/helpers/ffmpeg' |
6 | import { VideoPrivacy } from '@shared/models' | ||
6 | import { | 7 | import { |
7 | cleanupTests, | 8 | cleanupTests, |
8 | createSingleServer, | 9 | createSingleServer, |
@@ -13,7 +14,6 @@ import { | |||
13 | testFfmpegStreamError, | 14 | testFfmpegStreamError, |
14 | waitJobs | 15 | waitJobs |
15 | } from '@shared/server-commands' | 16 | } from '@shared/server-commands' |
16 | import { VideoPrivacy } from '@shared/models' | ||
17 | 17 | ||
18 | async function createLiveWrapper (server: PeerTubeServer) { | 18 | async function createLiveWrapper (server: PeerTubeServer) { |
19 | const liveAttributes = { | 19 | const liveAttributes = { |
@@ -92,7 +92,7 @@ describe('Test transcoding plugins', function () { | |||
92 | 92 | ||
93 | async function checkLiveFPS (uuid: string, type: 'above' | 'below', fps: number) { | 93 | async function checkLiveFPS (uuid: string, type: 'above' | 'below', fps: number) { |
94 | const playlistUrl = `${server.url}/static/streaming-playlists/hls/${uuid}/0.m3u8` | 94 | const playlistUrl = `${server.url}/static/streaming-playlists/hls/${uuid}/0.m3u8` |
95 | const videoFPS = await getVideoFileFPS(playlistUrl) | 95 | const videoFPS = await getVideoStreamFPS(playlistUrl) |
96 | 96 | ||
97 | if (type === 'above') { | 97 | if (type === 'above') { |
98 | expect(videoFPS).to.be.above(fps) | 98 | expect(videoFPS).to.be.above(fps) |
@@ -252,7 +252,7 @@ describe('Test transcoding plugins', function () { | |||
252 | const audioProbe = await getAudioStream(path) | 252 | const audioProbe = await getAudioStream(path) |
253 | expect(audioProbe.audioStream.codec_name).to.equal('opus') | 253 | expect(audioProbe.audioStream.codec_name).to.equal('opus') |
254 | 254 | ||
255 | const videoProbe = await getVideoStreamFromFile(path) | 255 | const videoProbe = await getVideoStream(path) |
256 | expect(videoProbe.codec_name).to.equal('vp9') | 256 | expect(videoProbe.codec_name).to.equal('vp9') |
257 | }) | 257 | }) |
258 | 258 | ||
@@ -269,7 +269,7 @@ describe('Test transcoding plugins', function () { | |||
269 | const audioProbe = await getAudioStream(playlistUrl) | 269 | const audioProbe = await getAudioStream(playlistUrl) |
270 | expect(audioProbe.audioStream.codec_name).to.equal('opus') | 270 | expect(audioProbe.audioStream.codec_name).to.equal('opus') |
271 | 271 | ||
272 | const videoProbe = await getVideoStreamFromFile(playlistUrl) | 272 | const videoProbe = await getVideoStream(playlistUrl) |
273 | expect(videoProbe.codec_name).to.equal('h264') | 273 | expect(videoProbe.codec_name).to.equal('h264') |
274 | }) | 274 | }) |
275 | }) | 275 | }) |