Skip to content

Commit b43fac6

Browse files
committed
Merge branch 'main' into Ajay/3003-migrate-is-pro-plan
2 parents 0964dda + 7200eea commit b43fac6

File tree

70 files changed

+342
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+342
-168
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
"eslint-plugin-testing-library": "^6.4.0",
152152
"http-proxy-middleware": "^2.0.7",
153153
"husky": "^9.1.4",
154-
"jsdom": "^25.0.0",
154+
"jsdom": "^25.0.1",
155155
"lint-staged": "^15.2.8",
156156
"msw": "^2.4.11",
157157
"postcss": "^8.4.31",

src/layouts/BaseLayout/BaseLayout.test.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ beforeAll(() => {
208208
server.listen({ onUnhandledRequest: 'warn' })
209209
})
210210

211+
beforeEach(() => {
212+
vi.resetModules()
213+
vi.restoreAllMocks()
214+
})
215+
211216
afterEach(() => {
212217
queryClient.clear()
213218
queryClientV5.clear()
@@ -588,4 +593,27 @@ describe('BaseLayout', () => {
588593
expect(errorMainAppUI).toBeInTheDocument()
589594
})
590595
})
596+
597+
describe('When Header has a network call error', async () => {
598+
it('renders nothing for the errored header', async () => {
599+
vi.spyOn(
600+
await import('layouts/Header'),
601+
'default'
602+
).mockImplementationOnce(() => {
603+
throw new Error('Simulated Header Error')
604+
})
605+
606+
setup({ currentUser: userHasDefaultOrg })
607+
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })
608+
609+
const header = screen.queryByText(/Header/)
610+
expect(header).not.toBeInTheDocument()
611+
612+
const mainAppContent = await screen.findByText('hello')
613+
expect(mainAppContent).toBeInTheDocument()
614+
615+
const footerContent = await screen.findByText(/Footer/)
616+
expect(footerContent).toBeInTheDocument()
617+
})
618+
})
591619
})

src/layouts/BaseLayout/BaseLayout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Header from 'layouts/Header'
77
import ErrorBoundary from 'layouts/shared/ErrorBoundary'
88
import { EmptyErrorComponent } from 'layouts/shared/ErrorBoundary/ErrorBoundary'
99
import NetworkErrorBoundary from 'layouts/shared/NetworkErrorBoundary'
10+
import SilentNetworkErrorWrapper from 'layouts/shared/SilentNetworkErrorWrapper'
1011
import ToastNotifications from 'layouts/ToastNotifications'
1112
import { RepoBreadcrumbProvider } from 'pages/RepoPage/context'
1213
import { useImpersonate } from 'services/impersonate'
@@ -110,7 +111,7 @@ function BaseLayout({ children }: React.PropsWithChildren) {
110111
{/* Header */}
111112
<Suspense>
112113
<ErrorBoundary errorComponent={<EmptyErrorComponent />}>
113-
<NetworkErrorBoundary>
114+
<SilentNetworkErrorWrapper>
114115
{isFullExperience || isImpersonating ? (
115116
<>
116117
<GlobalTopBanners />
@@ -121,7 +122,7 @@ function BaseLayout({ children }: React.PropsWithChildren) {
121122
{showDefaultOrgSelector ? <InstallationHelpBanner /> : null}
122123
</>
123124
)}
124-
</NetworkErrorBoundary>
125+
</SilentNetworkErrorWrapper>
125126
</ErrorBoundary>
126127
</Suspense>
127128

src/pages/AccountSettings/AccountSettings.test.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ describe('AccountSettings', () => {
164164
isEnterprisePlan: planValue === Plans.USERS_ENTERPRISEM,
165165
isFreePlan: planValue === Plans.USERS_BASIC,
166166
isProPlan: false,
167+
isTeamPlan:
168+
planValue === Plans.USERS_TEAMM ||
169+
planValue === Plans.USERS_TEAMY,
167170
},
168171
},
169172
},

src/pages/AccountSettings/AccountSettingsSideMenu.test.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ describe('AccountSettingsSideMenu', () => {
152152
isEnterprisePlan: planValue === Plans.USERS_ENTERPRISEM,
153153
isFreePlan: planValue === Plans.USERS_BASIC,
154154
isProPlan: false,
155+
isTeamPlan:
156+
planValue === Plans.USERS_TEAMM ||
157+
planValue === Plans.USERS_TEAMY,
155158
},
156159
},
157160
},

