mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-10 22:50:46 +02:00
[web] Fix feature refresh handling in ProjectController (#32353)
* Update tests to check that refreshed features are used correctly * Fix feature refresh handling in ProjectController GitOrigin-RevId: 14c0cedf72f6cfe6657aa35fab16e319a37231e7
This commit is contained in:
@@ -1082,10 +1082,11 @@ const _ProjectController = {
|
||||
refreshTimeoutHandler(),
|
||||
(async () => {
|
||||
try {
|
||||
user.features = await FeaturesUpdater.promises.refreshFeatures(
|
||||
const { features } = await FeaturesUpdater.promises.refreshFeatures(
|
||||
user._id,
|
||||
'load-editor'
|
||||
)
|
||||
user.features = features
|
||||
metrics.inc('features-refresh', 1, {
|
||||
path: 'load-editor',
|
||||
status: 'success',
|
||||
|
||||
@@ -169,7 +169,10 @@ describe('ProjectController', function () {
|
||||
ctx.FeaturesUpdater = {
|
||||
featuresEpochIsCurrent: sinon.stub().returns(true),
|
||||
promises: {
|
||||
refreshFeatures: sinon.stub().resolves(ctx.user),
|
||||
refreshFeatures: sinon.stub().resolves({
|
||||
features: { symbolPalette: true },
|
||||
featuresChanged: true,
|
||||
}),
|
||||
},
|
||||
}
|
||||
ctx.BrandVariationsHandler = {
|
||||
@@ -1112,16 +1115,20 @@ describe('ProjectController', function () {
|
||||
})
|
||||
|
||||
it('should refresh the user features if the epoch is outdated', async function (ctx) {
|
||||
await new Promise(resolve => {
|
||||
ctx.Features.hasFeature.withArgs('saas').returns(true)
|
||||
await new Promise((resolve, reject) => {
|
||||
ctx.FeaturesUpdater.featuresEpochIsCurrent = sinon.stub().returns(false)
|
||||
ctx.res.render = () => {
|
||||
ctx.res.render = (_, data) => {
|
||||
ctx.FeaturesUpdater.promises.refreshFeatures.should.have.been.calledWith(
|
||||
ctx.user._id,
|
||||
'load-editor'
|
||||
)
|
||||
expect(data.showSymbolPalette).to.equal(true)
|
||||
resolve()
|
||||
}
|
||||
ctx.ProjectController.loadEditor(ctx.req, ctx.res)
|
||||
ctx.ProjectController.loadEditor(ctx.req, ctx.res, err => {
|
||||
if (err) reject(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user