From 1a976af508224ec2b0f1dd2dfff16b71692b79f0 Mon Sep 17 00:00:00 2001 From: StevenDufresne Date: Fri, 17 Jan 2025 11:40:29 +0900 Subject: [PATCH] Rename clearedCart to userHasClearedCart --- client/layout/masterbar/checkout.tsx | 4 ++-- client/my-sites/checkout/src/lib/leave-checkout.ts | 12 ++++++------ client/my-sites/checkout/src/test/leave-checkout.ts | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/client/layout/masterbar/checkout.tsx b/client/layout/masterbar/checkout.tsx index 43bf4250d6dcd5..be4defc4d69982 100644 --- a/client/layout/masterbar/checkout.tsx +++ b/client/layout/masterbar/checkout.tsx @@ -54,13 +54,13 @@ const CheckoutMasterbar = ( { const { responseCart, replaceProductsInCart } = useShoppingCart( cartKey ); const [ isModalVisible, setIsModalVisible ] = useState( false ); - const closeAndLeave = ( clearedCart: boolean = false ) => + const closeAndLeave = ( userHasClearedCart: boolean = false ) => leaveCheckout( { siteSlug, forceCheckoutBackUrl, previousPath, tracksEvent: 'calypso_masterbar_close_clicked', - clearedCart: clearedCart, + userHasClearedCart: userHasClearedCart, } ); const clickClose = () => { diff --git a/client/my-sites/checkout/src/lib/leave-checkout.ts b/client/my-sites/checkout/src/lib/leave-checkout.ts index c15bb1d6dbfa3a..3a697490b9aed4 100644 --- a/client/my-sites/checkout/src/lib/leave-checkout.ts +++ b/client/my-sites/checkout/src/lib/leave-checkout.ts @@ -17,11 +17,11 @@ import { sendMessageToOpener } from './popup'; const debug = debugFactory( 'calypso:leave-checkout' ); const getCloseURL = ( { - clearedCart, + userHasClearedCart, previousPath, siteSlug, }: { - clearedCart: boolean; + userHasClearedCart: boolean; previousPath?: string; siteSlug?: string; } ): string => { @@ -34,7 +34,7 @@ const getCloseURL = ( { /* Regex to match /domains/add/abc123/email/def456? */ const emailUpsellRegex = /\/domains\/add\/[^/]+\/email\/[^/]+(\?|\/|$)/; - if ( clearedCart && emailUpsellRegex.test( previousPath ) ) { + if ( userHasClearedCart && emailUpsellRegex.test( previousPath ) ) { return '/domains/add/' + siteSlug; } return previousPath; @@ -49,14 +49,14 @@ export const leaveCheckout = ( { previousPath, tracksEvent, createUserAndSiteBeforeTransaction, - clearedCart = false, + userHasClearedCart = false, }: { siteSlug?: string; forceCheckoutBackUrl?: string; previousPath?: string; tracksEvent: string; createUserAndSiteBeforeTransaction?: boolean; - clearedCart?: boolean; + userHasClearedCart?: boolean; } ): void => { recordTracksEvent( tracksEvent ); debug( 'leaving checkout with args', { @@ -97,7 +97,7 @@ export const leaveCheckout = ( { return; } - const closeUrl = getCloseURL( { clearedCart, previousPath, siteSlug } ); + const closeUrl = getCloseURL( { userHasClearedCart, previousPath, siteSlug } ); try { const searchParams = new URLSearchParams( window.location.search ); diff --git a/client/my-sites/checkout/src/test/leave-checkout.ts b/client/my-sites/checkout/src/test/leave-checkout.ts index 7bf395d326ebdc..4305876dc52c58 100644 --- a/client/my-sites/checkout/src/test/leave-checkout.ts +++ b/client/my-sites/checkout/src/test/leave-checkout.ts @@ -70,7 +70,7 @@ describe( 'leaveCheckout', () => { leaveCheckout( { siteSlug: siteSlug, tracksEvent: 'checkout_cancel', - clearedCart: true, + userHasClearedCart: true, } ); expect( navigate ).toHaveBeenCalledWith( `/plans/${ siteSlug }` ); @@ -79,7 +79,7 @@ describe( 'leaveCheckout', () => { it( 'returns to /start if missing site slug', () => { leaveCheckout( { tracksEvent: 'checkout_cancel', - clearedCart: true, + userHasClearedCart: true, } ); expect( navigate ).toHaveBeenCalledWith( '/start' ); @@ -92,7 +92,7 @@ describe( 'leaveCheckout', () => { siteSlug: siteSlug, tracksEvent: 'checkout_cancel', previousPath: '/domains/add/my-search-domain/email/mywpsite.wordpress.com?', - clearedCart: true, + userHasClearedCart: true, } ); expect( navigate ).toHaveBeenCalledWith( `/domains/add/${ siteSlug }` ); @@ -104,7 +104,7 @@ describe( 'leaveCheckout', () => { leaveCheckout( { tracksEvent: 'checkout_cancel', previousPath: previousPath, - clearedCart: false, + userHasClearedCart: false, } ); expect( navigate ).toHaveBeenCalledWith( previousPath ); @@ -119,7 +119,7 @@ describe( 'leaveCheckout', () => { siteSlug: siteSlug, tracksEvent: 'checkout_cancel', previousPath: previousPath, - clearedCart: false, + userHasClearedCart: false, } ); expect( navigate ).toHaveBeenCalledWith( previousPath ); @@ -134,7 +134,7 @@ describe( 'leaveCheckout', () => { siteSlug: siteSlug, tracksEvent: 'checkout_cancel', previousPath: previousPath, - clearedCart: false, + userHasClearedCart: false, } ); expect( navigate ).toHaveBeenCalledWith( previousPath );