aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-07 10:39:09 +0200
committerChocobozzz <me@florianbigard.com>2020-05-07 10:39:09 +0200
commit3cc665f48fd233d09f778d7e887488dde6f03ef6 (patch)
treeba8503723206ef17f4b8e4a2e40125472b28dbaf /server/tests/api
parentee8e602ef9761b4869e14d4d3ed24a2e18f22c65 (diff)
downloadPeerTube-3cc665f48fd233d09f778d7e887488dde6f03ef6.tar.gz
PeerTube-3cc665f48fd233d09f778d7e887488dde6f03ef6.tar.zst
PeerTube-3cc665f48fd233d09f778d7e887488dde6f03ef6.zip
Add last login date to users
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/server/stats.ts35
-rw-r--r--server/tests/api/users/users.ts3
2 files changed, 33 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'
17import { setAccessTokensToServers } from '../../../../shared/extra-utils/index' 18import { setAccessTokensToServers } from '../../../../shared/extra-utils/index'
18import { getStats } from '../../../../shared/extra-utils/server/stats' 19import { getStats } from '../../../../shared/extra-utils/server/stats'
@@ -23,6 +24,10 @@ const expect = chai.expect
23 24
24describe('Test stats (excluding redundancy)', function () { 25describe('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 })
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index f3b732632..c0cbce360 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -418,6 +418,9 @@ describe('Test users', function () {
418 expect(rootUser.email).to.equal('admin' + server.internalServerNumber + '@example.com') 418 expect(rootUser.email).to.equal('admin' + server.internalServerNumber + '@example.com')
419 expect(user.nsfwPolicy).to.equal('display') 419 expect(user.nsfwPolicy).to.equal('display')
420 420
421 expect(rootUser.lastLoginDate).to.exist
422 expect(user.lastLoginDate).to.exist
423
421 userId = user.id 424 userId = user.id
422 }) 425 })
423 426