Merge pull request #5479 from overleaf/bg-refresh-features-on-editor-load

refresh user features on editor load when out of date

GitOrigin-RevId: ef39b5626cfdc6ed611137a6f6eca3417d3ce73f
This commit is contained in:
Brian Gough
2021-10-26 14:31:24 +01:00
committed by Copybot
parent 5862359ff0
commit e681c6322f
7 changed files with 123 additions and 3 deletions

View File

@@ -105,6 +105,10 @@ describe('ProjectController', function () {
this.Features = {
hasFeature: sinon.stub(),
}
this.FeaturesUpdater = {
featuresEpochIsCurrent: sinon.stub().returns(true),
refreshFeatures: sinon.stub().yields(null, this.user),
}
this.BrandVariationsHandler = {
getBrandVariationById: sinon
.stub()
@@ -167,6 +171,7 @@ describe('ProjectController', function () {
'../Collaborators/CollaboratorsGetter': this.CollaboratorsGetter,
'./ProjectEntityHandler': this.ProjectEntityHandler,
'../../infrastructure/Features': this.Features,
'../Subscription/FeaturesUpdater': this.FeaturesUpdater,
'../Notifications/NotificationsBuilder': this.NotificationBuilder,
'../User/UserGetter': this.UserGetter,
'../BrandVariations/BrandVariationsHandler': this
@@ -1083,6 +1088,18 @@ describe('ProjectController', function () {
this.ProjectController.loadEditor(this.req, this.res)
})
it('should refresh the user features if the epoch is outdated', function (done) {
this.FeaturesUpdater.featuresEpochIsCurrent = sinon.stub().returns(false)
this.res.render = () => {
this.FeaturesUpdater.refreshFeatures.should.have.been.calledWith(
this.user._id,
'load-editor'
)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
describe('pdf caching feature flags', function () {
/* eslint-disable mocha/no-identical-title */
function showNoVariant() {