]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/views/video-views-overall-stats.ts
Allow admins to disable two factor auth
[github/Chocobozzz/PeerTube.git] / server / tests / api / views / video-views-overall-stats.ts
index 02012388df959cd41680c119c7152a390b4aadbc..bb00684efd1aecfae7333ed388ed1859d2596bca 100644 (file)
@@ -1,13 +1,10 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
-import * as chai from 'chai'
+import { expect } from 'chai'
 import { FfmpegCommand } from 'fluent-ffmpeg'
 import { prepareViewsServers, prepareViewsVideos, processViewersStats } from '@server/tests/shared'
 import { cleanupTests, PeerTubeServer, stopFfmpeg, waitJobs } from '@shared/server-commands'
 
-const expect = chai.expect
-
 describe('Test views overall stats', function () {
   let servers: PeerTubeServer[]
 
@@ -36,6 +33,7 @@ describe('Test views overall stats', function () {
         expect(video.views).to.equal(0)
         expect(stats.averageWatchTime).to.equal(0)
         expect(stats.totalWatchTime).to.equal(0)
+        expect(stats.totalViewers).to.equal(0)
       }
     })
 
@@ -55,6 +53,7 @@ describe('Test views overall stats', function () {
         expect(video.views).to.equal(0)
         expect(stats.averageWatchTime).to.equal(1)
         expect(stats.totalWatchTime).to.equal(1)
+        expect(stats.totalViewers).to.equal(1)
       }
     })
 
@@ -74,6 +73,7 @@ describe('Test views overall stats', function () {
           expect(video.views).to.equal(1)
           expect(stats.averageWatchTime).to.equal(2)
           expect(stats.totalWatchTime).to.equal(4)
+          expect(stats.totalViewers).to.equal(2)
         }
 
         {
@@ -83,6 +83,7 @@ describe('Test views overall stats', function () {
           expect(video.views).to.equal(1)
           expect(stats.averageWatchTime).to.equal(21)
           expect(stats.totalWatchTime).to.equal(41)
+          expect(stats.totalViewers).to.equal(2)
         }
       }
     })
@@ -103,6 +104,7 @@ describe('Test views overall stats', function () {
         expect(video.views).to.equal(1)
         expect(stats.averageWatchTime).to.equal(2)
         expect(stats.totalWatchTime).to.equal(6)
+        expect(stats.totalViewers).to.equal(3)
       }
 
       {
@@ -112,6 +114,7 @@ describe('Test views overall stats', function () {
         expect(video.views).to.equal(1)
         expect(stats.averageWatchTime).to.equal(14)
         expect(stats.totalWatchTime).to.equal(43)
+        expect(stats.totalViewers).to.equal(3)
       }
     })
 
@@ -129,6 +132,7 @@ describe('Test views overall stats', function () {
         expect(video.views).to.equal(2)
         expect(stats.averageWatchTime).to.equal(3)
         expect(stats.totalWatchTime).to.equal(11)
+        expect(stats.totalViewers).to.equal(4)
       }
 
       {
@@ -138,6 +142,7 @@ describe('Test views overall stats', function () {
         expect(video.views).to.equal(2)
         expect(stats.averageWatchTime).to.equal(22)
         expect(stats.totalWatchTime).to.equal(88)
+        expect(stats.totalViewers).to.equal(4)
       }
     })
 
@@ -153,12 +158,14 @@ describe('Test views overall stats', function () {
         const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId, startDate: beforeView.toISOString() })
         expect(stats.averageWatchTime).to.equal(3)
         expect(stats.totalWatchTime).to.equal(3)
+        expect(stats.totalViewers).to.equal(1)
       }
 
       {
         const stats = await servers[0].videoStats.getOverallStats({ videoId: liveVideoId, endDate: beforeView.toISOString() })
         expect(stats.averageWatchTime).to.equal(22)
         expect(stats.totalWatchTime).to.equal(88)
+        expect(stats.totalViewers).to.equal(4)
       }
     })