Skip to content

Commit

Permalink
Update schema
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitvinnakota-codecov committed Jul 18, 2024
1 parent 84aa81d commit 5dec827
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
11 changes: 8 additions & 3 deletions src/services/user/useOwnerRateLimitStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import { NetworkErrorObject } from 'shared/api/helpers'

export const RequestSchema = z
.object({
owner: z
me: z
.object({
isGithubRateLimited: z.boolean(),
owner: z
.object({
isGithubRateLimited: z.boolean(),
})
.nullable(),
})
.nullable(),
})
Expand Down Expand Up @@ -38,6 +42,7 @@ export function useOwnerRateLimitStatus({
query,
}).then((res) => {
const parsedData = RequestSchema.safeParse(res?.data)
console.log(res)
if (!parsedData.success) {
return Promise.reject({
status: 404,
Expand All @@ -47,7 +52,7 @@ export function useOwnerRateLimitStatus({
}

const data = parsedData.data
const isGithubRateLimited = data?.owner?.isGithubRateLimited
const isGithubRateLimited = data?.me?.owner?.isGithubRateLimited
? true
: false
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,11 @@ describe('RepoOrgNotFound', () => {

describe('when the user is rate limited', () => {
it('shows rate limit messaging', async () => {
const { user, triggerResync } = setup({ isGithubRateLimited: true })
setup({ isGithubRateLimited: true })
render(<RepoOrgNotFound />, { wrapper })

const rateLimitText = await screen.findByText(/rate limits/)
expect(rateLimitText).toBeInTheDocument()

const resyncButton = screen.getByRole('button', {
name: /resyncing/i,
})
await user.click(resyncButton)
await waitFor(() => expect(triggerResync).toHaveBeenCalledTimes(1))
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ function ResyncButton() {
if (rateLimit?.isGithubRateLimited) {
return (
<div className="inline">
Try
<button
className="m-0 inline cursor-pointer border-none bg-none p-0 text-ds-blue hover:underline"
onClick={() => triggerResync()}
>
resyncing
</button>
<span className="inline"> otherwise it may be due to </span>
<span className="inline"> It may be due to </span>
<A
to={{ pageName: 'githubRateLimitExceeded' }}
hook={undefined}
Expand Down

0 comments on commit 5dec827

Please sign in to comment.