Check features before showing upgrade prompts
GitOrigin-RevId: 6f0ed9eca88197e1160b149cb304e27075aa0627
This commit is contained in:
@@ -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 &&
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user