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

Fix analytics page chart selector behavior #2400

Merged
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
6 changes: 5 additions & 1 deletion src/pages/AnalyticsPage/ChartSelectors/ChartSelectors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,25 @@ function RepoSelector({
setSelectedRepos,
resetRef,
}) {
const { owner } = useParams()
const { owner, provider } = useParams()
const [search, setSearch] = useState()

const onSelectChangeHandler = (item) => {
setSelectedRepos(item)
updateParams({ repositories: item })
}

const { data: tierName } = useTier({ provider, owner })
const shouldDisplayPublicReposOnly = tierName === TierNames.TEAM ? true : null

const { data, isLoading, fetchNextPage, hasNextPage } = useRepos({
active,
sortItem,
term: search,
owner,
first: Infinity,
suspense: false,
isPublic: shouldDisplayPublicReposOnly,
})

return (
Expand Down
17 changes: 16 additions & 1 deletion src/pages/AnalyticsPage/ChartSelectors/ChartSelectors.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ describe('ChartSelectors', () => {
expect(searchBoxUpdated).toHaveAttribute('value', 'codecov')

await waitFor(() => {
expect(useRepos).toBeCalledWith({
expect(useRepos).toHaveBeenCalledWith({
active: true,
first: Infinity,
owner: 'codecov',
Expand All @@ -377,6 +377,7 @@ describe('ChartSelectors', () => {
},
suspense: false,
term: 'codecov',
isPublic: null,
})
})
})
Expand Down Expand Up @@ -490,6 +491,20 @@ describe('ChartSelectors', () => {
const upgradeLink = await screen.findByRole('link', { name: 'Upgrade' })
expect(upgradeLink).toBeInTheDocument()
expect(upgradeLink).toHaveAttribute('href', '/plan/gh/codecov/upgrade')
await waitFor(() => {
expect(useRepos).toHaveBeenCalledWith({
active: true,
first: Infinity,
owner: 'codecov',
sortItem: {
direction: 'ASC',
ordering: 'NAME',
},
suspense: false,
term: '',
isPublic: true,
})
})
})
})
})