From f11f13d0670ea2ae91ace6e4e647c54933c8c89d Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Fri, 15 Nov 2024 15:10:37 -0800 Subject: [PATCH] remove this flag that hasnt been touched since 2022 --- .../CancelPlanPage/useProPlanMonth.js | 20 -- .../CancelPlanPage/useProPlanMonth.test.js | 210 ------------------ .../useEnterpriseCloudPlanSupport.js | 16 -- .../useEnterpriseCloudPlanSupport.test.js | 45 ---- src/shared/utils/billing.test.ts | 103 +++------ src/shared/utils/billing.ts | 27 +-- 6 files changed, 37 insertions(+), 384 deletions(-) delete mode 100644 src/pages/PlanPage/subRoutes/CancelPlanPage/useProPlanMonth.js delete mode 100644 src/pages/PlanPage/subRoutes/CancelPlanPage/useProPlanMonth.test.js delete mode 100644 src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/useEnterpriseCloudPlanSupport.js delete mode 100644 src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/useEnterpriseCloudPlanSupport.test.js diff --git a/src/pages/PlanPage/subRoutes/CancelPlanPage/useProPlanMonth.js b/src/pages/PlanPage/subRoutes/CancelPlanPage/useProPlanMonth.js deleted file mode 100644 index 94d703e9d8..0000000000 --- a/src/pages/PlanPage/subRoutes/CancelPlanPage/useProPlanMonth.js +++ /dev/null @@ -1,20 +0,0 @@ -import { useFlags } from 'shared/featureFlags' -import { Plans } from 'shared/utils/billing' - -export function useProPlanMonth({ plans }) { - const { enterpriseCloudPlanSupport } = useFlags({ - enterpriseCloudPlanSupport: true, - }) - - const proPlanMonth = enterpriseCloudPlanSupport - ? plans.find( - (plan) => - plan.value === Plans.USERS_PR_INAPPM || - plan.value === Plans.USERS_ENTERPRISEM - ) - : plans.find((plan) => plan.value === Plans.USERS_PR_INAPPM) - - return { - proPlanMonth, - } -} diff --git a/src/pages/PlanPage/subRoutes/CancelPlanPage/useProPlanMonth.test.js b/src/pages/PlanPage/subRoutes/CancelPlanPage/useProPlanMonth.test.js deleted file mode 100644 index 76a834c920..0000000000 --- a/src/pages/PlanPage/subRoutes/CancelPlanPage/useProPlanMonth.test.js +++ /dev/null @@ -1,210 +0,0 @@ -import { renderHook } from '@testing-library/react' - -import { Plans } from 'shared/utils/billing' - -import { useProPlanMonth } from './useProPlanMonth' - -const mocks = vi.hoisted(() => ({ - useFlags: vi.fn(), -})) - -vi.mock('shared/featureFlags', async () => { - const actual = await vi.importActual('shared/featureFlags') - return { - ...actual, - useFlags: mocks.useFlags, - } -}) - -describe('useProPlanMonth', () => { - function setup(flagValue) { - mocks.useFlags.mockReturnValue({ - enterpriseCloudPlanSupport: flagValue, - }) - } - - describe('flag is enabled', () => { - it('returns the inappm plan', () => { - const plans = [ - { - marketingName: 'Basic', - value: Plans.USERS_FREE, - billingRate: null, - baseUnitPrice: 0, - benefits: [ - 'Up to 5 users', - 'Unlimited public repositories', - 'Unlimited private repositories', - ], - }, - { - marketingName: 'Pro Team', - value: Plans.USERS_PR_INAPPM, - billingRate: 'monthly', - baseUnitPrice: 12, - benefits: [ - 'Configurable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - ] - setup(true) - - const { result } = renderHook(() => useProPlanMonth({ plans })) - - expect(result.current).toEqual({ - proPlanMonth: { - marketingName: 'Pro Team', - value: Plans.USERS_PR_INAPPM, - billingRate: 'monthly', - baseUnitPrice: 12, - benefits: [ - 'Configurable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - }) - }) - it('returns the enterprisem plan', () => { - const plans = [ - { - marketingName: 'Basic', - value: Plans.USERS_FREE, - billingRate: null, - baseUnitPrice: 0, - benefits: [ - 'Up to 5 users', - 'Unlimited public repositories', - 'Unlimited private repositories', - ], - }, - { - marketingName: 'Pro Team', - value: Plans.USERS_ENTERPRISEM, - billingRate: 'monthly', - baseUnitPrice: 12, - benefits: [ - 'Configurable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - ] - - setup(true) - - const { result } = renderHook(() => useProPlanMonth({ plans })) - - expect(result.current).toEqual({ - proPlanMonth: { - marketingName: 'Pro Team', - value: Plans.USERS_ENTERPRISEM, - billingRate: 'monthly', - baseUnitPrice: 12, - benefits: [ - 'Configurable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - }) - }) - }) - - describe('flag is disabled', () => { - beforeEach(() => { - setup(false) - }) - - it('returns the inappm plan', () => { - const { result } = renderHook(() => - useProPlanMonth({ plans: getPlans() }) - ) - - expect(result.current).toEqual({ - proPlanMonth: { - marketingName: 'Pro Team', - value: Plans.USERS_PR_INAPPM, - billingRate: 'monthly', - baseUnitPrice: 12, - benefits: [ - 'Configurable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - }) - }) - }) -}) - -function getPlans() { - return [ - { - marketingName: 'Basic', - value: Plans.USERS_FREE, - billingRate: null, - baseUnitPrice: 0, - benefits: [ - 'Up to 5 users', - 'Unlimited public repositories', - 'Unlimited private repositories', - ], - }, - { - marketingName: 'Pro Team', - value: Plans.USERS_PR_INAPPM, - billingRate: 'monthly', - baseUnitPrice: 12, - benefits: [ - 'Configurable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - { - marketingName: 'Pro Team', - value: Plans.USERS_PR_INAPPY, - billingRate: 'annually', - baseUnitPrice: 10, - benefits: [ - 'Configurable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - { - marketingName: 'Pro Team', - value: Plans.USERS_ENTERPRISE, - billingRate: 'monthly', - baseUnitPrice: 12, - benefits: [ - 'Configurable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - { - marketingName: 'Pro Team', - value: Plans.USERS_ENTERPRISEY, - billingRate: 'annually', - baseUnitPrice: 10, - benefits: [ - 'Configurable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - ] -} diff --git a/src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/useEnterpriseCloudPlanSupport.js b/src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/useEnterpriseCloudPlanSupport.js deleted file mode 100644 index ec86aba31a..0000000000 --- a/src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/useEnterpriseCloudPlanSupport.js +++ /dev/null @@ -1,16 +0,0 @@ -import { useFlags } from 'shared/featureFlags' -import { Plans } from 'shared/utils/billing' - -export function useEnterpriseCloudPlanSupport({ plans }) { - const { enterpriseCloudPlanSupport } = useFlags({ - enterpriseCloudPlanSupport: true, - }) - - const enterprisePlans = [Plans.USERS_ENTERPRISEM, Plans.USERS_ENTERPRISEY] - - if (enterpriseCloudPlanSupport) { - plans.push(...enterprisePlans) - } - - return { plans } -} diff --git a/src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/useEnterpriseCloudPlanSupport.test.js b/src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/useEnterpriseCloudPlanSupport.test.js deleted file mode 100644 index e12c5e6f1f..0000000000 --- a/src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/useEnterpriseCloudPlanSupport.test.js +++ /dev/null @@ -1,45 +0,0 @@ -import { renderHook } from '@testing-library/react' - -import { useEnterpriseCloudPlanSupport } from './useEnterpriseCloudPlanSupport' - -const mocks = vi.hoisted(() => ({ - useFlags: vi.fn(), -})) - -vi.mock('shared/featureFlags', () => ({ - useFlags: mocks.useFlags, -})) - -describe('useEnterpriseCloudPlanSupport', () => { - let hookData - - function setup(flagValue) { - const defaultPlans = ['users-inappm'] - mocks.useFlags.mockReturnValue({ - enterpriseCloudPlanSupport: flagValue, - }) - hookData = renderHook(() => - useEnterpriseCloudPlanSupport({ plans: defaultPlans }) - ) - } - - describe('flag is true', () => { - beforeEach(() => { - setup(true) - }) - it('adds enterprise plans to list', () => { - expect(hookData.result.current).toEqual({ - plans: ['users-inappm', 'users-enterprisem', 'users-enterprisey'], - }) - }) - }) - - describe('flag is false', () => { - beforeEach(() => { - setup(false) - }) - it('does not modify the list', () => { - expect(hookData.result.current).toEqual({ plans: ['users-inappm'] }) - }) - }) -}) diff --git a/src/shared/utils/billing.test.ts b/src/shared/utils/billing.test.ts index 61f56a19bd..eb0274f96f 100644 --- a/src/shared/utils/billing.test.ts +++ b/src/shared/utils/billing.test.ts @@ -244,80 +244,37 @@ describe('useProPlans', () => { }) } - describe('flag is true', () => { - beforeEach(() => { - setup(true) - }) + it('does not contain enterprise plans', () => { + setup(false) + const { result } = renderHook(() => useProPlans({ plans: getPlans() })) - it('contains enterprise plans', async () => { - const { result } = renderHook(() => useProPlans({ plans: getPlans() })) - - expect(result.current).toEqual({ - proPlanMonth: { - marketingName: 'Pro Team', - value: Plans.USERS_PR_INAPPM, - billingRate: 'monthly', - baseUnitPrice: 12, - monthlyUploadLimit: null, - benefits: [ - 'Configureable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - proPlanYear: { - marketingName: 'Pro Team', - value: Plans.USERS_PR_INAPPY, - billingRate: 'annually', - baseUnitPrice: 10, - monthlyUploadLimit: null, - benefits: [ - 'Configureable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - }) - }) - }) - - describe('flag is false', () => { - beforeEach(() => { - setup(false) - }) - it('does not contain enterprise plans', () => { - const { result } = renderHook(() => useProPlans({ plans: getPlans() })) - - expect(result.current).toEqual({ - proPlanMonth: { - marketingName: 'Pro Team', - value: Plans.USERS_PR_INAPPM, - billingRate: 'monthly', - baseUnitPrice: 12, - monthlyUploadLimit: null, - benefits: [ - 'Configureable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - proPlanYear: { - marketingName: 'Pro Team', - value: Plans.USERS_PR_INAPPY, - billingRate: 'annually', - baseUnitPrice: 10, - monthlyUploadLimit: null, - benefits: [ - 'Configureable # of users', - 'Unlimited public repositories', - 'Unlimited private repositories', - 'Priorty Support', - ], - }, - }) + expect(result.current).toEqual({ + proPlanMonth: { + marketingName: 'Pro Team', + value: Plans.USERS_PR_INAPPM, + billingRate: 'monthly', + baseUnitPrice: 12, + monthlyUploadLimit: null, + benefits: [ + 'Configureable # of users', + 'Unlimited public repositories', + 'Unlimited private repositories', + 'Priorty Support', + ], + }, + proPlanYear: { + marketingName: 'Pro Team', + value: Plans.USERS_PR_INAPPY, + billingRate: 'annually', + baseUnitPrice: 10, + monthlyUploadLimit: null, + benefits: [ + 'Configureable # of users', + 'Unlimited public repositories', + 'Unlimited private repositories', + 'Priorty Support', + ], + }, }) }) }) diff --git a/src/shared/utils/billing.ts b/src/shared/utils/billing.ts index 259a1fcdb4..7224ba7d86 100644 --- a/src/shared/utils/billing.ts +++ b/src/shared/utils/billing.ts @@ -5,7 +5,6 @@ import isUndefined from 'lodash/isUndefined' import { z } from 'zod' import { AccountDetailsSchema } from 'services/account' -import { useFlags } from 'shared/featureFlags' export const Plans = { USERS_FREE: 'users-free', @@ -136,25 +135,13 @@ export const CollectionMethods = Object.freeze({ }) export function useProPlans({ plans }: { plans?: Plan[] | null }) { - const { enterpriseCloudPlanSupport } = useFlags({ - enterpriseCloudPlanSupport: true, - }) - - const proPlanMonth = enterpriseCloudPlanSupport - ? plans?.find( - (plan) => - plan.value === Plans.USERS_PR_INAPPM || - plan.value === EnterprisePlans.USERS_ENTERPRISEM - ) - : plans?.find((plan) => plan.value === Plans.USERS_PR_INAPPM) - - const proPlanYear = enterpriseCloudPlanSupport - ? plans?.find( - (plan) => - plan.value === Plans.USERS_PR_INAPPY || - plan.value === EnterprisePlans.USERS_ENTERPRISEY - ) - : plans?.find((plan) => plan.value === Plans.USERS_PR_INAPPY) + const proPlanMonth = plans?.find( + (plan) => plan.value === Plans.USERS_PR_INAPPM + ) + + const proPlanYear = plans?.find( + (plan) => plan.value === Plans.USERS_PR_INAPPY + ) return { proPlanMonth,