Skip to content

Commit 372201f

Browse files
Merge branch 'main' into th/run-preview-trigger
2 parents df62e3d + 9ecb0dd commit 372201f

File tree

10 files changed

+100
-75
lines changed

10 files changed

+100
-75
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ To run the project in development mode
3030
> npm run start
3131
```
3232

33+
Note: The first run of `npm run start` may take 5-10 minutes to finish building.
34+
3335
The page will reload when you make edits. There is a local proxy to the staging API so you can develop against it. You can overwrite it by creating a `.env.local` file with it with the following:
3436

3537
```
@@ -166,5 +168,4 @@ Read more at the [official documentation.](https://mswjs.io/docs/getting-started
166168

167169
## Contributing
168170

169-
This repository, like all of Codecov's repositories, strives to follow our general [Contributing guidlines](https://github.com/codecov/contributing). If you're considering making a contribution to this repository, we encourage review of our Contributing guidelines first.
170-
171+
This repository, like all of Codecov's repositories, strives to follow our general [Contributing guidelines](https://github.com/codecov/contributing). If you're considering making a contribution to this repository, we encourage review of our Contributing guidelines first.

src/pages/PullRequestPage/PullCoverage/routes/FilesChangedTab/FilesChanged/FilesChangedTable/FilesChangedTable.spec.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,14 @@ const mockPull = ({
116116
const server = setupServer()
117117

118118
const wrapper =
119-
(queryClient: QueryClient): React.FC<React.PropsWithChildren> =>
119+
(
120+
queryClient: QueryClient,
121+
initialEntries = ['/gh/codecov/test-repo/pull/s2h5a6']
122+
): React.FC<React.PropsWithChildren> =>
120123
({ children }) =>
121124
(
122125
<QueryClientProvider client={queryClient}>
123-
<MemoryRouter initialEntries={['/gh/codecov/test-repo/pull/s2h5a6']}>
126+
<MemoryRouter initialEntries={initialEntries}>
124127
<Route path="/:provider/:owner/:repo/pull/:pull">{children}</Route>
125128
</MemoryRouter>
126129
</QueryClientProvider>
@@ -374,6 +377,18 @@ describe('FilesChangedTable', () => {
374377
const pullFileDiff = await screen.findByText('FileDiff')
375378
expect(pullFileDiff).toBeInTheDocument()
376379
})
380+
381+
it('auto expands if param is passed in url', async () => {
382+
const { queryClient } = setup()
383+
render(<FilesChangedTable />, {
384+
wrapper: wrapper(queryClient, [
385+
'/gh/codecov/test-repo/pull/s2h5a6?filepath=flag1/mafs.js',
386+
]),
387+
})
388+
389+
const pullFileDiff = await screen.findByText('FileDiff')
390+
expect(pullFileDiff).toBeInTheDocument()
391+
})
377392
})
378393

379394
describe('highlights critical files', () => {

src/pages/PullRequestPage/PullCoverage/routes/FilesChangedTab/FilesChanged/FilesChangedTable/FilesChangedTable.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import {
1212
import cs from 'classnames'
1313
import isEmpty from 'lodash/isEmpty'
1414
import isNumber from 'lodash/isNumber'
15-
import { Fragment, lazy, Suspense, useMemo, useState } from 'react'
16-
import { useParams } from 'react-router-dom'
15+
import qs from 'qs'
16+
import { Fragment, lazy, Suspense, useEffect, useMemo, useState } from 'react'
17+
import { useLocation , useParams } from 'react-router-dom'
1718

1819
import {
1920
ImpactedFile,
@@ -246,6 +247,11 @@ export default function FilesChangedTable() {
246247
{ id: 'missedLines', desc: true },
247248
])
248249
const { provider, owner, repo, pullId } = useParams<URLParams>()
250+
const location = useLocation()
251+
const params = qs.parse(location.search, {
252+
ignoreQueryPrefix: true,
253+
})
254+
const currentlySelectedFile = params.filepath
249255

250256
const { data: pullData, isLoading } = usePull({
251257
provider,
@@ -274,6 +280,19 @@ export default function FilesChangedTable() {
274280
return []
275281
}, [pullData?.pull?.compareWithBase])
276282

283+
useEffect(() => {
284+
if (data.length > 0 && currentlySelectedFile) {
285+
const fileToExpandIndex = data.findIndex(
286+
(file) => file && file.headName === currentlySelectedFile
287+
)
288+
if (fileToExpandIndex !== -1) {
289+
setExpanded({
290+
[fileToExpandIndex]: true,
291+
})
292+
}
293+
}
294+
}, [data, currentlySelectedFile])
295+
277296
const table = useReactTable({
278297
columns: getColumns({ pullId }),
279298
data,

src/pages/PullRequestPage/PullCoverage/routes/FilesChangedTab/FilesChanged/TableTeam/TableTeam.spec.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,14 @@ const mockNoChangeFileData = {
221221
const server = setupServer()
222222

223223
const wrapper =
224-
(queryClient: QueryClient): React.FC<React.PropsWithChildren> =>
224+
(
225+
queryClient: QueryClient,
226+
initialEntries = ['/gh/codecov/test-repo/pull/s2h5a6']
227+
): React.FC<React.PropsWithChildren> =>
225228
({ children }) =>
226229
(
227230
<QueryClientProvider client={queryClient}>
228-
<MemoryRouter initialEntries={['/gh/codecov/test-repo/pull/s2h5a6']}>
231+
<MemoryRouter initialEntries={initialEntries}>
229232
<Route path="/:provider/:owner/:repo/pull/:pull">{children}</Route>
230233
</MemoryRouter>
231234
</QueryClientProvider>
@@ -425,6 +428,18 @@ describe('TableTeam', () => {
425428
const pullFileDiff = await screen.findByText('FileDiff')
426429
expect(pullFileDiff).toBeInTheDocument()
427430
})
431+
432+
it('auto expands if param is passed in url', async () => {
433+
const { queryClient } = setup()
434+
render(<TableTeam />, {
435+
wrapper: wrapper(queryClient, [
436+
'/gh/codecov/test-repo/pull/s2h5a6?filepath=src/App.jsx',
437+
]),
438+
})
439+
440+
const pullFileDiff = await screen.findByText('FileDiff')
441+
expect(pullFileDiff).toBeInTheDocument()
442+
})
428443
})
429444

430445
describe('highlights critical files', () => {

src/pages/PullRequestPage/PullCoverage/routes/FilesChangedTab/FilesChanged/TableTeam/TableTeam.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import {
1111
} from '@tanstack/react-table'
1212
import cs from 'classnames'
1313
import isEmpty from 'lodash/isEmpty'
14-
import { Fragment, lazy, Suspense, useMemo, useState } from 'react'
15-
import { useParams } from 'react-router-dom'
14+
import qs from 'qs'
15+
import { Fragment, lazy, Suspense, useEffect, useMemo, useState } from 'react'
16+
import { useLocation , useParams } from 'react-router-dom'
1617

1718
import {
1819
ImpactedFile,
@@ -174,6 +175,12 @@ export default function FilesChangedTableTeam() {
174175
mostRecentCompare = pullData?.pull?.compareWithBase
175176
}
176177

178+
const location = useLocation()
179+
const params = qs.parse(location.search, {
180+
ignoreQueryPrefix: true,
181+
})
182+
const currentlySelectedFile = params.filepath
183+
177184
const data = useMemo(() => {
178185
if (
179186
pullData?.pull?.compareWithBase?.__typename === 'Comparison' &&
@@ -185,6 +192,19 @@ export default function FilesChangedTableTeam() {
185192
return []
186193
}, [pullData?.pull?.compareWithBase])
187194

195+
useEffect(() => {
196+
if (data.length > 0 && currentlySelectedFile) {
197+
const fileToExpandIndex = data.findIndex(
198+
(file) => file && file.headName === currentlySelectedFile
199+
)
200+
if (fileToExpandIndex !== -1) {
201+
setExpanded({
202+
[fileToExpandIndex]: true,
203+
})
204+
}
205+
}
206+
}, [data, currentlySelectedFile])
207+
188208
const table = useReactTable({
189209
columns: getColumns({ pullId }),
190210
data,

src/pages/RepoPage/ComponentsTab/BackfillBanners/TriggerSyncBanner/TriggerSyncBanner.spec.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,10 @@ describe('TriggerSyncBanner', () => {
6363
render(<TriggerSyncBanner />, { wrapper })
6464

6565
const enableAnalyticsText = screen.getByText(
66-
'You need to enable Component analytics to see coverage data'
66+
'You will need to enable components to see related coverage data.'
6767
)
6868
expect(enableAnalyticsText).toBeInTheDocument()
69-
expect(
70-
screen.getByText(
71-
'Component analytics is disabled by default. Enable this feature below to see all your historical coverage data and coverage trend for each component.'
72-
)
73-
).toBeInTheDocument()
69+
expect(screen.getByText('No data to display')).toBeInTheDocument()
7470
expect(screen.getByText('Enable component analytics')).toBeInTheDocument()
7571
})
7672

src/pages/RepoPage/ComponentsTab/BackfillBanners/TriggerSyncBanner/TriggerSyncBanner.tsx

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { useParams } from 'react-router-dom'
22

33
import { MEASUREMENT_TYPE, useActivateMeasurements } from 'services/repo'
4-
import Banner from 'ui/Banner'
5-
import BannerContent from 'ui/Banner/BannerContent'
6-
import BannerHeading from 'ui/Banner/BannerHeading'
74
import Button from 'ui/Button'
8-
import Icon from 'ui/Icon'
95

106
type URLParams = {
117
provider: string
@@ -23,37 +19,22 @@ function TriggerSyncBanner() {
2319
})
2420

2521
return (
26-
<div className="py-4">
27-
<Banner variant="plain">
28-
<BannerHeading>
29-
<div className="flex items-center gap-2">
30-
<Icon name="informationCircle" />
31-
<h2 className="font-semibold">
32-
You need to enable Component analytics to see coverage data
33-
</h2>
34-
</div>
35-
</BannerHeading>
36-
<BannerContent>
37-
<div className="flex flex-col gap-4">
38-
<p>
39-
Component analytics is disabled by default. Enable this feature
40-
below to see all your historical coverage data and coverage trend
41-
for each component.
42-
</p>
43-
<div className="flex self-start">
44-
<Button
45-
to={undefined}
46-
hook="backfill-task"
47-
variant="primary"
48-
onClick={mutate}
49-
disabled={false}
50-
>
51-
Enable component analytics
52-
</Button>
53-
</div>
54-
</div>
55-
</BannerContent>
56-
</Banner>
22+
<div className="mt-12 grid gap-4">
23+
<div className="flex flex-col items-center gap-1">
24+
<p>No data to display</p>
25+
<p>You will need to enable components to see related coverage data.</p>
26+
</div>
27+
<div className="flex flex-col items-center">
28+
<Button
29+
to={undefined}
30+
hook="backfill-task"
31+
variant="primary"
32+
onClick={mutate}
33+
disabled={false}
34+
>
35+
Enable component analytics
36+
</Button>
37+
</div>
5738
</div>
5839
)
5940
}

src/pages/RepoPage/ComponentsTab/ComponentsTab.jsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { SentryRoute } from 'sentry'
55
import { useRepoSettingsTeam } from 'services/repo'
66
import { TierNames, useTier } from 'services/tier'
77

8-
import blurredTable from './assets/blurredTable.png'
98
import BackfillBanners from './BackfillBanners/BackfillBanners'
109
import { useRepoBackfillingStatus } from './BackfillBanners/hooks'
1110
import Header from './Header'
@@ -56,16 +55,10 @@ function ComponentsTab() {
5655
{showComponentsTable({
5756
componentsMeasurementsActive,
5857
componentsMeasurementsBackfilled,
59-
}) ? (
58+
}) && (
6059
<SentryRoute path="/:provider/:owner/:repo/components" exact>
6160
<ComponentsTable />
6261
</SentryRoute>
63-
) : (
64-
<img
65-
alt="Blurred components table"
66-
src={blurredTable}
67-
className="h-auto max-w-full"
68-
/>
6962
)}
7063
</div>
7164
</div>

src/pages/RepoPage/ComponentsTab/ComponentsTab.spec.jsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,6 @@ describe('Components Tab', () => {
242242
const syncingBanner = screen.queryByText(/Syncing Banner/)
243243
expect(syncingBanner).not.toBeInTheDocument()
244244
})
245-
246-
it('renders a blurred image of the table', async () => {
247-
render(<ComponentsTab />, { wrapper })
248-
const blurredComponentsTableImage = await screen.findByRole('img', {
249-
name: /Blurred components table/,
250-
})
251-
expect(blurredComponentsTableImage).toBeInTheDocument()
252-
})
253245
})
254246

255247
describe('when rendered while ongoing syncing', () => {
@@ -277,14 +269,6 @@ describe('Components Tab', () => {
277269
const syncingBanner = await screen.findByText(/Syncing Banner/)
278270
expect(syncingBanner).toBeInTheDocument()
279271
})
280-
281-
it('renders a blurred image of the table', async () => {
282-
render(<ComponentsTab />, { wrapper })
283-
const blurredComponentsTableImage = await screen.findByRole('img', {
284-
name: /Blurred components table/,
285-
})
286-
expect(blurredComponentsTableImage).toBeInTheDocument()
287-
})
288272
})
289273

290274
describe('when rendered with backfilled repo', () => {

src/services/repo/useRepoComponents.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export function useRepoComponents({
218218
interval,
219219
after,
220220
before,
221+
branch,
221222
signal,
222223
}),
223224
...opts,

0 commit comments

Comments
 (0)