Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Migrate off isProPlan helper and onto GQL isProPlan #3599

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/pages/AccountSettings/AccountSettings.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ describe('AccountSettings', () => {
value: planValue,
isEnterprisePlan: planValue === Plans.USERS_ENTERPRISEM,
isFreePlan: planValue === Plans.USERS_BASIC,
isProPlan: false,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions src/pages/AccountSettings/AccountSettingsSideMenu.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ describe('AccountSettingsSideMenu', () => {
value: planValue,
isEnterprisePlan: planValue === Plans.USERS_ENTERPRISEM,
isFreePlan: planValue === Plans.USERS_BASIC,
isProPlan: false,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions src/pages/DefaultOrgSelector/DefaultOrgSelector.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ describe('DefaultOrgSelector', () => {
...mockTrialData,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
trialStatus,
value,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const mockedAccountDetails = {
const mockPlanData = {
isEnterprisePlan: false,
isFreePlan: true,
isProPlan: false,
baseUnitPrice: 10,
benefits: [],
billingRate: BillingRate.MONTHLY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const mockPlanData = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
}

const server = setupServer()
Expand Down
1 change: 1 addition & 0 deletions src/pages/MembersPage/MembersList/MembersList.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const mockActiveUserRequest = {

const mockPlanData = {
isEnterprisePlan: false,
isProPlan: false,
baseUnitPrice: 10,
benefits: [],
billingRate: 'monthly',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const queryClient = new QueryClient({

const mockPlanData = {
isEnterprisePlan: false,
isProPlan: false,
baseUnitPrice: 10,
benefits: [],
billingRate: 'monthly',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const mockPlanDataResponse = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
}

beforeAll(() => {
Expand Down
1 change: 1 addition & 0 deletions src/pages/OwnerPage/HeaderBanners/HeaderBanners.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const mockPlanDataResponse = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
}

const mockPlanDataResponseNoUploadLimit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const mockPlanDataResponse = {
value: Plans.USERS_PR_INAPPM,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
trialStatus: TrialStatuses.NOT_STARTED,
trialStartDate: '',
trialEndDate: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const mockResponse = {
planUserCount: 1,
hasSeatsLeft: true,
isEnterprisePlan: false,
isProPlan: false,
}

const wrapper: React.FC<React.PropsWithChildren> = ({ children }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const mockPlanData = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
}

const queryClient = new QueryClient({
Expand Down Expand Up @@ -158,6 +159,7 @@ describe('CancelPlanPage', () => {
value: planValue,
isEnterprisePlan: planValue === Plans.USERS_ENTERPRISEM,
isFreePlan: planValue === Plans.USERS_BASIC,
isProPlan: planValue === Plans.USERS_PR_INAPPM,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from 'services/account'
import {
BillingRate,
isProPlan,
isTrialPlan,
shouldDisplayTeamCard,
} from 'shared/utils/billing'
Expand Down Expand Up @@ -55,7 +54,7 @@ function CancelPlanPage() {
!accountDetailsData?.subscriptionDetail?.customer?.discount
const showSpecialOffer = discountNotApplied && isMonthlyPlan
const showTeamSpecialOffer =
shouldDisplayTeamCard({ plans }) && isProPlan(planData?.plan?.value)
shouldDisplayTeamCard({ plans }) && planData?.plan?.isProPlan
const showCancelPage = showSpecialOffer || showTeamSpecialOffer

let redirectTo = `/plan/${provider}/${owner}/cancel/downgrade`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const mockPlanData = {
hasPrivateRepos: true,
plan: {
isEnterprisePlan: false,
isProPlan: false,
baseUnitPrice: 10,
benefits: [],
billingRate: 'monthly',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const mockPlanDataResponse = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
}

const mockEnterpriseAccountDetailsNinetyPercent = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const proPlanDetails = {
billingRate: null,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: true,
},
}

Expand All @@ -42,6 +43,7 @@ const freePlanDetails = {
],
isEnterprisePlan: false,
isFreePlan: true,
isProPlan: false,
},
}

Expand All @@ -58,6 +60,7 @@ const enterprisePlan = {
],
isEnterprisePlan: true,
isFreePlan: false,
isProPlan: false,
},
}

Expand All @@ -74,6 +77,7 @@ const usesInvoiceTeamPlan = {
],
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
},
usesInvoice: true,
}
Expand All @@ -88,6 +92,7 @@ const trialPlanDetails = {
value: Plans.USERS_TRIAL,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const freePlan = {
monthlyUploadLimit: null,
isFreePlan: true,
isEnterprisePlan: false,
isProPlan: false,
}

const scheduledPhase = {
Expand All @@ -150,6 +151,7 @@ const mockPlanData = {
planUserCount: 1,
hasSeatsLeft: true,
isEnterprisePlan: false,
isProPlan: false,
}

const mockPreTrialPlanInfo = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropType from 'prop-types'

import { planPropType } from 'services/account'
import BenefitList from 'shared/plan/BenefitList'
import { findSentryPlans, useProPlans } from 'shared/utils/billing'
import { findProPlans, findSentryPlans } from 'shared/utils/billing'
import { SENTRY_PRICE } from 'shared/utils/upgradeForm'

import ActionsBilling from '../../shared/ActionsBilling/ActionsBilling'
Expand Down Expand Up @@ -49,7 +49,7 @@ PlanDetails.propTypes = {
}

function PlanUpgradePro({ isSentryUpgrade, plans }) {
const { proPlanMonth, proPlanYear } = useProPlans({ plans })
const { proPlanMonth, proPlanYear } = findProPlans({ plans })
const { sentryPlanYear } = findSentryPlans({ plans })

const upgradeToPlan = isSentryUpgrade ? sentryPlanYear : proPlanMonth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ vi.mock('shared/plan/BenefitList', () => ({ default: () => 'BenefitsList' }))
const mockPlanBasic = {
isEnterprisePlan: false,
isFreePlan: true,
isProPlan: false,
baseUnitPrice: 0,
benefits: ['Up to # user', 'Unlimited public repositories'],
billingRate: BillingRate.MONTHLY,
Expand All @@ -32,6 +33,7 @@ const mockPlanBasic = {

const mockPlanPro = {
isEnterprisePlan: false,
isProPlan: true,
isFreePlan: false,
baseUnitPrice: 10,
benefits: ['Up to # user', 'Unlimited public repositories'],
Expand All @@ -51,6 +53,7 @@ const mockPlanPro = {
const mockPlanTrialing = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
baseUnitPrice: 10,
benefits: ['Up to # user', 'Unlimited public repositories'],
billingRate: BillingRate.MONTHLY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const mockResponse = {
planUserCount: 1,
hasSeatsLeft: true,
isEnterprisePlan: false,
isProPlan: false,
isFreePlan: true,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ vi.mock('shared/plan/ScheduledPlanDetails', () => ({

const mockProPlan = {
isEnterprisePlan: false,
isProPlan: true,
isFreePlan: false,
marketingName: 'Pro',
value: Plans.USERS_PR_INAPPM,
Expand All @@ -48,6 +49,7 @@ const mockProPlan = {
const mockTeamPlan = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
marketingName: 'Team',
value: Plans.USERS_TEAMM,
billingRate: BillingRate.MONTHLY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ const mockTrialData = {
planUserCount: 1,
hasSeatsLeft: true,
isEnterprisePlan: false,
isProPlan: false,
isFreePlan: true,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const mockPlanData = {
planUserCount: 1,
hasSeatsLeft: true,
isEnterprisePlan: false,
isProPlan: false,
}

const server = setupServer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const mockPlanData = {
planUserCount: 1,
hasSeatsLeft: true,
isEnterprisePlan: false,
isProPlan: false,
}

const server = setupServer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const mockPlanData = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
}

const server = setupServer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const mockPlanDataResponse = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: true,
}

const server = setupServer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const mockPlanDataResponseMonthly = {
planUserCount: 1,
hasSeatsLeft: true,
isEnterprisePlan: false,
isProPlan: true,
isFreePlan: false,
}

Expand All @@ -147,6 +148,7 @@ const mockPlanDataResponseYearly = {
planUserCount: 1,
hasSeatsLeft: true,
isEnterprisePlan: false,
isProPlan: true,
isFreePlan: false,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const mockPlanDataResponse = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: true,
}

const server = setupServer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const mockPlanDataResponseMonthly = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: true,
}

const mockPlanDataResponseYearly = {
Expand All @@ -134,6 +135,7 @@ const mockPlanDataResponseYearly = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: true,
}

const queryClient = new QueryClient({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const mockPlanDataResponse = {
planUserCount: 1,
hasSeatsLeft: true,
isFreePlan: false,
isProPlan: false,
}

const server = setupServer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ describe('ErrorBanner', () => {
planUserCount: 1,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
}
if (planValue === Plans.USERS_BASIC) {
return HttpResponse.json({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const mockPlanDataResponseMonthly = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
}

const mockPlanDataResponseYearly = {
Expand All @@ -133,6 +134,7 @@ const mockPlanDataResponseYearly = {
hasSeatsLeft: true,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
}

const queryClient = new QueryClient({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,15 @@ describe('PlanTypeOptions', () => {
planUserCount: 1,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
}
if (planValue === Plans.USERS_BASIC) {
return HttpResponse.json({
data: { plan: { ...basicPlan, ...planChunk } },
})
} else if (planValue === Plans.USERS_PR_INAPPY) {
return HttpResponse.json({
data: { plan: { ...proPlanYear, ...planChunk } },
data: { plan: { ...proPlanYear, ...planChunk, isProPlan: true } },
})
} else if (planValue === Plans.USERS_TRIAL) {
return HttpResponse.json({
Expand All @@ -212,7 +213,9 @@ describe('PlanTypeOptions', () => {
})
} else if (planValue === Plans.USERS_SENTRYY) {
return HttpResponse.json({
data: { plan: { ...sentryPlanYear, ...planChunk } },
data: {
plan: { ...sentryPlanYear, ...planChunk, isProPlan: true },
},
})
}
})
Expand Down
Loading
Loading