Skip to content

Commit 6f51468

Browse files
committed
Conditionally render credit notice based on the feature flag
1 parent 5917526 commit 6f51468

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

client/my-sites/plans-features-main/components/plan-notice-domain-to-plan-credit.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const PlanNoticeDomainToPlanCredit = ( {
2828
const upgradeCreditDocsUrl = localizeUrl(
2929
'https://wordpress.com/support/manage-purchases/upgrade-your-plan/#upgrade-credit'
3030
);
31-
3231
const showNotice =
3332
visiblePlans &&
3433
visiblePlans.length > 0 &&

client/my-sites/plans-features-main/components/plan-notice.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isEnabled } from '@automattic/calypso-config';
12
import { PlanSlug, isProPlan, isStarterPlan } from '@automattic/calypso-products';
23
import { Site, SiteMediaStorage } from '@automattic/data-stores';
34
import { useTranslate } from 'i18n-calypso';
@@ -211,12 +212,14 @@ export default function PlanNotice( props: PlanNoticeProps ) {
211212
);
212213
case DOMAIN_TO_PLAN_CREDIT_NOTICE:
213214
return (
214-
<PlanNoticeDomainToPlanCredit
215-
className="plan-features-main__notice"
216-
onDismissClick={ handleDismissNotice }
217-
siteId={ siteId }
218-
visiblePlans={ visiblePlans }
219-
/>
215+
isEnabled( 'domain-to-plan-credit' ) && (
216+
<PlanNoticeDomainToPlanCredit
217+
className="plan-features-main__notice"
218+
onDismissClick={ handleDismissNotice }
219+
siteId={ siteId }
220+
visiblePlans={ visiblePlans }
221+
/>
222+
)
220223
);
221224
case MARKETING_NOTICE:
222225
default:

client/my-sites/plans-features-main/components/test/plan-notice.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @jest-environment jsdom */
22

3+
import { isEnabled } from '@automattic/calypso-config';
34
import {
45
PLAN_BUSINESS,
56
PLAN_PREMIUM,
@@ -67,6 +68,7 @@ jest.mock( 'calypso/my-sites/plans-features-main/hooks/use-max-plan-upgrade-cred
6768
jest.mock( 'calypso/state/currency-code/selectors', () => ( {
6869
getCurrentUserCurrencyCode: jest.fn(),
6970
} ) );
71+
jest.mock( '@automattic/calypso-config' );
7072

7173
const mGetDiscountByName = getDiscountByName as jest.MockedFunction< typeof getDiscountByName >;
7274
const mUseMarketingMessage = useMarketingMessage as jest.MockedFunction<
@@ -90,6 +92,7 @@ const mGetCurrentUserCurrencyCode = getCurrentUserCurrencyCode as jest.MockedFun
9092
>;
9193
const mGetByPurchaseId = getByPurchaseId as jest.MockedFunction< typeof getByPurchaseId >;
9294
const mIsProPlan = isProPlan as jest.MockedFunction< typeof isProPlan >;
95+
const mIsEnabled = isEnabled as jest.MockedFunction< typeof isEnabled >;
9396

9497
const plansList: PlanSlug[] = [
9598
PLAN_FREE,
@@ -119,6 +122,7 @@ describe( '<PlanNotice /> Tests', () => {
119122
mUseDomainToPlanCreditsApplicable.mockImplementation( () => 100 );
120123
mGetByPurchaseId.mockImplementation( () => ( { isInAppPurchase: false } ) as Purchase );
121124
mIsProPlan.mockImplementation( () => false );
125+
mIsEnabled.mockImplementation( ( key ) => key !== 'domain-to-plan-credit' );
122126
} );
123127

124128
test( 'A contact site owner <PlanNotice /> should be shown no matter what other conditions are met, when the current site owner is not logged in, and the site plan is paid', () => {
@@ -179,6 +183,7 @@ describe( '<PlanNotice /> Tests', () => {
179183
test( 'A domain-to-plan credit <PlanNotice /> should be shown in a site where a domain has been purchased without a paid plan', () => {
180184
mUsePlanUpgradeCreditsApplicable.mockImplementation( () => null );
181185
mUseDomainToPlanCreditsApplicable.mockImplementation( () => 1000 );
186+
mIsEnabled.mockImplementation( ( key ) => key === 'domain-to-plan-credit' );
182187

183188
renderWithProvider(
184189
<PlanNotice

0 commit comments

Comments
 (0)