mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 21:01:33 +02:00
* [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
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
const sinon = require('sinon')
|
|
const { expect } = require('chai')
|
|
const modulePath = '../../../../app/src/Features/User/UserHandler.js'
|
|
const SandboxedModule = require('sandboxed-module')
|
|
|
|
describe('UserHandler', function () {
|
|
beforeEach(function () {
|
|
this.user = {
|
|
_id: '12390i',
|
|
email: 'bob@bob.com',
|
|
remove: sinon.stub().callsArgWith(0),
|
|
}
|
|
|
|
this.TeamInvitesHandler = {
|
|
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 },
|
|
},
|
|
})
|
|
})
|
|
|
|
describe('populateTeamInvites', function () {
|
|
beforeEach(function (done) {
|
|
this.UserHandler.populateTeamInvites(this.user, done)
|
|
})
|
|
|
|
it('notifies the user about legacy team invites', function () {
|
|
this.TeamInvitesHandler.createTeamInvitesForLegacyInvitedEmail
|
|
.calledWith(this.user.email)
|
|
.should.eq(true)
|
|
})
|
|
})
|
|
|
|
describe('countActiveUsers', function () {
|
|
it('return user count from DB lookup', async function () {
|
|
expect(await this.UserHandler.promises.countActiveUsers()).to.equal(2)
|
|
})
|
|
})
|
|
})
|