[web] Expose metric for active users in SP (#20130)
* [web] Expose metric for active users in SP * Removed redundant UserHandler.setupLoginData() In the past this method was also calling a now deleted notifyDomainLicence(), but now this is just an alias for populateTeamInvites() * Added migration for `lastActive` * Added secondary read precedence to count active users GitOrigin-RevId: 86d6db31e1ae74ae40c6599e6acb731d8c4a04bd
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
const modulePath = '../../../../app/src/Features/User/UserHandler.js'
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
@@ -14,9 +15,18 @@ describe('UserHandler', function () {
|
||||
createTeamInvitesForLegacyInvitedEmail: sinon.stub().yields(),
|
||||
}
|
||||
|
||||
this.db = {
|
||||
users: {
|
||||
find: sinon.stub().returns({
|
||||
count: sinon.stub().resolves(2),
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
this.UserHandler = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
'../Subscription/TeamInvitesHandler': this.TeamInvitesHandler,
|
||||
'../../infrastructure/mongodb': { db: this.db },
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -32,4 +42,10 @@ describe('UserHandler', function () {
|
||||
.should.eq(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('countActiveUsers', function () {
|
||||
it('return user count from DB lookup', async function () {
|
||||
expect(await this.UserHandler.promises.countActiveUsers()).to.equal(2)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user