Merge pull request #23972 from overleaf/jdt-grant-assist-via-wf-set-trait

enable granting of premium error assist based on WF entitlement to bu…

GitOrigin-RevId: 9d21cf8755c881bdc698c0cf9891076ecefd34eb
This commit is contained in:
Jimmy Domagala-Tang
2025-03-11 13:10:28 -04:00
committed by Copybot
parent 7708bd1883
commit e48be7b195
5 changed files with 91 additions and 1 deletions
@@ -1121,6 +1121,44 @@ describe('ProjectController', function () {
this.ProjectController.loadEditor(this.req, this.res)
})
})
describe('when fetching the users featureSet', function () {
beforeEach(function () {
this.Modules.promises.hooks.fire = sinon.stub().resolves()
this.user.features = {}
})
it('should take into account features overrides from modules', function (done) {
// this case occurs when the user has bought the ai bundle on WF, which should include our error assistant
const bundleFeatures = { aiErrorAssistant: true }
this.user.features = { aiErrorAssistant: false }
this.Modules.promises.hooks.fire = sinon
.stub()
.resolves([bundleFeatures])
this.res.render = (pageName, opts) => {
expect(opts.user.features).to.deep.equal(bundleFeatures)
this.Modules.promises.hooks.fire.should.have.been.calledWith(
'getModuleProvidedFeatures',
this.user._id
)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
it('should handle modules not returning any features', function (done) {
this.Modules.promises.hooks.fire = sinon.stub().resolves([])
this.res.render = (pageName, opts) => {
expect(opts.user.features).to.deep.equal({})
this.Modules.promises.hooks.fire.should.have.been.calledWith(
'getModuleProvidedFeatures',
this.user._id
)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
})
})
describe('userProjectsJson', function () {