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:
@@ -459,38 +459,14 @@ const ProjectController = {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
persistentUpgradePromptsAssignment(cb) {
|
|
||||||
SplitTestHandler.getAssignment(
|
|
||||||
req,
|
|
||||||
res,
|
|
||||||
'persistent-upgrade-prompt',
|
|
||||||
(err, assignment) => {
|
|
||||||
if (err) {
|
|
||||||
logger.warn(
|
|
||||||
{ err },
|
|
||||||
'failed to get "persistent-upgrade-prompt" split test assignment'
|
|
||||||
)
|
|
||||||
cb(null, { variant: 'default' })
|
|
||||||
} else {
|
|
||||||
cb(null, assignment)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
(err, results) => {
|
(err, results) => {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
OError.tag(err, 'error getting data for project list page')
|
OError.tag(err, 'error getting data for project list page')
|
||||||
return next(err)
|
return next(err)
|
||||||
}
|
}
|
||||||
const {
|
const { notifications, user, userEmailsData, primaryEmailCheckActive } =
|
||||||
notifications,
|
results
|
||||||
user,
|
|
||||||
userEmailsData,
|
|
||||||
primaryEmailCheckActive,
|
|
||||||
persistentUpgradePromptsAssignment,
|
|
||||||
} = results
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
user &&
|
user &&
|
||||||
@@ -621,7 +597,6 @@ const ProjectController = {
|
|||||||
|
|
||||||
// Persistent upgrade prompts
|
// Persistent upgrade prompts
|
||||||
const showToolbarUpgradePrompt =
|
const showToolbarUpgradePrompt =
|
||||||
persistentUpgradePromptsAssignment.variant === 'persistent-upgrade' &&
|
|
||||||
!results.hasSubscription &&
|
!results.hasSubscription &&
|
||||||
!userEmails.some(e => e.emailHasInstitutionLicence)
|
!userEmails.some(e => e.emailHasInstitutionLicence)
|
||||||
|
|
||||||
@@ -909,21 +884,6 @@ const ProjectController = {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
persistentUpgradePromptsAssignment(cb) {
|
|
||||||
SplitTestHandler.getAssignment(
|
|
||||||
req,
|
|
||||||
res,
|
|
||||||
'persistent-upgrade-prompt',
|
|
||||||
(error, assignment) => {
|
|
||||||
// do not fail editor load if assignment fails
|
|
||||||
if (error) {
|
|
||||||
cb(null, { variant: 'default' })
|
|
||||||
} else {
|
|
||||||
cb(null, assignment)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
(
|
(
|
||||||
err,
|
err,
|
||||||
@@ -940,7 +900,6 @@ const ProjectController = {
|
|||||||
pdfDetachAssignment,
|
pdfDetachAssignment,
|
||||||
pdfjsAssignment,
|
pdfjsAssignment,
|
||||||
dictionaryEditorAssignment,
|
dictionaryEditorAssignment,
|
||||||
persistentUpgradePromptsAssignment,
|
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
@@ -1053,8 +1012,6 @@ const ProjectController = {
|
|||||||
|
|
||||||
// Persistent upgrade prompts
|
// Persistent upgrade prompts
|
||||||
const showHeaderUpgradePrompt =
|
const showHeaderUpgradePrompt =
|
||||||
persistentUpgradePromptsAssignment.variant ===
|
|
||||||
'persistent-upgrade' &&
|
|
||||||
userId &&
|
userId &&
|
||||||
!subscription &&
|
!subscription &&
|
||||||
!userIsMemberOfGroupSubscription &&
|
!userIsMemberOfGroupSubscription &&
|
||||||
|
|||||||
@@ -133,13 +133,3 @@ if (isOverleaf)
|
|||||||
a.btn.btn-info(
|
a.btn.btn-info(
|
||||||
href="/user/settings"
|
href="/user/settings"
|
||||||
) Add Affiliation
|
) Add Affiliation
|
||||||
|
|
||||||
unless (showToolbarUpgradePrompt)
|
|
||||||
.row-spaced(ng-if="hasProjects && userHasNoSubscription && !userOnPayingUniversity", ng-cloak).text-centered
|
|
||||||
hr
|
|
||||||
p.small #{translate("on_free_sl")}
|
|
||||||
p
|
|
||||||
a(href="/user/subscription/plans" ng-click="upgradeSubscription()").btn.btn-primary #{translate("upgrade")}
|
|
||||||
p.small.text-centered
|
|
||||||
| #{translate("or_unlock_features_bonus")}
|
|
||||||
a(href="/user/bonus" ng-click="share()") #{translate("sharing_sl")}.
|
|
||||||
|
|||||||
@@ -4,24 +4,9 @@ export default App.controller(
|
|||||||
'LeftHandMenuPromoController',
|
'LeftHandMenuPromoController',
|
||||||
function ($scope, UserAffiliationsDataService, eventTracking) {
|
function ($scope, UserAffiliationsDataService, eventTracking) {
|
||||||
$scope.hasProjects = window.data.projects.length > 0
|
$scope.hasProjects = window.data.projects.length > 0
|
||||||
$scope.userHasNoSubscription = window.userHasNoSubscription
|
|
||||||
|
|
||||||
$scope.upgradeSubscription = function () {
|
|
||||||
eventTracking.send('subscription-funnel', 'project-page', 'upgrade')
|
|
||||||
eventTracking.sendMB('upgrade-button-click', {
|
|
||||||
source: 'dashboard',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.share = function () {
|
|
||||||
eventTracking.send('subscription-funnel', 'project-page', 'sharing')
|
|
||||||
}
|
|
||||||
|
|
||||||
const _userHasNoAffiliation = function () {
|
const _userHasNoAffiliation = function () {
|
||||||
$scope.withAffiliations = window.data.userAffiliations.length > 0
|
$scope.withAffiliations = window.data.userAffiliations.length > 0
|
||||||
$scope.userOnPayingUniversity = window.data.userAffiliations.some(
|
|
||||||
affiliation => affiliation.licence && affiliation.licence !== 'free'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_userHasNoAffiliation()
|
_userHasNoAffiliation()
|
||||||
|
|||||||
@@ -198,6 +198,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.toolbar-header-upgrade-prompt {
|
.toolbar-header-upgrade-prompt {
|
||||||
|
margin-left: 10px;
|
||||||
@media (max-width: @screen-md-min) {
|
@media (max-width: @screen-md-min) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -556,53 +556,36 @@ describe('ProjectController', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('persistent upgrade prompt', function () {
|
describe('persistent upgrade prompt', function () {
|
||||||
describe('if the user has the default variant', function (done) {
|
it('should show for a user without a subscription or only non-paid affiliations', function (done) {
|
||||||
it('should not show', function (done) {
|
this.res.render = (pageName, opts) => {
|
||||||
this.res.render = (pageName, opts) => {
|
expect(opts.showToolbarUpgradePrompt).to.equal(true)
|
||||||
expect(opts.showToolbarUpgradePrompt).to.equal(false)
|
done()
|
||||||
done()
|
}
|
||||||
}
|
this.ProjectController.projectListPage(this.req, this.res)
|
||||||
this.ProjectController.projectListPage(this.req, this.res)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
it('should not show for a user with a subscription', function (done) {
|
||||||
describe('if the user has the persistent-upgrade variant', function (done) {
|
this.LimitationsManager.hasPaidSubscription = sinon
|
||||||
beforeEach(function () {
|
.stub()
|
||||||
this.SplitTestHandler.getAssignment
|
.callsArgWith(1, null, true)
|
||||||
.withArgs(this.req, this.res, 'persistent-upgrade-prompt')
|
this.res.render = (pageName, opts) => {
|
||||||
.yields(null, { variant: 'persistent-upgrade' })
|
expect(opts.showToolbarUpgradePrompt).to.equal(false)
|
||||||
})
|
done()
|
||||||
it('should show for a user without a subscription or only non-paid affiliations', function (done) {
|
}
|
||||||
this.res.render = (pageName, opts) => {
|
this.ProjectController.projectListPage(this.req, this.res)
|
||||||
expect(opts.showToolbarUpgradePrompt).to.equal(true)
|
})
|
||||||
done()
|
it('should not show for a user with an affiliated paid university', function (done) {
|
||||||
}
|
const emailWithProAffiliation = {
|
||||||
this.ProjectController.projectListPage(this.req, this.res)
|
email: 'pro@example.com',
|
||||||
})
|
emailHasInstitutionLicence: true,
|
||||||
it('should not show for a user with a subscription', function (done) {
|
}
|
||||||
this.LimitationsManager.hasPaidSubscription = sinon
|
this.UserGetter.getUserFullEmails = sinon
|
||||||
.stub()
|
.stub()
|
||||||
.callsArgWith(1, null, true)
|
.yields(null, [emailWithProAffiliation])
|
||||||
this.res.render = (pageName, opts) => {
|
this.res.render = (pageName, opts) => {
|
||||||
expect(opts.showToolbarUpgradePrompt).to.equal(false)
|
expect(opts.showToolbarUpgradePrompt).to.equal(false)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
this.ProjectController.projectListPage(this.req, this.res)
|
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()
|
.stub()
|
||||||
.callsArgWith(1, null, null)
|
.callsArgWith(1, null, null)
|
||||||
})
|
})
|
||||||
describe('if the user has the default variant', function (done) {
|
it('should show for a user without a subscription or only non-paid affiliations', function (done) {
|
||||||
it('should not show', function (done) {
|
this.res.render = (pageName, opts) => {
|
||||||
this.res.render = (pageName, opts) => {
|
expect(opts.showHeaderUpgradePrompt).to.equal(true)
|
||||||
expect(opts.showHeaderUpgradePrompt).to.equal(false)
|
done()
|
||||||
done()
|
}
|
||||||
}
|
this.ProjectController.loadEditor(this.req, this.res)
|
||||||
this.ProjectController.loadEditor(this.req, this.res)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
it('should not show for a user with a personal subscription', function (done) {
|
||||||
describe('if the user has the persistent-upgrade variant', function (done) {
|
this.SubscriptionLocator.getUsersSubscription = sinon
|
||||||
beforeEach(function () {
|
.stub()
|
||||||
this.SplitTestHandler.getAssignment
|
.callsArgWith(1, null, {})
|
||||||
.withArgs(this.req, this.res, 'persistent-upgrade-prompt')
|
this.res.render = (pageName, opts) => {
|
||||||
.yields(null, { variant: 'persistent-upgrade' })
|
expect(opts.showHeaderUpgradePrompt).to.equal(false)
|
||||||
})
|
done()
|
||||||
it('should show for a user without a subscription or only non-paid affiliations', function (done) {
|
}
|
||||||
this.res.render = (pageName, opts) => {
|
this.ProjectController.loadEditor(this.req, this.res)
|
||||||
expect(opts.showHeaderUpgradePrompt).to.equal(true)
|
})
|
||||||
done()
|
it('should not show for a user who is a member of a group subscription', function (done) {
|
||||||
}
|
this.LimitationsManager.userIsMemberOfGroupSubscription = sinon
|
||||||
this.ProjectController.loadEditor(this.req, this.res)
|
.stub()
|
||||||
})
|
.callsArgWith(1, null, true)
|
||||||
it('should not show for a user with a personal subscription', function (done) {
|
this.res.render = (pageName, opts) => {
|
||||||
this.SubscriptionLocator.getUsersSubscription = sinon
|
expect(opts.showHeaderUpgradePrompt).to.equal(false)
|
||||||
.stub()
|
done()
|
||||||
.callsArgWith(1, null, {})
|
}
|
||||||
this.res.render = (pageName, opts) => {
|
this.ProjectController.loadEditor(this.req, this.res)
|
||||||
expect(opts.showHeaderUpgradePrompt).to.equal(false)
|
})
|
||||||
done()
|
it('should not show for a user with an affiliated paid university', function (done) {
|
||||||
}
|
this.InstitutionsFeatures.hasLicence = sinon
|
||||||
this.ProjectController.loadEditor(this.req, this.res)
|
.stub()
|
||||||
})
|
.callsArgWith(1, null, true)
|
||||||
it('should not show for a user who is a member of a group subscription', function (done) {
|
this.res.render = (pageName, opts) => {
|
||||||
this.LimitationsManager.userIsMemberOfGroupSubscription = sinon
|
expect(opts.showHeaderUpgradePrompt).to.equal(false)
|
||||||
.stub()
|
done()
|
||||||
.callsArgWith(1, null, true)
|
}
|
||||||
this.res.render = (pageName, opts) => {
|
this.ProjectController.loadEditor(this.req, this.res)
|
||||||
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)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user