diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-07 10:39:09 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-05-07 10:39:09 +0200 |
commit | 3cc665f48fd233d09f778d7e887488dde6f03ef6 (patch) | |
tree | ba8503723206ef17f4b8e4a2e40125472b28dbaf /server/tests/api/server/stats.ts | |
parent | ee8e602ef9761b4869e14d4d3ed24a2e18f22c65 (diff) | |
download | PeerTube-3cc665f48fd233d09f778d7e887488dde6f03ef6.tar.gz PeerTube-3cc665f48fd233d09f778d7e887488dde6f03ef6.tar.zst PeerTube-3cc665f48fd233d09f778d7e887488dde6f03ef6.zip |
Add last login date to users
Diffstat (limited to 'server/tests/api/server/stats.ts')
-rw-r--r-- | server/tests/api/server/stats.ts | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts index fe956413c..637525ff8 100644 --- a/server/tests/api/server/stats.ts +++ b/server/tests/api/server/stats.ts | |||
@@ -12,7 +12,8 @@ import { | |||
12 | ServerInfo, unfollow, | 12 | ServerInfo, unfollow, |
13 | uploadVideo, | 13 | uploadVideo, |
14 | viewVideo, | 14 | viewVideo, |
15 | wait | 15 | wait, |
16 | userLogin | ||
16 | } from '../../../../shared/extra-utils' | 17 | } from '../../../../shared/extra-utils' |
17 | import { setAccessTokensToServers } from '../../../../shared/extra-utils/index' | 18 | import { setAccessTokensToServers } from '../../../../shared/extra-utils/index' |
18 | import { getStats } from '../../../../shared/extra-utils/server/stats' | 19 | import { getStats } from '../../../../shared/extra-utils/server/stats' |
@@ -23,6 +24,10 @@ const expect = chai.expect | |||
23 | 24 | ||
24 | describe('Test stats (excluding redundancy)', function () { | 25 | describe('Test stats (excluding redundancy)', function () { |
25 | let servers: ServerInfo[] = [] | 26 | let servers: ServerInfo[] = [] |
27 | const user = { | ||
28 | username: 'user1', | ||
29 | password: 'super_password' | ||
30 | } | ||
26 | 31 | ||
27 | before(async function () { | 32 | before(async function () { |
28 | this.timeout(60000) | 33 | this.timeout(60000) |
@@ -31,10 +36,6 @@ describe('Test stats (excluding redundancy)', function () { | |||
31 | 36 | ||
32 | await doubleFollow(servers[0], servers[1]) | 37 | await doubleFollow(servers[0], servers[1]) |
33 | 38 | ||
34 | const user = { | ||
35 | username: 'user1', | ||
36 | password: 'super_password' | ||
37 | } | ||
38 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 39 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) |
39 | 40 | ||
40 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { fixture: 'video_short.webm' }) | 41 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { fixture: 'video_short.webm' }) |
@@ -96,6 +97,8 @@ describe('Test stats (excluding redundancy)', function () { | |||
96 | }) | 97 | }) |
97 | 98 | ||
98 | it('Should have the correct total videos stats after an unfollow', async function () { | 99 | it('Should have the correct total videos stats after an unfollow', async function () { |
100 | this.timeout(15000) | ||
101 | |||
99 | await unfollow(servers[2].url, servers[2].accessToken, servers[0]) | 102 | await unfollow(servers[2].url, servers[2].accessToken, servers[0]) |
100 | await waitJobs(servers) | 103 | await waitJobs(servers) |
101 | 104 | ||
@@ -105,6 +108,28 @@ describe('Test stats (excluding redundancy)', function () { | |||
105 | expect(data.totalVideos).to.equal(0) | 108 | expect(data.totalVideos).to.equal(0) |
106 | }) | 109 | }) |
107 | 110 | ||
111 | it('Should have the correct active users stats', async function () { | ||
112 | const server = servers[0] | ||
113 | |||
114 | { | ||
115 | const res = await getStats(server.url) | ||
116 | const data: ServerStats = res.body | ||
117 | expect(data.totalDailyActiveUsers).to.equal(1) | ||
118 | expect(data.totalWeeklyActiveUsers).to.equal(1) | ||
119 | expect(data.totalMonthlyActiveUsers).to.equal(1) | ||
120 | } | ||
121 | |||
122 | { | ||
123 | await userLogin(server, user) | ||
124 | |||
125 | const res = await getStats(server.url) | ||
126 | const data: ServerStats = res.body | ||
127 | expect(data.totalDailyActiveUsers).to.equal(2) | ||
128 | expect(data.totalWeeklyActiveUsers).to.equal(2) | ||
129 | expect(data.totalMonthlyActiveUsers).to.equal(2) | ||
130 | } | ||
131 | }) | ||
132 | |||
108 | after(async function () { | 133 | after(async function () { |
109 | await cleanupTests(servers) | 134 | await cleanupTests(servers) |
110 | }) | 135 | }) |