From 1f3e9feca2caf68024168b0ea9ed39d8438fa235 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 30 Nov 2017 09:21:11 +0100 Subject: Better view counter --- server/tests/api/multiple-servers.ts | 33 +++++++++++++++++---------------- server/tests/api/single-server.ts | 5 +++++ 2 files changed, 22 insertions(+), 16 deletions(-) (limited to 'server/tests/api') 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 { doubleFollow } from '../utils' import { createUser } from '../utils/users' +import { viewVideo } from '../utils/videos' const expect = chai.expect @@ -486,10 +487,10 @@ describe('Test multiple servers', function () { this.timeout(10000) const tasks: Promise[] = [] - tasks.push(getVideo(servers[2].url, localVideosServer3[0])) - tasks.push(getVideo(servers[2].url, localVideosServer3[0])) - tasks.push(getVideo(servers[2].url, localVideosServer3[0])) - tasks.push(getVideo(servers[2].url, localVideosServer3[1])) + tasks.push(viewVideo(servers[2].url, localVideosServer3[0])) + tasks.push(viewVideo(servers[2].url, localVideosServer3[0])) + tasks.push(viewVideo(servers[2].url, localVideosServer3[0])) + tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) await Promise.all(tasks) @@ -502,8 +503,8 @@ describe('Test multiple servers', function () { const video0 = videos.find(v => v.uuid === localVideosServer3[0]) const video1 = videos.find(v => v.uuid === localVideosServer3[1]) - expect(video0.views).to.equal(7) - expect(video1.views).to.equal(5) + expect(video0.views).to.equal(3) + expect(video1.views).to.equal(1) } }) @@ -511,16 +512,16 @@ describe('Test multiple servers', function () { this.timeout(15000) const tasks: Promise[] = [] - tasks.push(getVideo(servers[0].url, remoteVideosServer1[0])) - tasks.push(getVideo(servers[1].url, remoteVideosServer2[0])) - tasks.push(getVideo(servers[1].url, remoteVideosServer2[0])) - tasks.push(getVideo(servers[2].url, remoteVideosServer3[0])) - tasks.push(getVideo(servers[2].url, remoteVideosServer3[1])) - tasks.push(getVideo(servers[2].url, remoteVideosServer3[1])) - tasks.push(getVideo(servers[2].url, remoteVideosServer3[1])) - tasks.push(getVideo(servers[2].url, localVideosServer3[1])) - tasks.push(getVideo(servers[2].url, localVideosServer3[1])) - tasks.push(getVideo(servers[2].url, localVideosServer3[1])) + tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0])) + tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0])) + tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0])) + tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0])) + tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) + tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) + tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1])) + tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) + tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) + tasks.push(viewVideo(servers[2].url, localVideosServer3[1])) await Promise.all(tasks) 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 { searchVideoWithSort, updateVideo } from '../utils' +import { viewVideo } from '../utils/videos' describe('Test a single server', function () { let server: ServerInfo = null @@ -214,6 +215,10 @@ describe('Test a single server', function () { }) it('Should have the views updated', async function () { + await viewVideo(server.url, videoId) + await viewVideo(server.url, videoId) + await viewVideo(server.url, videoId) + const res = await getVideo(server.url, videoId) const video = res.body -- cgit v1.2.3