diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/live/live.ts | 65 | ||||
-rw-r--r-- | server/tests/api/search/search-videos.ts | 49 | ||||
-rw-r--r-- | server/tests/api/videos/single-server.ts | 4 |
3 files changed, 114 insertions, 4 deletions
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index d48e2a8ee..57fb58150 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -19,10 +19,12 @@ import { | |||
19 | doubleFollow, | 19 | doubleFollow, |
20 | flushAndRunMultipleServers, | 20 | flushAndRunMultipleServers, |
21 | getLive, | 21 | getLive, |
22 | getMyVideosWithFilter, | ||
22 | getPlaylist, | 23 | getPlaylist, |
23 | getVideo, | 24 | getVideo, |
24 | getVideoIdFromUUID, | 25 | getVideoIdFromUUID, |
25 | getVideosList, | 26 | getVideosList, |
27 | getVideosWithFilters, | ||
26 | killallServers, | 28 | killallServers, |
27 | makeRawRequest, | 29 | makeRawRequest, |
28 | removeVideo, | 30 | removeVideo, |
@@ -37,6 +39,7 @@ import { | |||
37 | testImage, | 39 | testImage, |
38 | updateCustomSubConfig, | 40 | updateCustomSubConfig, |
39 | updateLive, | 41 | updateLive, |
42 | uploadVideoAndGetId, | ||
40 | viewVideo, | 43 | viewVideo, |
41 | wait, | 44 | wait, |
42 | waitJobs, | 45 | waitJobs, |
@@ -229,6 +232,68 @@ describe('Test live', function () { | |||
229 | }) | 232 | }) |
230 | }) | 233 | }) |
231 | 234 | ||
235 | describe('Live filters', function () { | ||
236 | let command: any | ||
237 | let liveVideoId: string | ||
238 | let vodVideoId: string | ||
239 | |||
240 | before(async function () { | ||
241 | this.timeout(120000) | ||
242 | |||
243 | vodVideoId = (await uploadVideoAndGetId({ server: servers[0], videoName: 'vod video' })).uuid | ||
244 | |||
245 | const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].videoChannel.id } | ||
246 | const resLive = await createLive(servers[0].url, servers[0].accessToken, liveOptions) | ||
247 | liveVideoId = resLive.body.video.uuid | ||
248 | |||
249 | command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) | ||
250 | await waitUntilLivePublishedOnAllServers(liveVideoId) | ||
251 | await waitJobs(servers) | ||
252 | }) | ||
253 | |||
254 | it('Should only display lives', async function () { | ||
255 | const res = await getVideosWithFilters(servers[0].url, { isLive: true }) | ||
256 | |||
257 | expect(res.body.total).to.equal(1) | ||
258 | expect(res.body.data).to.have.lengthOf(1) | ||
259 | expect(res.body.data[0].name).to.equal('live') | ||
260 | }) | ||
261 | |||
262 | it('Should not display lives', async function () { | ||
263 | const res = await getVideosWithFilters(servers[0].url, { isLive: false }) | ||
264 | |||
265 | expect(res.body.total).to.equal(1) | ||
266 | expect(res.body.data).to.have.lengthOf(1) | ||
267 | expect(res.body.data[0].name).to.equal('vod video') | ||
268 | }) | ||
269 | |||
270 | it('Should display my lives', async function () { | ||
271 | this.timeout(60000) | ||
272 | |||
273 | await stopFfmpeg(command) | ||
274 | await waitJobs(servers) | ||
275 | |||
276 | const res = await getMyVideosWithFilter(servers[0].url, servers[0].accessToken, { isLive: true }) | ||
277 | const videos = res.body.data as Video[] | ||
278 | |||
279 | const result = videos.every(v => v.isLive) | ||
280 | expect(result).to.be.true | ||
281 | }) | ||
282 | |||
283 | it('Should not display my lives', async function () { | ||
284 | const res = await getMyVideosWithFilter(servers[0].url, servers[0].accessToken, { isLive: false }) | ||
285 | const videos = res.body.data as Video[] | ||
286 | |||
287 | const result = videos.every(v => !v.isLive) | ||
288 | expect(result).to.be.true | ||
289 | }) | ||
290 | |||
291 | after(async function () { | ||
292 | await removeVideo(servers[0].url, servers[0].accessToken, vodVideoId) | ||
293 | await removeVideo(servers[0].url, servers[0].accessToken, liveVideoId) | ||
294 | }) | ||
295 | }) | ||
296 | |||
232 | describe('Stream checks', function () { | 297 | describe('Stream checks', function () { |
233 | let liveVideo: LiveVideo & VideoDetails | 298 | let liveVideo: LiveVideo & VideoDetails |
234 | let rtmpUrl: string | 299 | let rtmpUrl: string |
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index e05c3a269..5b8907961 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts | |||
@@ -1,17 +1,24 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | ||
5 | import { VideoPrivacy } from '@shared/models' | ||
5 | import { | 6 | import { |
6 | advancedVideosSearch, | 7 | advancedVideosSearch, |
7 | cleanupTests, | 8 | cleanupTests, |
9 | createLive, | ||
8 | flushAndRunServer, | 10 | flushAndRunServer, |
9 | immutableAssign, | 11 | immutableAssign, |
10 | searchVideo, | 12 | searchVideo, |
13 | sendRTMPStreamInVideo, | ||
11 | ServerInfo, | 14 | ServerInfo, |
12 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
16 | setDefaultVideoChannel, | ||
17 | stopFfmpeg, | ||
18 | updateCustomSubConfig, | ||
13 | uploadVideo, | 19 | uploadVideo, |
14 | wait | 20 | wait, |
21 | waitUntilLivePublished | ||
15 | } from '../../../../shared/extra-utils' | 22 | } from '../../../../shared/extra-utils' |
16 | import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions' | 23 | import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions' |
17 | 24 | ||
@@ -28,6 +35,7 @@ describe('Test videos search', function () { | |||
28 | server = await flushAndRunServer(1) | 35 | server = await flushAndRunServer(1) |
29 | 36 | ||
30 | await setAccessTokensToServers([ server ]) | 37 | await setAccessTokensToServers([ server ]) |
38 | await setDefaultVideoChannel([ server ]) | ||
31 | 39 | ||
32 | { | 40 | { |
33 | const attributes1 = { | 41 | const attributes1 = { |
@@ -449,6 +457,43 @@ describe('Test videos search', function () { | |||
449 | expect(res.body.data[0].name).to.equal('1111 2222 3333 - 3') | 457 | expect(res.body.data[0].name).to.equal('1111 2222 3333 - 3') |
450 | }) | 458 | }) |
451 | 459 | ||
460 | it('Should search by live', async function () { | ||
461 | this.timeout(30000) | ||
462 | |||
463 | { | ||
464 | const options = { | ||
465 | search: { | ||
466 | searchIndex: { enabled: false } | ||
467 | }, | ||
468 | live: { enabled: true } | ||
469 | } | ||
470 | await updateCustomSubConfig(server.url, server.accessToken, options) | ||
471 | } | ||
472 | |||
473 | { | ||
474 | const res = await advancedVideosSearch(server.url, { isLive: true }) | ||
475 | |||
476 | expect(res.body.total).to.equal(0) | ||
477 | expect(res.body.data).to.have.lengthOf(0) | ||
478 | } | ||
479 | |||
480 | { | ||
481 | const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.videoChannel.id } | ||
482 | const resLive = await createLive(server.url, server.accessToken, liveOptions) | ||
483 | const liveVideoId = resLive.body.video.uuid | ||
484 | |||
485 | const command = await sendRTMPStreamInVideo(server.url, server.accessToken, liveVideoId) | ||
486 | await waitUntilLivePublished(server.url, server.accessToken, liveVideoId) | ||
487 | |||
488 | const res = await advancedVideosSearch(server.url, { isLive: true }) | ||
489 | |||
490 | expect(res.body.total).to.equal(1) | ||
491 | expect(res.body.data[0].name).to.equal('live') | ||
492 | |||
493 | await stopFfmpeg(command) | ||
494 | } | ||
495 | }) | ||
496 | |||
452 | after(async function () { | 497 | after(async function () { |
453 | await cleanupTests([ server ]) | 498 | await cleanupTests([ server ]) |
454 | }) | 499 | }) |
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index da90223b8..a79648bf7 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -387,11 +387,11 @@ describe('Test a single server', function () { | |||
387 | }) | 387 | }) |
388 | 388 | ||
389 | it('Should filter by tags and category', async function () { | 389 | it('Should filter by tags and category', async function () { |
390 | const res1 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: 4 }) | 390 | const res1 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] }) |
391 | expect(res1.body.total).to.equal(1) | 391 | expect(res1.body.total).to.equal(1) |
392 | expect(res1.body.data[0].name).to.equal('my super video updated') | 392 | expect(res1.body.data[0].name).to.equal('my super video updated') |
393 | 393 | ||
394 | const res2 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: 3 }) | 394 | const res2 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] }) |
395 | expect(res2.body.total).to.equal(0) | 395 | expect(res2.body.total).to.equal(0) |
396 | }) | 396 | }) |
397 | 397 | ||