src/pages/DefaultOrgSelector/DefaultOrgSelector.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { useUpdateDefaultOrganization } from 'services/defaultOrganization'
1717
import { useStaticNavLinks } from 'services/navigation'
1818
import { useStartTrial } from 'services/trial'
1919
import { CustomerIntent, useUser } from 'services/user'
20-
import { isBasicPlan } from 'shared/utils/billing'
2120
import { mapEdges } from 'shared/utils/graphql'
2221
import { providerToName } from 'shared/utils/provider'
2322
import A from 'ui/A/A'
@@ -133,7 +132,7 @@ function DefaultOrgSelector() {
133132
jsonPayload: { action: 'Selected Default Org' },
134133
})
135134
if (
136-
isBasicPlan(planData?.plan?.value) &&
135+
planData?.plan?.isFreePlan &&
137136
selectedOrg !== currentUser?.user?.username &&
138137
isNewTrial &&
139138
planData?.hasPrivateRepos

src/pages/DefaultOrgSelector/DefaultOrgSelector.test.jsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ const wrapper =
159159
)
160160

161161
beforeAll(() => {
162+
console.error = () => {}
162163
server.listen({
163164
onUnhandledRequest: 'warn',
164165
})
@@ -169,6 +170,7 @@ afterEach(() => {
169170
})
170171
afterAll(() => {
171172
server.close()
173+
vi.resetAllMocks()
172174
})
173175

174176
describe('DefaultOrgSelector', () => {
@@ -213,8 +215,10 @@ describe('DefaultOrgSelector', () => {
213215
plan: {
214216
...mockTrialData,
215217
isEnterprisePlan: false,
216-
isFreePlan: false,
217218
isProPlan: false,
219+
isFreePlan: value === Plans.USERS_BASIC,
220+
isTeamPlan:
221+
value === Plans.USERS_TEAMM || value === Plans.USERS_TEAMY,
218222
trialStatus,
219223
value,
220224
},
@@ -1295,7 +1299,7 @@ describe('DefaultOrgSelector', () => {
12951299

12961300
describe('on fetch next page', () => {
12971301
it('renders next page', async () => {
1298-
const { user, fetchNextPage } = setup({
1302+
const { fetchNextPage } = setup({
12991303
useUserData: mockUserData,
13001304
myOrganizationsData: {
13011305
me: {
@@ -1317,12 +1321,6 @@ describe('DefaultOrgSelector', () => {
13171321
render(<DefaultOrgSelector />, { wrapper: wrapper() })
13181322
mocks.useIntersection.mockReturnValue({ isIntersecting: true })
13191323

1320-
const selectOrg = await screen.findByRole('button', {
1321-
name: 'Select an organization',
1322-
})
1323-
1324-
await user.click(selectOrg)
1325-
13261324
await waitFor(() => expect(fetchNextPage).toHaveBeenCalled())
13271325
await waitFor(() => expect(fetchNextPage).toHaveBeenCalledWith('MTI='))
13281326
})

src/pages/MembersPage/MembersActivation/Activation/Activation.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const mockPlanData = {
2929
isEnterprisePlan: false,
3030
isFreePlan: true,
3131
isProPlan: false,
32+
isTeamPlan: false,
3233
baseUnitPrice: 10,
3334
benefits: [],
3435
billingRate: BillingRate.MONTHLY,

src/pages/MembersPage/MembersActivation/MembersActivation.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const mockPlanData = {
4343
isEnterprisePlan: false,
4444
isFreePlan: false,
4545
isProPlan: false,
46+
isTeamPlan: false,
4647
}
4748

4849
const server = setupServer()

src/pages/MembersPage/MembersList/MembersList.test.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ describe('MembersList', () => {
131131
...mockPlanData,
132132
value: planName,
133133
isFreePlan: planName === Plans.USERS_BASIC,
134+
isTeamPlan:
135+
planName === Plans.USERS_TEAMM ||
136+
planName === Plans.USERS_TEAMY,
134137
planUserCount,
135138
hasSeatsLeft,
136139
},

0 commit comments

Comments
 (0)