Skip to content

Commit bfcdda7

Browse files
Merge branch 'main' into cy/light_dark_switch
2 parents 609cb2e + c763e30 commit bfcdda7

File tree

117 files changed

+3197
-4325
lines changed

Some content is hidden

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

117 files changed

+3197
-4325
lines changed

src/App.test.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ const user = {
8484
student: false,
8585
studentCreatedAt: null,
8686
studentUpdatedAt: null,
87-
customerIntent: 'PERSONAL',
8887
},
8988
trackingMetadata: {
9089
service: 'github',
@@ -135,6 +134,14 @@ const mockNavigatorData = {
135134
},
136135
}
137136

137+
const mockOwnerContext = { owner: { ownerid: 123 } }
138+
139+
const mockRepoContext = {
140+
owner: {
141+
repository: { __typename: 'Repository', repoid: 321, private: false },
142+
},
143+
}
144+
138145
const queryClient = new QueryClient({
139146
defaultOptions: { queries: { retry: false } },
140147
})
@@ -249,6 +256,12 @@ describe('App', () => {
249256
}),
250257
graphql.query('NavigatorData', () => {
251258
return HttpResponse.json({ data: mockNavigatorData })
259+
}),
260+
graphql.query('OwnerContext', () => {
261+
return HttpResponse.json({ data: mockOwnerContext })
262+
}),
263+
graphql.query('RepoContext', () => {
264+
return HttpResponse.json({ data: mockRepoContext })
252265
})
253266
)
254267
}
Loading

src/config.js

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const defaultConfig = {
1212
SENTRY_ERROR_SAMPLE_RATE: 1.0,
1313
GH_APP: DEFAULT_GH_APP,
1414
GH_APP_AI: 'codecov-ai',
15+
SUNBURST_ENABLED: true,
1516
}
1617

