Merge pull request #8240 from overleaf/tm-teardown-persistent-upgrade-test

Teardown persistent upgrade prompt split test and fix styling

GitOrigin-RevId: 8776231c3308c5f08b91232c962c9796a5f4afa0
This commit is contained in:
Thomas
2022-06-01 15:18:19 +02:00
committed by Copybot
parent df35a67707
commit 5e2933e2fe
5 changed files with 67 additions and 168 deletions

View File

@@ -556,53 +556,36 @@ describe('ProjectController', function () {
})
describe('persistent upgrade prompt', function () {
describe('if the user has the default variant', function (done) {
it('should not show', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.showToolbarUpgradePrompt).to.equal(false)
done()
}
this.ProjectController.projectListPage(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.showToolbarUpgradePrompt).to.equal(true)
done()
}
this.ProjectController.projectListPage(this.req, this.res)
})
describe('if the user has the persistent-upgrade variant', function (done) {
beforeEach(function () {
this.SplitTestHandler.getAssignment
.withArgs(this.req, this.res, 'persistent-upgrade-prompt')
.yields(null, { variant: 'persistent-upgrade' })
})
it('should show for a user without a subscription or only non-paid affiliations', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.showToolbarUpgradePrompt).to.equal(true)
done()
}
this.ProjectController.projectListPage(this.req, this.res)
})
it('should not show for a user with a subscription', function (done) {
this.LimitationsManager.hasPaidSubscription = sinon
.stub()
.callsArgWith(1, null, true)
this.res.render = (pageName, opts) => {
expect(opts.showToolbarUpgradePrompt).to.equal(false)
done()
}
this.ProjectController.projectListPage(this.req, this.res)
})
it('should not show for a user with an affiliated paid university', function (done) {
const emailWithProAffiliation = {
email: 'pro@example.com',
emailHasInstitutionLicence: true,
}
this.UserGetter.getUserFullEmails = sinon
.stub()
.yields(null, [emailWithProAffiliation])
this.res.render = (pageName, opts) => {
expect(opts.showToolbarUpgradePrompt).to.equal(false)
done()
}
this.ProjectController.projectListPage(this.req, this.res)
})
it('should not show for a user with a subscription', function (done) {
this.LimitationsManager.hasPaidSubscription = sinon
.stub()
.callsArgWith(1, null, true)
this.res.render = (pageName, opts) => {
expect(opts.showToolbarUpgradePrompt).to.equal(false)
done()
}
this.ProjectController.projectListPage(this.req, this.res)
})
it('should not show for a user with an affiliated paid university', function (done) {
const emailWithProAffiliation = {
email: 'pro@example.com',
emailHasInstitutionLicence: true,
}
this.UserGetter.getUserFullEmails = sinon
.stub()
.yields(null, [emailWithProAffiliation])
this.res.render = (pageName, opts) => {
expect(opts.showToolbarUpgradePrompt).to.equal(false)
done()
}
this.ProjectController.projectListPage(this.req, this.res)
})
})
@@ -1509,59 +1492,42 @@ describe('ProjectController', function () {
.stub()
.callsArgWith(1, null, null)
})
describe('if the user has the default variant', function (done) {
it('should not show', function (done) {
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)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
describe('if the user has the persistent-upgrade variant', function (done) {
beforeEach(function () {
this.SplitTestHandler.getAssignment
.withArgs(this.req, this.res, 'persistent-upgrade-prompt')
.yields(null, { variant: 'persistent-upgrade' })
})
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)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
it('should not show for a user with a personal subscription', function (done) {
this.SubscriptionLocator.getUsersSubscription = sinon
.stub()
.callsArgWith(1, null, {})
this.res.render = (pageName, opts) => {
expect(opts.showHeaderUpgradePrompt).to.equal(false)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
it('should not show for a user who is a member of a group subscription', function (done) {
this.LimitationsManager.userIsMemberOfGroupSubscription = sinon
.stub()
.callsArgWith(1, null, true)
this.res.render = (pageName, opts) => {
expect(opts.showHeaderUpgradePrompt).to.equal(false)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
it('should not show for a user with an affiliated paid university', function (done) {
this.InstitutionsFeatures.hasLicence = sinon
.stub()
.callsArgWith(1, null, true)
this.res.render = (pageName, opts) => {
expect(opts.showHeaderUpgradePrompt).to.equal(false)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
it('should not show for a user with a personal subscription', function (done) {
this.SubscriptionLocator.getUsersSubscription = sinon
.stub()
.callsArgWith(1, null, {})
this.res.render = (pageName, opts) => {
expect(opts.showHeaderUpgradePrompt).to.equal(false)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
it('should not show for a user who is a member of a group subscription', function (done) {
this.LimitationsManager.userIsMemberOfGroupSubscription = sinon
.stub()
.callsArgWith(1, null, true)
this.res.render = (pageName, opts) => {
expect(opts.showHeaderUpgradePrompt).to.equal(false)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
it('should not show for a user with an affiliated paid university', function (done) {
this.InstitutionsFeatures.hasLicence = sinon
.stub()
.callsArgWith(1, null, true)
this.res.render = (pageName, opts) => {
expect(opts.showHeaderUpgradePrompt).to.equal(false)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
})
})