From ff7bd5718b4bdaa350eb4e17fc74cb4d951fb202 Mon Sep 17 00:00:00 2001 From: M Fahru Date: Mon, 9 Dec 2024 10:13:50 -0700 Subject: [PATCH] Merge pull request #22304 from overleaf/mf-clean-up-latam-v2-test [web] Tear down LATAM geo-pricing v2 split test GitOrigin-RevId: ca379c7ace5600aa31559c82e166c7ea67c6c26d --- .../Project/ProjectListController.mjs | 11 +- .../Subscription/SubscriptionController.js | 55 +-- .../plans-v2/plans-v2-tracking.ts | 4 - .../SubscriptionControllerTests.js | 405 +++++++----------- 4 files changed, 165 insertions(+), 310 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectListController.mjs b/services/web/app/src/Features/Project/ProjectListController.mjs index c8031150c7..f636cbac53 100644 --- a/services/web/app/src/Features/Project/ProjectListController.mjs +++ b/services/web/app/src/Features/Project/ProjectListController.mjs @@ -396,13 +396,6 @@ async function projectListPage(req, res, next) { usersBestSubscription?.type === 'free' || usersBestSubscription?.type === 'standalone-ai-add-on' ) { - const latamGeoPricingAssignment = - await SplitTestHandler.promises.getAssignment( - req, - res, - 'geo-pricing-latam-v2' - ) - const { countryCode, currencyCode } = await GeoIpLookup.promises.getCurrencyCode(req.ip) @@ -411,9 +404,7 @@ async function projectListPage(req, res, next) { } showBrlGeoBanner = countryCode === 'BR' - showLATAMBanner = - latamGeoPricingAssignment.variant === 'latam' && - ['MX', 'CO', 'CL', 'PE'].includes(countryCode) + showLATAMBanner = ['MX', 'CO', 'CL', 'PE'].includes(countryCode) // LATAM Banner needs to know which currency to display if (showLATAMBanner) { recommendedCurrency = currencyCode diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.js b/services/web/app/src/Features/Subscription/SubscriptionController.js index e9ece23d40..825befc344 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.js +++ b/services/web/app/src/Features/Subscription/SubscriptionController.js @@ -68,10 +68,8 @@ function _getGroupPlanModalDefaults(req, currency) { } } -function _plansBanners({ geoPricingLATAMTestVariant, countryCode }) { - const showLATAMBanner = - geoPricingLATAMTestVariant === 'latam' && - ['MX', 'CO', 'CL', 'PE'].includes(countryCode) +function _plansBanners(countryCode) { + const showLATAMBanner = ['MX', 'CO', 'CL', 'PE'].includes(countryCode) const showInrGeoBanner = countryCode === 'IN' const showBrlGeoBanner = countryCode === 'BR' return { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } @@ -105,20 +103,15 @@ async function plansPage(req, res) { const plans = SubscriptionViewModelBuilder.buildPlansList() - const { currency, countryCode, geoPricingLATAMTestVariant } = - await _getRecommendedCurrency(req, res) + const { currency, countryCode } = await _getRecommendedCurrency(req, res) const latamCountryBannerDetails = await getLatamCountryBannerDetails(req, res) const groupPlanModalDefaults = _getGroupPlanModalDefaults(req, currency) const currentView = 'annual' - const { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } = _plansBanners( - { - geoPricingLATAMTestVariant, - countryCode, - } - ) + const { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } = + _plansBanners(countryCode) const localCcyAssignment = await SplitTestHandler.promises.getAssignment( req, @@ -163,8 +156,7 @@ async function plansPage(req, res) { } async function plansPageLightDesign(req, res) { - const { currency, countryCode, geoPricingLATAMTestVariant } = - await _getRecommendedCurrency(req, res) + const { currency, countryCode } = await _getRecommendedCurrency(req, res) const language = req.i18n.language || 'en' const currentView = 'annual' @@ -181,12 +173,8 @@ async function plansPageLightDesign(req, res) { ? formatCurrencyLocalized : SubscriptionHelper.formatCurrencyDefault - const { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } = _plansBanners( - { - geoPricingLATAMTestVariant, - countryCode, - } - ) + const { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } = + _plansBanners(countryCode) const latamCountryBannerDetails = await getLatamCountryBannerDetails(req, res) @@ -358,8 +346,10 @@ async function interstitialPaymentPage(req, res) { } const user = SessionManager.getSessionUser(req.session) - const { recommendedCurrency, countryCode, geoPricingLATAMTestVariant } = - await _getRecommendedCurrency(req, res) + const { recommendedCurrency, countryCode } = await _getRecommendedCurrency( + req, + res + ) const latamCountryBannerDetails = await getLatamCountryBannerDetails(req, res) @@ -371,10 +361,7 @@ async function interstitialPaymentPage(req, res) { res.redirect('/user/subscription?hasSubscription=true') } else { const { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } = - _plansBanners({ - geoPricingLATAMTestVariant, - countryCode, - }) + _plansBanners(countryCode) const localCcyAssignment = await SplitTestHandler.promises.getAssignment( req, @@ -827,20 +814,7 @@ async function _getRecommendedCurrency(req, res) { } const currencyLookup = await GeoIpLookup.promises.getCurrencyCode(ip) const countryCode = currencyLookup.countryCode - let recommendedCurrency = currencyLookup.currencyCode - - const assignmentLATAM = await SplitTestHandler.promises.getAssignment( - req, - res, - 'geo-pricing-latam-v2' - ) - - if ( - ['MXN', 'COP', 'CLP', 'PEN'].includes(recommendedCurrency) && - assignmentLATAM?.variant === 'default' - ) { - recommendedCurrency = GeoIpLookup.DEFAULT_CURRENCY_CODE - } + const recommendedCurrency = currencyLookup.currencyCode let currency = null const queryCurrency = req.query.currency?.toUpperCase() @@ -854,7 +828,6 @@ async function _getRecommendedCurrency(req, res) { currency, recommendedCurrency, countryCode, - geoPricingLATAMTestVariant: assignmentLATAM?.variant, } } diff --git a/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-tracking.ts b/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-tracking.ts index 0ed52a40e2..0377be631d 100644 --- a/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-tracking.ts +++ b/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-tracking.ts @@ -8,9 +8,6 @@ export function sendPlansViewEvent() { function () { const currency = getMeta('ol-recommendedCurrency') const countryCode = getMeta('ol-countryCode') - const geoPricingLATAMTestVariant = getSplitTestVariant( - 'geo-pricing-latam-v2' - ) const groupTabImprovementsVariant = getSplitTestVariant( 'group-tab-improvements' @@ -35,7 +32,6 @@ export function sendPlansViewEvent() { currency, countryCode, device, - 'geo-pricing-latam-v2': geoPricingLATAMTestVariant, 'website-redesign-plans': websiteRedesignPlansTestVariant, 'group-tab-improvements': groupTabImprovementsVariant, plan: planTabParam, diff --git a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js index 4450e862db..51f16b16c9 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js @@ -323,89 +323,60 @@ describe('SubscriptionController', function () { }) describe('showLATAMBanner', function () { - describe('latam variant', function () { - beforeEach(function () { - this.SplitTestV2Hander.promises.getAssignment - .withArgs(this.req, this.res, 'geo-pricing-latam-v2') - .resolves({ - variant: 'latam', - }) - }) - it('should return true for Mexican users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'MX', - }) - this.SubscriptionController.plansPage(this.req, this.res) - }) - it('should return true for Colombian users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'CO', - }) - this.SubscriptionController.plansPage(this.req, this.res) - }) - it('should return true for Chilean users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'CL', - }) - this.SubscriptionController.plansPage(this.req, this.res) - }) - it('should return true for Peruvian users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'PE', - }) - this.SubscriptionController.plansPage(this.req, this.res) - }) - it('should return true for US users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans') - opts.showLATAMBanner.should.equal(false) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'US', - }) - this.SubscriptionController.plansPage(this.req, this.res) + it('should return true for Mexican users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/plans') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'MX', }) + this.SubscriptionController.plansPage(this.req, this.res) }) - describe('default variant', function () { - beforeEach(function () { - this.SplitTestV2Hander.promises.getAssignment - .withArgs(this.req, this.res, 'geo-pricing-latam-v2') - .resolves({ - variant: 'default', - }) + it('should return true for Colombian users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/plans') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'CO', }) - it('should return false', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans') - opts.showLATAMBanner.should.equal(false) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'MX', - }) - this.SubscriptionController.plansPage(this.req, this.res) + this.SubscriptionController.plansPage(this.req, this.res) + }) + it('should return true for Chilean users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/plans') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'CL', }) + this.SubscriptionController.plansPage(this.req, this.res) + }) + it('should return true for Peruvian users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/plans') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'PE', + }) + this.SubscriptionController.plansPage(this.req, this.res) + }) + it('should return true for US users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/plans') + opts.showLATAMBanner.should.equal(false) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'US', + }) + this.SubscriptionController.plansPage(this.req, this.res) }) }) @@ -670,89 +641,60 @@ describe('SubscriptionController', function () { }) describe('showLATAMBanner', function () { - describe('latam variant', function () { - beforeEach(function () { - this.SplitTestV2Hander.promises.getAssignment - .withArgs(this.req, this.res, 'geo-pricing-latam-v2') - .resolves({ - variant: 'latam', - }) - }) - it('should return true for Mexican users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans-light-design') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'MX', - }) - this.SubscriptionController.plansPageLightDesign(this.req, this.res) - }) - it('should return true for Colombian users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans-light-design') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'CO', - }) - this.SubscriptionController.plansPageLightDesign(this.req, this.res) - }) - it('should return true for Chilean users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans-light-design') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'CL', - }) - this.SubscriptionController.plansPageLightDesign(this.req, this.res) - }) - it('should return true for Peruvian users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans-light-design') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'PE', - }) - this.SubscriptionController.plansPageLightDesign(this.req, this.res) - }) - it('should return true for US users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans-light-design') - opts.showLATAMBanner.should.equal(false) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'US', - }) - this.SubscriptionController.plansPageLightDesign(this.req, this.res) + it('should return true for Mexican users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/plans-light-design') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'MX', }) + this.SubscriptionController.plansPageLightDesign(this.req, this.res) }) - describe('default variant', function () { - beforeEach(function () { - this.SplitTestV2Hander.promises.getAssignment - .withArgs(this.req, this.res, 'geo-pricing-latam-v2') - .resolves({ - variant: 'default', - }) + it('should return true for Colombian users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/plans-light-design') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'CO', }) - it('should return false', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/plans-light-design') - opts.showLATAMBanner.should.equal(false) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'MX', - }) - this.SubscriptionController.plansPageLightDesign(this.req, this.res) + this.SubscriptionController.plansPageLightDesign(this.req, this.res) + }) + it('should return true for Chilean users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/plans-light-design') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'CL', }) + this.SubscriptionController.plansPageLightDesign(this.req, this.res) + }) + it('should return true for Peruvian users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/plans-light-design') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'PE', + }) + this.SubscriptionController.plansPageLightDesign(this.req, this.res) + }) + it('should return true for US users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/plans-light-design') + opts.showLATAMBanner.should.equal(false) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'US', + }) + this.SubscriptionController.plansPageLightDesign(this.req, this.res) }) }) @@ -876,107 +818,60 @@ describe('SubscriptionController', function () { }) describe('showLATAMBanner', function () { - describe('latam variant', function () { - beforeEach(function () { - this.SplitTestV2Hander.promises.getAssignment - .withArgs(this.req, this.res, 'geo-pricing-latam-v2') - .resolves({ - variant: 'latam', - }) - }) - it('should return true for Mexican users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/interstitial-payment') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'MX', - }) - this.SubscriptionController.interstitialPaymentPage( - this.req, - this.res - ) - }) - it('should return true for Colombian users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/interstitial-payment') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'CO', - }) - this.SubscriptionController.interstitialPaymentPage( - this.req, - this.res - ) - }) - it('should return true for Chilean users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/interstitial-payment') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'CL', - }) - this.SubscriptionController.interstitialPaymentPage( - this.req, - this.res - ) - }) - it('should return true for Peruvian users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/interstitial-payment') - opts.showLATAMBanner.should.equal(true) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'PE', - }) - this.SubscriptionController.interstitialPaymentPage( - this.req, - this.res - ) - }) - it('should return true for US users', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/interstitial-payment') - opts.showLATAMBanner.should.equal(false) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'US', - }) - this.SubscriptionController.interstitialPaymentPage( - this.req, - this.res - ) + it('should return true for Mexican users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/interstitial-payment') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'MX', }) + this.SubscriptionController.interstitialPaymentPage(this.req, this.res) }) - describe('default variant', function () { - beforeEach(function () { - this.SplitTestV2Hander.promises.getAssignment - .withArgs(this.req, this.res, 'website-redesign-plan') - .resolves({ - variant: 'default', - }) + it('should return true for Colombian users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/interstitial-payment') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'CO', }) - it('should return false', function (done) { - this.res.render = (page, opts) => { - page.should.equal('subscriptions/interstitial-payment') - opts.showLATAMBanner.should.equal(false) - done() - } - this.GeoIpLookup.promises.getCurrencyCode.resolves({ - countryCode: 'MX', - }) - this.SubscriptionController.interstitialPaymentPage( - this.req, - this.res - ) + this.SubscriptionController.interstitialPaymentPage(this.req, this.res) + }) + it('should return true for Chilean users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/interstitial-payment') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'CL', }) + this.SubscriptionController.interstitialPaymentPage(this.req, this.res) + }) + it('should return true for Peruvian users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/interstitial-payment') + opts.showLATAMBanner.should.equal(true) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'PE', + }) + this.SubscriptionController.interstitialPaymentPage(this.req, this.res) + }) + it('should return true for US users', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/interstitial-payment') + opts.showLATAMBanner.should.equal(false) + done() + } + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + countryCode: 'US', + }) + this.SubscriptionController.interstitialPaymentPage(this.req, this.res) }) })