Merge pull request #26397 from overleaf/kh-use-new-price-lookups

[web] use new price lookup keys

GitOrigin-RevId: f4c077d946100862aaea0288d5035a34d6188e83
This commit is contained in:
Kristina
2025-06-17 08:05:51 +00:00
committed by Copybot
parent 9aa261eaf6
commit 6b38336c7b
5 changed files with 135 additions and 82 deletions
@@ -50,84 +50,111 @@ describe('PlansLocator', function () {
})
})
describe('mapRecurlyPlanCodeToStripeLookupKey', function () {
describe('buildStripeLookupKey', function () {
it('should map "collaborator" plan code to stripe lookup keys', function () {
const planCode = 'collaborator'
const lookupKey =
this.PlansLocator.mapRecurlyPlanCodeToStripeLookupKey(planCode)
expect(lookupKey).to.equal('collaborator_may2025')
const currency = 'eur'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
planCode,
currency
)
expect(lookupKey).to.equal('standard_monthly_jun2025_eur')
})
it('should map "collaborator_free_trial_7_days" plan code to stripe lookup keys', function () {
const planCode = 'collaborator_free_trial_7_days'
const lookupKey =
this.PlansLocator.mapRecurlyPlanCodeToStripeLookupKey(planCode)
expect(lookupKey).to.equal('collaborator_may2025')
const currency = 'eur'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
planCode,
currency
)
expect(lookupKey).to.equal('standard_monthly_jun2025_eur')
})
it('should map "collaborator-annual" plan code to stripe lookup keys', function () {
const planCode = 'collaborator-annual'
const lookupKey =
this.PlansLocator.mapRecurlyPlanCodeToStripeLookupKey(planCode)
expect(lookupKey).to.equal('collaborator_annual_may2025')
const currency = 'eur'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
planCode,
currency
)
expect(lookupKey).to.equal('standard_annual_jun2025_eur')
})
it('should map "professional" plan code to stripe lookup keys', function () {
const planCode = 'professional'
const lookupKey =
this.PlansLocator.mapRecurlyPlanCodeToStripeLookupKey(planCode)
expect(lookupKey).to.equal('professional_may2025')
const currency = 'eur'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
planCode,
currency
)
expect(lookupKey).to.equal('professional_monthly_jun2025_eur')
})
it('should map "professional_free_trial_7_days" plan code to stripe lookup keys', function () {
const planCode = 'professional_free_trial_7_days'
const lookupKey =
this.PlansLocator.mapRecurlyPlanCodeToStripeLookupKey(planCode)
expect(lookupKey).to.equal('professional_may2025')
const currency = 'eur'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
planCode,
currency
)
expect(lookupKey).to.equal('professional_monthly_jun2025_eur')
})
it('should map "professional-annual" plan code to stripe lookup keys', function () {
const planCode = 'professional-annual'
const lookupKey =
this.PlansLocator.mapRecurlyPlanCodeToStripeLookupKey(planCode)
expect(lookupKey).to.equal('professional_annual_may2025')
const currency = 'eur'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
planCode,
currency
)
expect(lookupKey).to.equal('professional_annual_jun2025_eur')
})
it('should map "student" plan code to stripe lookup keys', function () {
const planCode = 'student'
const lookupKey =
this.PlansLocator.mapRecurlyPlanCodeToStripeLookupKey(planCode)
expect(lookupKey).to.equal('student_may2025')
const currency = 'eur'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
planCode,
currency
)
expect(lookupKey).to.equal('student_monthly_jun2025_eur')
})
it('shoult map "student_free_trial_7_days" plan code to stripe lookup keys', function () {
const planCode = 'student_free_trial_7_days'
const lookupKey =
this.PlansLocator.mapRecurlyPlanCodeToStripeLookupKey(planCode)
expect(lookupKey).to.equal('student_may2025')
const currency = 'eur'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
planCode,
currency
)
expect(lookupKey).to.equal('student_monthly_jun2025_eur')
})
it('should map "student-annual" plan code to stripe lookup keys', function () {
const planCode = 'student-annual'
const lookupKey =
this.PlansLocator.mapRecurlyPlanCodeToStripeLookupKey(planCode)
expect(lookupKey).to.equal('student_annual_may2025')
const currency = 'eur'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
planCode,
currency
)
expect(lookupKey).to.equal('student_annual_jun2025_eur')
})
})
describe('mapRecurlyAddOnCodeToStripeLookupKey', function () {
it('should return null for unknown add-on codes', function () {
const billingCycleInterval = 'month'
const addOnCode = 'unknown_addon'
const lookupKey = this.PlansLocator.mapRecurlyAddOnCodeToStripeLookupKey(
const currency = 'gbp'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
addOnCode,
currency,
billingCycleInterval
)
expect(lookupKey).to.equal(null)
})
it('should handle missing input', function () {
const lookupKey = this.PlansLocator.mapRecurlyAddOnCodeToStripeLookupKey(
const lookupKey = this.PlansLocator.buildStripeLookupKey(
undefined,
undefined
)
@@ -137,21 +164,25 @@ describe('PlansLocator', function () {
it('returns the key for a monthly AI assist add-on', function () {
const billingCycleInterval = 'month'
const addOnCode = this.AI_ADD_ON_CODE
const lookupKey = this.PlansLocator.mapRecurlyAddOnCodeToStripeLookupKey(
const currency = 'gbp'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
addOnCode,
currency,
billingCycleInterval
)
expect(lookupKey).to.equal('assistant_may2025')
expect(lookupKey).to.equal('assistant_monthly_jun2025_gbp')
})
it('returns the key for an annual AI assist add-on', function () {
const billingCycleInterval = 'year'
const addOnCode = this.AI_ADD_ON_CODE
const lookupKey = this.PlansLocator.mapRecurlyAddOnCodeToStripeLookupKey(
const currency = 'gbp'
const lookupKey = this.PlansLocator.buildStripeLookupKey(
addOnCode,
currency,
billingCycleInterval
)
expect(lookupKey).to.equal('assistant_annual_may2025')
expect(lookupKey).to.equal('assistant_annual_jun2025_gbp')
})
})