Merge pull request #4035 from overleaf/jel-reconfirmation-dropbox-notification

Notification for Dropbox unlinked due to reconfirmation lapse

GitOrigin-RevId: 03d2bed922e1d3dd993f9227b8e7675af42eda4b
This commit is contained in:
Jessica Lawshe
2021-05-19 02:06:06 +00:00
committed by Copybot
parent 1b5d5bfb5b
commit 9b29fa7cbc
13 changed files with 95 additions and 286 deletions
@@ -1,70 +0,0 @@
const { expect } = require('chai')
const Settings = require('settings-sharelatex')
const UserHelper = require('./helpers/UserHelper')
const MockV1ApiClass = require('./mocks/MockV1Api')
const InstitutionsReconfirmationHandler = require('../../../app/src/Features/Institutions/InstitutionsReconfirmationHandler')
let MockV1Api
let userHelper = new UserHelper()
before(function () {
MockV1Api = MockV1ApiClass.instance()
})
describe('InstitutionsReconfirmationHandler', function () {
const institutionUsers = []
let result
beforeEach(async function () {
// create institution
const domain = 'institution-1.com'
const maxConfirmationMonths = 6
MockV1Api.createInstitution({
commonsAccount: true,
confirmed: true,
hostname: domain,
maxConfirmationMonths,
})
// create users affiliated with institution
async function _createInstitutionUserPastReconfirmation() {
userHelper = await UserHelper.createUser()
const userId = userHelper.user._id
// add the affiliation
userHelper = await UserHelper.loginUser(
userHelper.getDefaultEmailPassword()
)
const institutionEmail = `${userId}@${domain}`
await userHelper.addEmailAndConfirm(userId, institutionEmail)
institutionUsers.push(userId)
// backdate confirmation
await userHelper.changeConfirmedToPastReconfirmation(
userId,
institutionEmail,
maxConfirmationMonths
)
// verify user has features before script run
const result = await UserHelper.getUser(
{ _id: userHelper.user._id },
{ features: 1 }
)
expect(result.user.features).to.deep.equal(Settings.features.professional)
return userId
}
await _createInstitutionUserPastReconfirmation()
await _createInstitutionUserPastReconfirmation()
await _createInstitutionUserPastReconfirmation()
result = await InstitutionsReconfirmationHandler.processLapsed()
})
it('should refresh features', async function () {
expect(result.failedToRefresh.length).to.equal(0)
expect(result.refreshedUsers.length).to.equal(3)
})
})