Merge pull request #17822 from overleaf/jel-dash-usersBestSubscription

[web] Limit data sent to dash for best subscription when group

GitOrigin-RevId: d52101bec69cbb7931e9702e085b4aeb65d9d603
This commit is contained in:
Jessica Lawshe 2024-04-11 08:26:40 -05:00 committed by Copybot
parent 751e079105
commit 0cfcdf5e4d
2 changed files with 26 additions and 4 deletions

View file

@ -404,10 +404,14 @@ async function getBestSubscription(user) {
groupSubscription.planCode
)
if (_isPlanEqualOrBetter(plan, bestSubscription.plan)) {
const groupDataForView = {}
if (groupSubscription.teamName) {
groupDataForView.teamName = groupSubscription.teamName
}
const remainingTrialDays = _getRemainingTrialDays(groupSubscription)
bestSubscription = {
type: 'group',
subscription: groupSubscription,
subscription: groupDataForView,
plan,
remainingTrialDays,
}

View file

@ -269,7 +269,25 @@ describe('SubscriptionViewModelBuilder', function () {
)
assert.deepEqual(usersBestSubscription, {
type: 'group',
subscription: this.groupSubscription,
subscription: {},
plan: this.groupPlan,
remainingTrialDays: -1,
})
})
it('should return a group subscription with team name when user has one', async function () {
this.SubscriptionLocator.promises.getMemberSubscriptions
.withArgs(this.user)
.resolves([
Object.assign({}, this.groupSubscription, { teamName: 'test team' }),
])
const usersBestSubscription =
await this.SubscriptionViewModelBuilder.promises.getBestSubscription(
this.user
)
assert.deepEqual(usersBestSubscription, {
type: 'group',
subscription: { teamName: 'test team' },
plan: this.groupPlan,
remainingTrialDays: -1,
})
@ -345,7 +363,7 @@ describe('SubscriptionViewModelBuilder', function () {
assert.deepEqual(usersBestSubscription, {
type: 'group',
subscription: this.groupSubscription,
subscription: {},
plan: this.groupPlan,
remainingTrialDays: -1,
})
@ -434,7 +452,7 @@ describe('SubscriptionViewModelBuilder', function () {
assert.deepEqual(usersBestSubscription, {
type: 'group',
subscription: this.groupSubscription,
subscription: {},
plan: this.groupPlan,
remainingTrialDays: -1,
})