diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index b1e189acc2..8330ef1c12 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -443,6 +443,9 @@ const ProjectController = { }) }, usersBestSubscription(cb) { + if (!Features.hasFeature('saas')) { + return cb() + } SubscriptionViewModelBuilder.getBestSubscription( { _id: userId }, (err, subscription) => { @@ -1113,6 +1116,7 @@ const ProjectController = { // Persistent upgrade prompts const showHeaderUpgradePrompt = + Features.hasFeature('saas') && userId && !subscription && !userIsMemberOfGroupSubscription && diff --git a/services/web/test/unit/src/Project/ProjectControllerTests.js b/services/web/test/unit/src/Project/ProjectControllerTests.js index d2c4b972a4..fc0da6030d 100644 --- a/services/web/test/unit/src/Project/ProjectControllerTests.js +++ b/services/web/test/unit/src/Project/ProjectControllerTests.js @@ -524,7 +524,8 @@ describe('ProjectController', function () { this.ProjectController.projectListPage(this.req, this.res) }) - it("should send the user's best subscription", function (done) { + it("should send the user's best subscription when saas feature present", function (done) { + this.Features.hasFeature.withArgs('saas').returns(true) this.res.render = (pageName, opts) => { expect(opts.usersBestSubscription).to.deep.include({ type: 'free' }) done() @@ -532,6 +533,15 @@ describe('ProjectController', function () { this.ProjectController.projectListPage(this.req, this.res) }) + it('should not return a best subscription without saas feature', function (done) { + this.Features.hasFeature.withArgs('saas').returns(false) + this.res.render = (pageName, opts) => { + expect(opts.usersBestSubscription).to.be.undefined + done() + } + this.ProjectController.projectListPage(this.req, this.res) + }) + describe('front widget', function (done) { beforeEach(function () { this.settings.overleaf = { @@ -1404,11 +1414,21 @@ describe('ProjectController', function () { describe('persistent upgrade prompt', function () { beforeEach(function () { + // default to saas enabled + this.Features.hasFeature.withArgs('saas').returns(true) // default to without a subscription this.SubscriptionLocator.getUsersSubscription = sinon .stub() .callsArgWith(1, null, null) }) + it('should not show without the saas feature', function (done) { + this.Features.hasFeature.withArgs('saas').returns(false) + this.res.render = (pageName, opts) => { + expect(opts.showHeaderUpgradePrompt).to.equal(false) + done() + } + this.ProjectController.loadEditor(this.req, this.res) + }) it('should show for a user without a subscription or only non-paid affiliations', function (done) { this.res.render = (pageName, opts) => { expect(opts.showHeaderUpgradePrompt).to.equal(true)