aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-30 09:21:11 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-30 09:21:11 +0100
commit1f3e9feca2caf68024168b0ea9ed39d8438fa235 (patch)
treeb77b02d11796cf435496fd22b85c430a7ed2479f /server/tests/api
parent86d13ec2aa94ec10810ddf9c8b33314bd4968791 (diff)
downloadPeerTube-1f3e9feca2caf68024168b0ea9ed39d8438fa235.tar.gz
PeerTube-1f3e9feca2caf68024168b0ea9ed39d8438fa235.tar.zst
PeerTube-1f3e9feca2caf68024168b0ea9ed39d8438fa235.zip
Better view counter
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/multiple-servers.ts33
-rw-r--r--server/tests/api/single-server.ts5
2 files changed, 22 insertions, 16 deletions
diff --git a/server/tests/api/multiple-servers.ts b/server/tests/api/multiple-servers.ts
index 052b0231f..c80ded862 100644
--- a/server/tests/api/multiple-servers.ts
+++ b/server/tests/api/multiple-servers.ts
@@ -25,6 +25,7 @@ import {
25 doubleFollow 25 doubleFollow
26} from '../utils' 26} from '../utils'
27import { createUser } from '../utils/users' 27import { createUser } from '../utils/users'
28import { viewVideo } from '../utils/videos'
28 29
29const expect = chai.expect 30const expect = chai.expect
30 31
@@ -486,10 +487,10 @@ describe('Test multiple servers', function () {
486 this.timeout(10000) 487 this.timeout(10000)
487 488
488 const tasks: Promise<any>[] = [] 489 const tasks: Promise<any>[] = []
489 tasks.push(getVideo(servers[2].url, localVideosServer3[0])) 490 tasks.push(viewVideo(servers[2].url, localVideosServer3[0]))
490 tasks.push(getVideo(servers[2].url, localVideosServer3[0])) 491 tasks.push(viewVideo(servers[2].url, localVideosServer3[0]))
491 tasks.push(getVideo(servers[2].url, localVideosServer3[0])) 492 tasks.push(viewVideo(servers[2].url, localVideosServer3[0]))
492 tasks.push(getVideo(servers[2].url, localVideosServer3[1])) 493 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
493 494
494 await Promise.all(tasks) 495 await Promise.all(tasks)
495 496
@@ -502,8 +503,8 @@ describe('Test multiple servers', function () {
502 const video0 = videos.find(v => v.uuid === localVideosServer3[0]) 503 const video0 = videos.find(v => v.uuid === localVideosServer3[0])
503 const video1 = videos.find(v => v.uuid === localVideosServer3[1]) 504 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
504 505
505 expect(video0.views).to.equal(7) 506 expect(video0.views).to.equal(3)
506 expect(video1.views).to.equal(5) 507 expect(video1.views).to.equal(1)
507 } 508 }
508 }) 509 })
509 510
@@ -511,16 +512,16 @@ describe('Test multiple servers', function () {
511 this.timeout(15000) 512 this.timeout(15000)
512 513
513 const tasks: Promise<any>[] = [] 514 const tasks: Promise<any>[] = []
514 tasks.push(getVideo(servers[0].url, remoteVideosServer1[0])) 515 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
515 tasks.push(getVideo(servers[1].url, remoteVideosServer2[0])) 516 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
516 tasks.push(getVideo(servers[1].url, remoteVideosServer2[0])) 517 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
517 tasks.push(getVideo(servers[2].url, remoteVideosServer3[0])) 518 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
518 tasks.push(getVideo(servers[2].url, remoteVideosServer3[1])) 519 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
519 tasks.push(getVideo(servers[2].url, remoteVideosServer3[1])) 520 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
520 tasks.push(getVideo(servers[2].url, remoteVideosServer3[1])) 521 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
521 tasks.push(getVideo(servers[2].url, localVideosServer3[1])) 522 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
522 tasks.push(getVideo(servers[2].url, localVideosServer3[1])) 523 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
523 tasks.push(getVideo(servers[2].url, localVideosServer3[1])) 524 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
524 525
525 await Promise.all(tasks) 526 await Promise.all(tasks)
526 527
diff --git a/server/tests/api/single-server.ts b/server/tests/api/single-server.ts
index 40e2c64fe..041d13225 100644
--- a/server/tests/api/single-server.ts
+++ b/server/tests/api/single-server.ts
@@ -33,6 +33,7 @@ import {
33 searchVideoWithSort, 33 searchVideoWithSort,
34 updateVideo 34 updateVideo
35} from '../utils' 35} from '../utils'
36import { viewVideo } from '../utils/videos'
36 37
37describe('Test a single server', function () { 38describe('Test a single server', function () {
38 let server: ServerInfo = null 39 let server: ServerInfo = null
@@ -214,6 +215,10 @@ describe('Test a single server', function () {
214 }) 215 })
215 216
216 it('Should have the views updated', async function () { 217 it('Should have the views updated', async function () {
218 await viewVideo(server.url, videoId)
219 await viewVideo(server.url, videoId)
220 await viewVideo(server.url, videoId)
221
217 const res = await getVideo(server.url, videoId) 222 const res = await getVideo(server.url, videoId)
218 223
219 const video = res.body 224 const video = res.body