From a800dbf345e856ab790e7b3ab9a97e8c5dfa0a32 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 9 Dec 2020 15:00:02 +0100 Subject: Live views update --- server/tests/api/live/live.ts | 51 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'server/tests/api/live/live.ts') diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index e728fcce0..6d504f742 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts @@ -328,7 +328,7 @@ describe('Test live', function () { await checkResolutionsInMasterPlaylist(hlsPlaylist.playlistUrl, resolutions) for (let i = 0; i < resolutions.length; i++) { - const segmentNum = 2 + const segmentNum = 3 const segmentName = `${i}-00000${segmentNum}.ts` await waitUntilLiveSegmentGeneration(servers[0], video.uuid, i, segmentNum) @@ -608,6 +608,55 @@ describe('Test live', function () { } }) + it('Should correctly send views change notification', async function () { + this.timeout(60000) + + let localLastVideoViews = 0 + let remoteLastVideoViews = 0 + + const liveVideoUUID = await createLiveWrapper() + await waitJobs(servers) + + { + const videoId = await getVideoIdFromUUID(servers[0].url, liveVideoUUID) + + const localSocket = getLiveNotificationSocket(servers[0].url) + localSocket.on('views-change', data => { localLastVideoViews = data.views }) + localSocket.emit('subscribe', { videoId }) + } + + { + const videoId = await getVideoIdFromUUID(servers[1].url, liveVideoUUID) + + const remoteSocket = getLiveNotificationSocket(servers[1].url) + remoteSocket.on('views-change', data => { remoteLastVideoViews = data.views }) + remoteSocket.emit('subscribe', { videoId }) + } + + const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) + + for (const server of servers) { + await waitUntilLivePublished(server.url, server.accessToken, liveVideoUUID) + } + + await waitJobs(servers) + + expect(localLastVideoViews).to.equal(0) + expect(remoteLastVideoViews).to.equal(0) + + await viewVideo(servers[0].url, liveVideoUUID) + await viewVideo(servers[1].url, liveVideoUUID) + + await waitJobs(servers) + await wait(5000) + await waitJobs(servers) + + expect(localLastVideoViews).to.equal(2) + expect(remoteLastVideoViews).to.equal(2) + + await stopFfmpeg(command) + }) + it('Should not receive a notification after unsubscribe', async function () { this.timeout(60000) -- cgit v1.2.3