Skip to content

Commit

Permalink
Merge branch 'main' into Ajay/3003-migrate-is-pro-plan
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-sentry committed Dec 23, 2024
2 parents 0964dda + 7200eea commit b43fac6
Show file tree
Hide file tree
Showing 70 changed files with 342 additions and 168 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"eslint-plugin-testing-library": "^6.4.0",
"http-proxy-middleware": "^2.0.7",
"husky": "^9.1.4",
"jsdom": "^25.0.0",
"jsdom": "^25.0.1",
"lint-staged": "^15.2.8",
"msw": "^2.4.11",
"postcss": "^8.4.31",
Expand Down
28 changes: 28 additions & 0 deletions src/layouts/BaseLayout/BaseLayout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ beforeAll(() => {
server.listen({ onUnhandledRequest: 'warn' })
})

beforeEach(() => {
vi.resetModules()
vi.restoreAllMocks()
})

afterEach(() => {
queryClient.clear()
queryClientV5.clear()
Expand Down Expand Up @@ -588,4 +593,27 @@ describe('BaseLayout', () => {
expect(errorMainAppUI).toBeInTheDocument()
})
})

describe('When Header has a network call error', async () => {
it('renders nothing for the errored header', async () => {
vi.spyOn(
await import('layouts/Header'),
'default'
).mockImplementationOnce(() => {
throw new Error('Simulated Header Error')
})

setup({ currentUser: userHasDefaultOrg })
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })

const header = screen.queryByText(/Header/)
expect(header).not.toBeInTheDocument()

const mainAppContent = await screen.findByText('hello')
expect(mainAppContent).toBeInTheDocument()

const footerContent = await screen.findByText(/Footer/)
expect(footerContent).toBeInTheDocument()
})
})
})
5 changes: 3 additions & 2 deletions src/layouts/BaseLayout/BaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Header from 'layouts/Header'
import ErrorBoundary from 'layouts/shared/ErrorBoundary'
import { EmptyErrorComponent } from 'layouts/shared/ErrorBoundary/ErrorBoundary'
import NetworkErrorBoundary from 'layouts/shared/NetworkErrorBoundary'
import SilentNetworkErrorWrapper from 'layouts/shared/SilentNetworkErrorWrapper'
import ToastNotifications from 'layouts/ToastNotifications'
import { RepoBreadcrumbProvider } from 'pages/RepoPage/context'
import { useImpersonate } from 'services/impersonate'
Expand Down Expand Up @@ -110,7 +111,7 @@ function BaseLayout({ children }: React.PropsWithChildren) {
{/* Header */}
<Suspense>
<ErrorBoundary errorComponent={<EmptyErrorComponent />}>
<NetworkErrorBoundary>
<SilentNetworkErrorWrapper>
{isFullExperience || isImpersonating ? (
<>
<GlobalTopBanners />
Expand All @@ -121,7 +122,7 @@ function BaseLayout({ children }: React.PropsWithChildren) {
{showDefaultOrgSelector ? <InstallationHelpBanner /> : null}
</>
)}
</NetworkErrorBoundary>
</SilentNetworkErrorWrapper>
</ErrorBoundary>
</Suspense>

Expand Down
3 changes: 3 additions & 0 deletions src/pages/AccountSettings/AccountSettings.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ describe('AccountSettings', () => {
isEnterprisePlan: planValue === Plans.USERS_ENTERPRISEM,
isFreePlan: planValue === Plans.USERS_BASIC,
isProPlan: false,
isTeamPlan:
planValue === Plans.USERS_TEAMM ||
planValue === Plans.USERS_TEAMY,
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions src/pages/AccountSettings/AccountSettingsSideMenu.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ describe('AccountSettingsSideMenu', () => {
isEnterprisePlan: planValue === Plans.USERS_ENTERPRISEM,
isFreePlan: planValue === Plans.USERS_BASIC,
isProPlan: false,
isTeamPlan:
planValue === Plans.USERS_TEAMM ||
planValue === Plans.USERS_TEAMY,
},
},
},
Expand Down
3 changes: 1 addition & 2 deletions src/pages/DefaultOrgSelector/DefaultOrgSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { useUpdateDefaultOrganization } from 'services/defaultOrganization'
import { useStaticNavLinks } from 'services/navigation'
import { useStartTrial } from 'services/trial'
import { CustomerIntent, useUser } from 'services/user'
import { isBasicPlan } from 'shared/utils/billing'
import { mapEdges } from 'shared/utils/graphql'
import { providerToName } from 'shared/utils/provider'
import A from 'ui/A/A'
Expand Down Expand Up @@ -133,7 +132,7 @@ function DefaultOrgSelector() {
jsonPayload: { action: 'Selected Default Org' },
})
if (
isBasicPlan(planData?.plan?.value) &&
planData?.plan?.isFreePlan &&
selectedOrg !== currentUser?.user?.username &&
isNewTrial &&
planData?.hasPrivateRepos
Expand Down
14 changes: 6 additions & 8 deletions src/pages/DefaultOrgSelector/DefaultOrgSelector.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const wrapper =
)

beforeAll(() => {
console.error = () => {}
server.listen({
onUnhandledRequest: 'warn',
})
Expand All @@ -169,6 +170,7 @@ afterEach(() => {
})
afterAll(() => {
server.close()
vi.resetAllMocks()
})

describe('DefaultOrgSelector', () => {
Expand Down Expand Up @@ -213,8 +215,10 @@ describe('DefaultOrgSelector', () => {
plan: {
...mockTrialData,
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
isFreePlan: value === Plans.USERS_BASIC,
isTeamPlan:
value === Plans.USERS_TEAMM || value === Plans.USERS_TEAMY,
trialStatus,
value,
},
Expand Down Expand Up @@ -1295,7 +1299,7 @@ describe('DefaultOrgSelector', () => {

describe('on fetch next page', () => {
it('renders next page', async () => {
const { user, fetchNextPage } = setup({
const { fetchNextPage } = setup({
useUserData: mockUserData,
myOrganizationsData: {
me: {
Expand All @@ -1317,12 +1321,6 @@ describe('DefaultOrgSelector', () => {
render(<DefaultOrgSelector />, { wrapper: wrapper() })
mocks.useIntersection.mockReturnValue({ isIntersecting: true })

const selectOrg = await screen.findByRole('button', {
name: 'Select an organization',
})

await user.click(selectOrg)

await waitFor(() => expect(fetchNextPage).toHaveBeenCalled())
await waitFor(() => expect(fetchNextPage).toHaveBeenCalledWith('MTI='))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const mockPlanData = {
isEnterprisePlan: false,
isFreePlan: true,
isProPlan: false,
isTeamPlan: false,
baseUnitPrice: 10,
benefits: [],
billingRate: BillingRate.MONTHLY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const mockPlanData = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
isTeamPlan: false,
}

const server = setupServer()
Expand Down
3 changes: 3 additions & 0 deletions src/pages/MembersPage/MembersList/MembersList.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ describe('MembersList', () => {
...mockPlanData,
value: planName,
isFreePlan: planName === Plans.USERS_BASIC,
isTeamPlan:
planName === Plans.USERS_TEAMM ||
planName === Plans.USERS_TEAMY,
planUserCount,
hasSeatsLeft,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ describe('MembersTable', () => {
...mockPlanData,
value: planName,
isFreePlan: planName === Plans.USERS_BASIC,
isTeamPlan:
planName === Plans.USERS_TEAMM ||
planName === Plans.USERS_TEAMY,
planUserCount,
hasSeatsLeft,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const mockPlanDataResponse = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
isTeamPlan: 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 @@ -43,6 +43,7 @@ const mockPlanDataResponse = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
isTeamPlan: false,
}

const mockPlanDataResponseNoUploadLimit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const mockPlanDataResponse = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
isTeamPlan: false,
trialStatus: TrialStatuses.NOT_STARTED,
trialStartDate: '',
trialEndDate: '',
Expand Down
3 changes: 3 additions & 0 deletions src/pages/OwnerPage/Tabs/TrialReminder/TrialReminder.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ describe('TrialReminder', () => {
trialEndDate,
value: planValue,
isFreePlan: planValue === Plans.USERS_BASIC,
isTeamPlan:
planValue === Plans.USERS_TEAMM ||
planValue === Plans.USERS_TEAMY,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const mockPlanData = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
isTeamPlan: false,
}

const queryClient = new QueryClient({
Expand Down Expand Up @@ -160,6 +161,9 @@ describe('CancelPlanPage', () => {
isEnterprisePlan: planValue === Plans.USERS_ENTERPRISEM,
isFreePlan: planValue === Plans.USERS_BASIC,
isProPlan: planValue === Plans.USERS_PR_INAPPM,
isTeamPlan:
planValue === Plans.USERS_TEAMM ||
planValue === Plans.USERS_TEAMY,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const mockPlanDataResponse = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
isTeamPlan: false,
}

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

Expand All @@ -44,6 +45,7 @@ const freePlanDetails = {
isEnterprisePlan: false,
isFreePlan: true,
isProPlan: false,
isTeamPlan: false,
},
}

Expand All @@ -61,6 +63,7 @@ const enterprisePlan = {
isEnterprisePlan: true,
isFreePlan: false,
isProPlan: false,
isTeamPlan: false,
},
}

Expand All @@ -78,6 +81,7 @@ const usesInvoiceTeamPlan = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
isTeamPlan: true,
},
usesInvoice: true,
}
Expand All @@ -93,6 +97,7 @@ const trialPlanDetails = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
isTeamPlan: true,
},
}

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

const scheduledPhase = {
Expand Down Expand Up @@ -226,6 +227,9 @@ describe('FreePlanCard', () => {
value: planValue,
planUserCount,
isFreePlan: planValue === Plans.USERS_BASIC,
isTeamPlan:
planValue === Plans.USERS_TEAMM ||
planValue === Plans.USERS_TEAMY,
},
pretrialPlan: mockPreTrialPlanInfo,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const mockPlanBasic = {
isEnterprisePlan: false,
isFreePlan: true,
isProPlan: false,
isTeamPlan: false,
baseUnitPrice: 0,
benefits: ['Up to # user', 'Unlimited public repositories'],
billingRate: BillingRate.MONTHLY,
Expand All @@ -35,6 +36,7 @@ const mockPlanPro = {
isEnterprisePlan: false,
isProPlan: true,
isFreePlan: false,
isTeamPlan: false,
baseUnitPrice: 10,
benefits: ['Up to # user', 'Unlimited public repositories'],
billingRate: BillingRate.MONTHLY,
Expand All @@ -54,6 +56,7 @@ const mockPlanTrialing = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
isTeamPlan: 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 @@ -26,6 +26,7 @@ const mockResponse = {
isEnterprisePlan: false,
isProPlan: false,
isFreePlan: true,
isTeamPlan: false,
}

const server = setupServer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const mockProPlan = {
isEnterprisePlan: false,
isProPlan: true,
isFreePlan: false,
isTeamPlan: false,
marketingName: 'Pro',
value: Plans.USERS_PR_INAPPM,
billingRate: BillingRate.MONTHLY,
Expand All @@ -50,6 +51,7 @@ const mockTeamPlan = {
isEnterprisePlan: false,
isFreePlan: false,
isProPlan: false,
isTeamPlan: true,
marketingName: 'Team',
value: Plans.USERS_TEAMM,
billingRate: BillingRate.MONTHLY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { PlanPageDataQueryOpts } from 'pages/PlanPage/queries/PlanPageDataQueryO
import { useAccountDetails, usePlanData } from 'services/account'
import BenefitList from 'shared/plan/BenefitList'
import ScheduledPlanDetails from 'shared/plan/ScheduledPlanDetails'
import { isTeamPlan } from 'shared/utils/billing'

import ActionsBilling from '../shared/ActionsBilling/ActionsBilling'
import PlanPricing from '../shared/PlanPricing'
Expand Down Expand Up @@ -75,7 +74,7 @@ function PaidPlanCard() {
<ScheduledPlanDetails scheduledPhase={scheduledPhase} />
) : null}
</div>
{isNumber(numberOfUploads) && isTeamPlan(plan?.value) ? (
{isNumber(numberOfUploads) && plan?.isTeamPlan ? (
<div>
<p className="mb-2 text-xs font-semibold">Private repo uploads</p>
<p className="text-xs text-ds-gray-senary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ describe('Actions Billing', () => {
...trialPlanData.plan,
value: accountDetails.plan.value,
isFreePlan: accountDetails.plan.value === Plans.USERS_BASIC,
isTeamPlan:
accountDetails.plan.value === Plans.USERS_TEAMM ||
accountDetails.plan.value === Plans.USERS_TEAMY,
},
hasPrivateRepos,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ describe('ProPlanDetails', () => {
plan: {
...mockPlanData,
isFreePlan: !isProPlan && !isSentryPlan,
isTeamPlan: false,
trialStatus: isOngoingTrial
? TrialStatuses.ONGOING
: TrialStatuses.CANNOT_TRIAL,
Expand Down
Loading

0 comments on commit b43fac6

Please sign in to comment.