aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/live/live.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-06 16:42:23 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commite4bf78561763cd84d22ebceb6f371cccf9a356d8 (patch)
tree7d8ea6ed53810d1dfcc2cfa5e3150da8e87e4645 /server/tests/api/live/live.ts
parent529f037294d9917a62235f8162887a8edc04c32f (diff)
downloadPeerTube-e4bf78561763cd84d22ebceb6f371cccf9a356d8.tar.gz
PeerTube-e4bf78561763cd84d22ebceb6f371cccf9a356d8.tar.zst
PeerTube-e4bf78561763cd84d22ebceb6f371cccf9a356d8.zip
Handle views for live videos
Diffstat (limited to 'server/tests/api/live/live.ts')
-rw-r--r--server/tests/api/live/live.ts77
1 files changed, 77 insertions, 0 deletions
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index b41b5fc2e..2198114b4 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -28,9 +28,12 @@ import {
28 testImage, 28 testImage,
29 updateCustomSubConfig, 29 updateCustomSubConfig,
30 updateLive, 30 updateLive,
31 viewVideo,
32 wait,
31 waitJobs, 33 waitJobs,
32 waitUntilLiveStarts 34 waitUntilLiveStarts
33} from '../../../../shared/extra-utils' 35} from '../../../../shared/extra-utils'
36import { FfmpegCommand } from 'fluent-ffmpeg'
34 37
35const expect = chai.expect 38const expect = chai.expect
36 39
@@ -419,6 +422,80 @@ describe('Test live', function () {
419 }) 422 })
420 }) 423 })
421 424
425 describe('Live views', function () {
426 let liveVideoId: string
427 let command: FfmpegCommand
428
429 async function countViews (expected: number) {
430 for (const server of servers) {
431 const res = await getVideo(server.url, liveVideoId)
432 const video: VideoDetails = res.body
433
434 expect(video.views).to.equal(expected)
435 }
436 }
437
438 before(async function () {
439 this.timeout(30000)
440
441 const liveAttributes = {
442 name: 'live video',
443 channelId: servers[0].videoChannel.id,
444 privacy: VideoPrivacy.PUBLIC
445 }
446
447 const res = await createLive(servers[0].url, servers[0].accessToken, liveAttributes)
448 liveVideoId = res.body.video.uuid
449
450 command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
451 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId)
452 await waitJobs(servers)
453 })
454
455 it('Should display no views for a live', async function () {
456 await countViews(0)
457 })
458
459 it('Should view a live twice and display 1 view', async function () {
460 this.timeout(30000)
461
462 await viewVideo(servers[0].url, liveVideoId)
463 await viewVideo(servers[0].url, liveVideoId)
464
465 await wait(5000)
466
467 await waitJobs(servers)
468
469 await countViews(1)
470 })
471
472 it('Should wait 5 seconds and display 0 views', async function () {
473 this.timeout(30000)
474
475 await wait(5000)
476 await waitJobs(servers)
477
478 await countViews(0)
479 })
480
481 it('Should view a live on a remote and on local and display 2 views', async function () {
482 this.timeout(30000)
483
484 await viewVideo(servers[0].url, liveVideoId)
485 await viewVideo(servers[1].url, liveVideoId)
486 await viewVideo(servers[1].url, liveVideoId)
487
488 await wait(5000)
489 await waitJobs(servers)
490
491 await countViews(2)
492 })
493
494 after(async function () {
495 await stopFfmpeg(command)
496 })
497 })
498
422 describe('Live socket messages', function () { 499 describe('Live socket messages', function () {
423 500
424 async function createLiveWrapper () { 501 async function createLiveWrapper () {