1718
export function removeReactAppPrefix(obj) {
@@ -33,6 +34,10 @@ export function removeReactAppPrefix(obj) {
3334
keys['HIDE_ACCESS_TAB'] = keys['HIDE_ACCESS_TAB'].toLowerCase() === 'true'
3435
}
3536

37+
if ('SUNBURST_ENABLED' in keys) {
38+
keys['SUNBURST_ENABLED'] = keys['SUNBURST_ENABLED'].toLowerCase() === 'true'
39+
}
40+
3641
if ('SENTRY_TRACING_SAMPLE_RATE' in keys) {
3742
keys['SENTRY_TRACING_SAMPLE_RATE'] = parseFloat(
3843
keys['SENTRY_TRACING_SAMPLE_RATE']

src/config.test.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@ import { removeReactAppPrefix } from 'config'
33
describe('config', () => {
44
describe('removeReactAppPrefix', () => {
55
it('removes REACT_APP prefix', () => {
6-
const obj = {
7-
REACT_APP_TEST_ENV: 'test env',
8-
}
6+
const obj = { REACT_APP_TEST_ENV: 'test env' }
97

108
expect(removeReactAppPrefix(obj)).toEqual({ TEST_ENV: 'test env' })
119
})
1210

1311
describe('sets IS_SELF_HOSTED to boolean', () => {
1412
it('sets to true', () => {
15-
const obj = {
16-
ENV: 'enterprise',
17-
}
13+
const obj = { ENV: 'enterprise' }
1814

1915
expect(removeReactAppPrefix(obj)).toEqual({
2016
ENV: 'enterprise',
@@ -23,9 +19,7 @@ describe('config', () => {
2319
})
2420

2521
it('sets to false', () => {
26-
const obj = {
27-
ENV: 'production',
28-
}
22+
const obj = { ENV: 'production' }
2923

3024
expect(removeReactAppPrefix(obj)).toEqual({
3125
ENV: 'production',
@@ -68,6 +62,14 @@ describe('config', () => {
6862
})
6963
})
7064

65+
describe('sets SUNBURST_ENABLED to boolean', () => {
66+
it('sets to true', () => {
67+
const obj = { SUNBURST_ENABLED: 'true' }
68+
69+
expect(removeReactAppPrefix(obj)).toEqual({ SUNBURST_ENABLED: true })
70+
})
71+
})
72+
7173
describe('sets IS_DEDICATED_NAMESPACE to boolean', () => {
7274
it('sets to true', () => {
7375
const obj = {

src/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Router } from 'react-router-dom'
1212
import { CompatRouter } from 'react-router-dom-v5-compat'
1313

1414
import ErrorBoundary from 'layouts/shared/ErrorBoundary'
15+
import { initEventTracker } from 'services/events/events'
1516
import { withFeatureFlagProvider } from 'shared/featureFlags'
1617

1718
import App from './App'
@@ -38,6 +39,7 @@ const history = createBrowserHistory()
3839

3940
const TOO_MANY_REQUESTS_ERROR_CODE = 429
4041

42+
initEventTracker()
4143
setupSentry({ history })
4244

4345
const queryClient = new QueryClient({

src/layouts/BaseLayout/BaseLayout.test.tsx

+29-76
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ const mockedUseImpersonate = useImpersonate as Mock
2727
vi.mock('shared/GlobalTopBanners', () => ({
2828
default: () => 'GlobalTopBanners',
2929
}))
30-
vi.mock('./InstallationHelpBanner', () => ({
31-
default: () => 'InstallationHelpBanner',
32-
}))
3330
vi.mock('pages/TermsOfService', () => ({ default: () => 'TermsOfService' }))
34-
vi.mock('pages/DefaultOrgSelector', () => ({
35-
default: () => 'DefaultOrgSelector',
36-
}))
3731
vi.mock('layouts/Header', () => ({ default: () => 'Header' }))
3832
vi.mock('layouts/Footer', () => ({ default: () => 'Footer' }))
3933

@@ -53,7 +47,6 @@ const mockUser = {
5347
student: false,
5448
studentCreatedAt: null,
5549
studentUpdatedAt: null,
56-
customerIntent: 'BUSINESS',
5750
externalId: 'asdf',
5851
owners: [
5952
{
@@ -170,6 +163,22 @@ const mockNavigatorData = {
170163
},
171164
}
172165

166+
const mockOwnerContext = {
167+
owner: {
168+
ownerid: 123,
169+
},
170+
}
171+
172+
const mockRepoContext = {
173+
owner: {
174+
repository: {
175+
__typename: 'Repository',
176+
repoid: 321,
177+
private: false,
178+
},
179+
},
180+
}
181+
173182
const server = setupServer()
174183
const queryClient = new QueryClient({
175184
defaultOptions: {
@@ -288,6 +297,14 @@ describe('BaseLayout', () => {
288297
graphql.query('NavigatorData', () => {
289298
return HttpResponse.json({ data: mockNavigatorData })
290299
}),
300+
graphql.query('OwnerContext', () => {
301+
return HttpResponse.json({ data: mockOwnerContext })
302+
}),
303+
graphql.query('RepoContext', () => {
304+
return HttpResponse.json({
305+
data: mockRepoContext,
306+
})
307+
}),
291308
http.get('/internal/users/current', () => {
292309
return HttpResponse.json({})
293310
})
@@ -306,9 +323,6 @@ describe('BaseLayout', () => {
306323
const hello = screen.getByText('hello')
307324
expect(hello).toBeInTheDocument()
308325

309-
const defaultOrg = screen.queryByText(/DefaultOrgSelector/)
310-
expect(defaultOrg).not.toBeInTheDocument()
311-
312326
const termsOfService = screen.queryByText(/TermsOfService/)
313327
expect(termsOfService).not.toBeInTheDocument()
314328
})
@@ -328,9 +342,6 @@ describe('BaseLayout', () => {
328342
const hello = screen.getByText('hello')
329343
expect(hello).toBeInTheDocument()
330344

331-
const defaultOrg = screen.queryByText(/DefaultOrgSelector/)
332-
expect(defaultOrg).not.toBeInTheDocument()
333-
334345
const termsOfService = screen.queryByText(/TermsOfService/)
335346
expect(termsOfService).not.toBeInTheDocument()
336347
})
@@ -361,68 +372,19 @@ describe('BaseLayout', () => {
361372
const header = screen.queryByText(/Header/)
362373
expect(header).not.toBeInTheDocument()
363374
})
364-
365-
it('renders help banner', async () => {
366-
setup({
367-
currentUser: userNoTermsAgreement,
368-
internalUser: mockUserNoTermsAgreement,
369-
})
370-
371-
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })
372-
const helpBanner = await screen.findByText(/InstallationHelpBanner/)
373-
expect(helpBanner).toBeInTheDocument()
374-
})
375375
})
376376

377-
describe('when no default org selected', () => {
378-
it('renders the default org selector', async () => {
379-
setup({
380-
currentUser: loggedInUser,
381-
internalUser: mockUser,
382-
})
383-
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })
384-
385-
const defaultOrgSelector = await screen.findByText(/DefaultOrgSelector/)
386-
expect(defaultOrgSelector).toBeInTheDocument()
387-
})
388-
389-
it('does not render the header', async () => {
390-
setup({
391-
currentUser: loggedInUser,
392-
internalUser: mockUser,
393-
})
394-
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })
395-
396-
const defaultOrgSelector = await screen.findByText(/DefaultOrgSelector/)
397-
expect(defaultOrgSelector).toBeInTheDocument()
398-
399-
const header = screen.queryByText(/Header/)
400-
expect(header).not.toBeInTheDocument()
401-
})
402-
403-
it('renders help banner', async () => {
404-
setup({
405-
currentUser: loggedInUser,
406-
internalUser: mockUser,
407-
})
408-
409-
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })
410-
const helpBanner = await screen.findByText(/InstallationHelpBanner/)
411-
expect(helpBanner).toBeInTheDocument()
412-
})
413-
})
414-
415-
describe('when agreed to TOS and default org selected', () => {
377+
describe('when agreed to TOS', () => {
416378
it('renders children', async () => {
417-
setup({ currentUser: userHasDefaultOrg })
379+
setup({ currentUser: loggedInUser })
418380
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })
419381

420382
const children = await screen.findByText(/hello/)
421383
expect(children).toBeInTheDocument()
422384
})
423385

424386
it('renders header', async () => {
425-
setup({ currentUser: userHasDefaultOrg })
387+
setup({ currentUser: loggedInUser })
426388
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })
427389

428390
const header = await screen.findByText(/Header/)
@@ -464,9 +426,6 @@ describe('BaseLayout', () => {
464426
const hello = screen.getByText('hello')
465427
expect(hello).toBeInTheDocument()
466428

467-
const defaultOrg = screen.queryByText(/DefaultOrgSelector/)
468-
expect(defaultOrg).not.toBeInTheDocument()
469-
470429
const termsOfService = screen.queryByText(/TermsOfService/)
471430
expect(termsOfService).not.toBeInTheDocument()
472431
})
@@ -486,9 +445,6 @@ describe('BaseLayout', () => {
486445
const hello = screen.getByText('hello')
487446
expect(hello).toBeInTheDocument()
488447

489-
const defaultOrg = screen.queryByText(/DefaultOrgSelector/)
490-
expect(defaultOrg).not.toBeInTheDocument()
491-
492448
const termsOfService = screen.queryByText(/TermsOfService/)
493449
expect(termsOfService).not.toBeInTheDocument()
494450
})
@@ -526,23 +482,20 @@ describe('BaseLayout', () => {
526482

527483
const header = await screen.findByText(/Header/)
528484
expect(header).toBeInTheDocument()
529-
530-
const defaultOrgSelector = screen.queryByText(/DefaultOrgSelector/)
531-
expect(defaultOrgSelector).not.toBeInTheDocument()
532485
})
533486
})
534487

535488
describe('when agreed to TOS and default org selected', () => {
536489
it('renders children', async () => {
537-
setup({ currentUser: userHasDefaultOrg })
490+
setup({ currentUser: loggedInUser })
538491
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })
539492

540493
const children = await screen.findByText(/hello/)
541494
expect(children).toBeInTheDocument()
542495
})
543496

544497
it('renders header', async () => {
545-
setup({ currentUser: userHasDefaultOrg })
498+
setup({ currentUser: loggedInUser })
546499
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })
547500

548501
const header = await screen.findByText(/Header/)

0 commit comments

Comments
 (0)