]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/views/video-views-overall-stats.ts
Add filter by start/end date overall stats in api
[github/Chocobozzz/PeerTube.git] / server / tests / api / views / video-views-overall-stats.ts
index 72b072c963dd31e2382aea79a8d20f19e4c08293..53b8f0d4b97e91e570ae6819e6ac6a1ac0e9e5c6 100644 (file)
@@ -141,6 +141,27 @@ describe('Test views overall stats', function () {
       }
     })
 
+    it('Should filter overall stats by date', async function () {
+      this.timeout(60000)
+
+      const beforeView = new Date()
+
+      await servers[0].views.simulateViewer({ id: vodVideoId, currentTimes: [ 0, 3 ] })
+      await processViewersStats(servers)
+
+      {
+        const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId, startDate: beforeView.toISOString() })
+        expect(stats.averageWatchTime).to.equal(3)
+        expect(stats.totalWatchTime).to.equal(3)
+      }
+
+      {
+        const stats = await servers[0].videoStats.getOverallStats({ videoId: liveVideoId, endDate: beforeView.toISOString() })
+        expect(stats.averageWatchTime).to.equal(22)
+        expect(stats.totalWatchTime).to.equal(88)
+      }
+    })
+
     after(async function () {
       await stopFfmpeg(command)
     })