aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/views/video-views-overall-stats.ts79
1 files changed, 20 insertions, 59 deletions
diff --git a/server/tests/api/views/video-views-overall-stats.ts b/server/tests/api/views/video-views-overall-stats.ts
index a70d6185e..72b072c96 100644
--- a/server/tests/api/views/video-views-overall-stats.ts
+++ b/server/tests/api/views/video-views-overall-stats.ts
@@ -17,57 +17,6 @@ describe('Test views overall stats', function () {
17 servers = await prepareViewsServers() 17 servers = await prepareViewsServers()
18 }) 18 })
19 19
20 describe('Test rates and comments of local videos on VOD', function () {
21 let vodVideoId: string
22
23 before(async function () {
24 this.timeout(120000);
25
26 ({ vodVideoId } = await prepareViewsVideos({ servers, live: false, vod: true }))
27 })
28
29 it('Should have the appropriate likes', async function () {
30 this.timeout(60000)
31
32 await servers[0].videos.rate({ id: vodVideoId, rating: 'like' })
33 await servers[1].videos.rate({ id: vodVideoId, rating: 'like' })
34
35 await waitJobs(servers)
36
37 const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId })
38
39 expect(stats.likes).to.equal(2)
40 expect(stats.dislikes).to.equal(0)
41 })
42
43 it('Should have the appropriate dislikes', async function () {
44 this.timeout(60000)
45
46 await servers[0].videos.rate({ id: vodVideoId, rating: 'dislike' })
47 await servers[1].videos.rate({ id: vodVideoId, rating: 'dislike' })
48
49 await waitJobs(servers)
50
51 const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId })
52
53 expect(stats.likes).to.equal(0)
54 expect(stats.dislikes).to.equal(2)
55 })
56
57 it('Should have the appropriate comments', async function () {
58 this.timeout(60000)
59
60 await servers[0].comments.createThread({ videoId: vodVideoId, text: 'root' })
61 await servers[0].comments.addReplyToLastThread({ text: 'reply' })
62 await servers[1].comments.createThread({ videoId: vodVideoId, text: 'root' })
63
64 await waitJobs(servers)
65
66 const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId })
67 expect(stats.comments).to.equal(3)
68 })
69 })
70
71 describe('Test watch time stats of local videos on live and VOD', function () { 20 describe('Test watch time stats of local videos on live and VOD', function () {
72 let vodVideoId: string 21 let vodVideoId: string
73 let liveVideoId: string 22 let liveVideoId: string
@@ -82,8 +31,9 @@ describe('Test views overall stats', function () {
82 it('Should display overall stats of a video with no viewers', async function () { 31 it('Should display overall stats of a video with no viewers', async function () {
83 for (const videoId of [ liveVideoId, vodVideoId ]) { 32 for (const videoId of [ liveVideoId, vodVideoId ]) {
84 const stats = await servers[0].videoStats.getOverallStats({ videoId }) 33 const stats = await servers[0].videoStats.getOverallStats({ videoId })
34 const video = await servers[0].videos.get({ id: videoId })
85 35
86 expect(stats.views).to.equal(0) 36 expect(video.views).to.equal(0)
87 expect(stats.averageWatchTime).to.equal(0) 37 expect(stats.averageWatchTime).to.equal(0)
88 expect(stats.totalWatchTime).to.equal(0) 38 expect(stats.totalWatchTime).to.equal(0)
89 } 39 }
@@ -100,8 +50,9 @@ describe('Test views overall stats', function () {
100 50
101 for (const videoId of [ liveVideoId, vodVideoId ]) { 51 for (const videoId of [ liveVideoId, vodVideoId ]) {
102 const stats = await servers[0].videoStats.getOverallStats({ videoId }) 52 const stats = await servers[0].videoStats.getOverallStats({ videoId })
53 const video = await servers[0].videos.get({ id: videoId })
103 54
104 expect(stats.views).to.equal(0) 55 expect(video.views).to.equal(0)
105 expect(stats.averageWatchTime).to.equal(1) 56 expect(stats.averageWatchTime).to.equal(1)
106 expect(stats.totalWatchTime).to.equal(1) 57 expect(stats.totalWatchTime).to.equal(1)
107 } 58 }
@@ -118,14 +69,18 @@ describe('Test views overall stats', function () {
118 69
119 { 70 {
120 const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId }) 71 const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId })
121 expect(stats.views).to.equal(1) 72 const video = await servers[0].videos.get({ id: vodVideoId })
73
74 expect(video.views).to.equal(1)
122 expect(stats.averageWatchTime).to.equal(2) 75 expect(stats.averageWatchTime).to.equal(2)
123 expect(stats.totalWatchTime).to.equal(4) 76 expect(stats.totalWatchTime).to.equal(4)
124 } 77 }
125 78
126 { 79 {
127 const stats = await servers[0].videoStats.getOverallStats({ videoId: liveVideoId }) 80 const stats = await servers[0].videoStats.getOverallStats({ videoId: liveVideoId })
128 expect(stats.views).to.equal(1) 81 const video = await servers[0].videos.get({ id: liveVideoId })
82
83 expect(video.views).to.equal(1)
129 expect(stats.averageWatchTime).to.equal(21) 84 expect(stats.averageWatchTime).to.equal(21)
130 expect(stats.totalWatchTime).to.equal(41) 85 expect(stats.totalWatchTime).to.equal(41)
131 } 86 }
@@ -143,16 +98,18 @@ describe('Test views overall stats', function () {
143 98
144 { 99 {
145 const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId }) 100 const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId })
101 const video = await servers[0].videos.get({ id: vodVideoId })
146 102
147 expect(stats.views).to.equal(1) 103 expect(video.views).to.equal(1)
148 expect(stats.averageWatchTime).to.equal(2) 104 expect(stats.averageWatchTime).to.equal(2)
149 expect(stats.totalWatchTime).to.equal(6) 105 expect(stats.totalWatchTime).to.equal(6)
150 } 106 }
151 107
152 { 108 {
153 const stats = await servers[0].videoStats.getOverallStats({ videoId: liveVideoId }) 109 const stats = await servers[0].videoStats.getOverallStats({ videoId: liveVideoId })
110 const video = await servers[0].videos.get({ id: liveVideoId })
154 111
155 expect(stats.views).to.equal(1) 112 expect(video.views).to.equal(1)
156 expect(stats.averageWatchTime).to.equal(14) 113 expect(stats.averageWatchTime).to.equal(14)
157 expect(stats.totalWatchTime).to.equal(43) 114 expect(stats.totalWatchTime).to.equal(43)
158 } 115 }
@@ -167,14 +124,18 @@ describe('Test views overall stats', function () {
167 124
168 { 125 {
169 const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId }) 126 const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId })
170 expect(stats.views).to.equal(2) 127 const video = await servers[0].videos.get({ id: vodVideoId })
128
129 expect(video.views).to.equal(2)
171 expect(stats.averageWatchTime).to.equal(3) 130 expect(stats.averageWatchTime).to.equal(3)
172 expect(stats.totalWatchTime).to.equal(11) 131 expect(stats.totalWatchTime).to.equal(11)
173 } 132 }
174 133
175 { 134 {
176 const stats = await servers[0].videoStats.getOverallStats({ videoId: liveVideoId }) 135 const stats = await servers[0].videoStats.getOverallStats({ videoId: liveVideoId })
177 expect(stats.views).to.equal(2) 136 const video = await servers[0].videos.get({ id: liveVideoId })
137
138 expect(video.views).to.equal(2)
178 expect(stats.averageWatchTime).to.equal(22) 139 expect(stats.averageWatchTime).to.equal(22)
179 expect(stats.totalWatchTime).to.equal(88) 140 expect(stats.totalWatchTime).to.equal(88)
180 } 141 }