From 1fd61899eaea245a5844e33e21f04b2562f16e5e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 3 May 2021 11:06:19 +0200 Subject: Add ability to filter my videos by live --- server/tests/api/live/live.ts | 65 ++++++++++++++++++++++++++++++++ server/tests/api/search/search-videos.ts | 49 +++++++++++++++++++++++- server/tests/api/videos/single-server.ts | 4 +- 3 files changed, 114 insertions(+), 4 deletions(-) (limited to 'server/tests/api') 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 { doubleFollow, flushAndRunMultipleServers, getLive, + getMyVideosWithFilter, getPlaylist, getVideo, getVideoIdFromUUID, getVideosList, + getVideosWithFilters, killallServers, makeRawRequest, removeVideo, @@ -37,6 +39,7 @@ import { testImage, updateCustomSubConfig, updateLive, + uploadVideoAndGetId, viewVideo, wait, waitJobs, @@ -229,6 +232,68 @@ describe('Test live', function () { }) }) + describe('Live filters', function () { + let command: any + let liveVideoId: string + let vodVideoId: string + + before(async function () { + this.timeout(120000) + + vodVideoId = (await uploadVideoAndGetId({ server: servers[0], videoName: 'vod video' })).uuid + + const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].videoChannel.id } + const resLive = await createLive(servers[0].url, servers[0].accessToken, liveOptions) + liveVideoId = resLive.body.video.uuid + + command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) + await waitUntilLivePublishedOnAllServers(liveVideoId) + await waitJobs(servers) + }) + + it('Should only display lives', async function () { + const res = await getVideosWithFilters(servers[0].url, { isLive: true }) + + expect(res.body.total).to.equal(1) + expect(res.body.data).to.have.lengthOf(1) + expect(res.body.data[0].name).to.equal('live') + }) + + it('Should not display lives', async function () { + const res = await getVideosWithFilters(servers[0].url, { isLive: false }) + + expect(res.body.total).to.equal(1) + expect(res.body.data).to.have.lengthOf(1) + expect(res.body.data[0].name).to.equal('vod video') + }) + + it('Should display my lives', async function () { + this.timeout(60000) + + await stopFfmpeg(command) + await waitJobs(servers) + + const res = await getMyVideosWithFilter(servers[0].url, servers[0].accessToken, { isLive: true }) + const videos = res.body.data as Video[] + + const result = videos.every(v => v.isLive) + expect(result).to.be.true + }) + + it('Should not display my lives', async function () { + const res = await getMyVideosWithFilter(servers[0].url, servers[0].accessToken, { isLive: false }) + const videos = res.body.data as Video[] + + const result = videos.every(v => !v.isLive) + expect(result).to.be.true + }) + + after(async function () { + await removeVideo(servers[0].url, servers[0].accessToken, vodVideoId) + await removeVideo(servers[0].url, servers[0].accessToken, liveVideoId) + }) + }) + describe('Stream checks', function () { let liveVideo: LiveVideo & VideoDetails 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 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' +import * as chai from 'chai' +import { VideoPrivacy } from '@shared/models' import { advancedVideosSearch, cleanupTests, + createLive, flushAndRunServer, immutableAssign, searchVideo, + sendRTMPStreamInVideo, ServerInfo, setAccessTokensToServers, + setDefaultVideoChannel, + stopFfmpeg, + updateCustomSubConfig, uploadVideo, - wait + wait, + waitUntilLivePublished } from '../../../../shared/extra-utils' import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions' @@ -28,6 +35,7 @@ describe('Test videos search', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) + await setDefaultVideoChannel([ server ]) { const attributes1 = { @@ -449,6 +457,43 @@ describe('Test videos search', function () { expect(res.body.data[0].name).to.equal('1111 2222 3333 - 3') }) + it('Should search by live', async function () { + this.timeout(30000) + + { + const options = { + search: { + searchIndex: { enabled: false } + }, + live: { enabled: true } + } + await updateCustomSubConfig(server.url, server.accessToken, options) + } + + { + const res = await advancedVideosSearch(server.url, { isLive: true }) + + expect(res.body.total).to.equal(0) + expect(res.body.data).to.have.lengthOf(0) + } + + { + const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.videoChannel.id } + const resLive = await createLive(server.url, server.accessToken, liveOptions) + const liveVideoId = resLive.body.video.uuid + + const command = await sendRTMPStreamInVideo(server.url, server.accessToken, liveVideoId) + await waitUntilLivePublished(server.url, server.accessToken, liveVideoId) + + const res = await advancedVideosSearch(server.url, { isLive: true }) + + expect(res.body.total).to.equal(1) + expect(res.body.data[0].name).to.equal('live') + + await stopFfmpeg(command) + } + }) + after(async function () { await cleanupTests([ server ]) }) 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 () { }) it('Should filter by tags and category', async function () { - const res1 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: 4 }) + const res1 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] }) expect(res1.body.total).to.equal(1) expect(res1.body.data[0].name).to.equal('my super video updated') - const res2 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: 3 }) + const res2 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] }) expect(res2.body.total).to.equal(0) }) -- cgit v1.2.3