aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/views/video-views-timeserie-stats.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-04-08 10:22:56 +0200
committerChocobozzz <chocobozzz@cpy.re>2022-04-15 09:49:35 +0200
commit3eda9b775ae700ac544e8c5588514627796b83cd (patch)
tree97ec1fdfce274e83d976352f5b4154c315ee33d7 /server/tests/api/views/video-views-timeserie-stats.ts
parent901bcf5c188ea79350fecd499ad76460b866617b (diff)
downloadPeerTube-3eda9b775ae700ac544e8c5588514627796b83cd.tar.gz
PeerTube-3eda9b775ae700ac544e8c5588514627796b83cd.tar.zst
PeerTube-3eda9b775ae700ac544e8c5588514627796b83cd.zip
Support interactive video stats graph
Diffstat (limited to 'server/tests/api/views/video-views-timeserie-stats.ts')
-rw-r--r--server/tests/api/views/video-views-timeserie-stats.ts22
1 files changed, 11 insertions, 11 deletions
diff --git a/server/tests/api/views/video-views-timeserie-stats.ts b/server/tests/api/views/video-views-timeserie-stats.ts
index 4db76fe89..fd3aba188 100644
--- a/server/tests/api/views/video-views-timeserie-stats.ts
+++ b/server/tests/api/views/video-views-timeserie-stats.ts
@@ -110,21 +110,21 @@ describe('Test views timeserie stats', function () {
110 110
111 it('Should use a custom start/end date', async function () { 111 it('Should use a custom start/end date', async function () {
112 const now = new Date() 112 const now = new Date()
113 const tenDaysAgo = new Date() 113 const twentyDaysAgo = new Date()
114 tenDaysAgo.setDate(tenDaysAgo.getDate() - 9) 114 twentyDaysAgo.setDate(twentyDaysAgo.getDate() - 19)
115 115
116 const result = await servers[0].videoStats.getTimeserieStats({ 116 const result = await servers[0].videoStats.getTimeserieStats({
117 videoId: vodVideoId, 117 videoId: vodVideoId,
118 metric: 'aggregateWatchTime', 118 metric: 'aggregateWatchTime',
119 startDate: tenDaysAgo, 119 startDate: twentyDaysAgo,
120 endDate: now 120 endDate: now
121 }) 121 })
122 122
123 expect(result.groupInterval).to.equal('one_day') 123 expect(result.groupInterval).to.equal('1 day')
124 expect(result.data).to.have.lengthOf(10) 124 expect(result.data).to.have.lengthOf(20)
125 125
126 const first = result.data[0] 126 const first = result.data[0]
127 expect(new Date(first.date).toLocaleDateString()).to.equal(tenDaysAgo.toLocaleDateString()) 127 expect(new Date(first.date).toLocaleDateString()).to.equal(twentyDaysAgo.toLocaleDateString())
128 128
129 expectInterval(result, 24 * 3600 * 1000) 129 expectInterval(result, 24 * 3600 * 1000)
130 expectTodayLastValue(result, 9) 130 expectTodayLastValue(result, 9)
@@ -142,7 +142,7 @@ describe('Test views timeserie stats', function () {
142 endDate: now 142 endDate: now
143 }) 143 })
144 144
145 expect(result.groupInterval).to.equal('one_hour') 145 expect(result.groupInterval).to.equal('1 hour')
146 expect(result.data).to.have.length.above(24).and.below(50) 146 expect(result.data).to.have.length.above(24).and.below(50)
147 147
148 expectInterval(result, 3600 * 1000) 148 expectInterval(result, 3600 * 1000)
@@ -152,7 +152,7 @@ describe('Test views timeserie stats', function () {
152 it('Should automatically group by ten minutes', async function () { 152 it('Should automatically group by ten minutes', async function () {
153 const now = new Date() 153 const now = new Date()
154 const twoHoursAgo = new Date() 154 const twoHoursAgo = new Date()
155 twoHoursAgo.setHours(twoHoursAgo.getHours() - 1) 155 twoHoursAgo.setHours(twoHoursAgo.getHours() - 4)
156 156
157 const result = await servers[0].videoStats.getTimeserieStats({ 157 const result = await servers[0].videoStats.getTimeserieStats({
158 videoId: vodVideoId, 158 videoId: vodVideoId,
@@ -161,8 +161,8 @@ describe('Test views timeserie stats', function () {
161 endDate: now 161 endDate: now
162 }) 162 })
163 163
164 expect(result.groupInterval).to.equal('ten_minutes') 164 expect(result.groupInterval).to.equal('10 minutes')
165 expect(result.data).to.have.length.above(6).and.below(18) 165 expect(result.data).to.have.length.above(20).and.below(30)
166 166
167 expectInterval(result, 60 * 10 * 1000) 167 expectInterval(result, 60 * 10 * 1000)
168 expectTodayLastValue(result, 9) 168 expectTodayLastValue(result, 9)
@@ -180,7 +180,7 @@ describe('Test views timeserie stats', function () {
180 endDate: now 180 endDate: now
181 }) 181 })
182 182
183 expect(result.groupInterval).to.equal('one_minute') 183 expect(result.groupInterval).to.equal('1 minute')
184 expect(result.data).to.have.length.above(20).and.below(40) 184 expect(result.data).to.have.length.above(20).and.below(40)
185 185
186 expectInterval(result, 60 * 1000) 186 expectInterval(result, 60 * 1000)