Skip to content

Commit

Permalink
Merge branch 'main' into gh-eng-3382-render-only-three-levels-of-the-…
Browse files Browse the repository at this point in the history
…sunburst
  • Loading branch information
nicholas-codecov authored Feb 28, 2025
2 parents 80253a1 + 52909c8 commit 6fc34b6
Showing 163 changed files with 1,255 additions and 1,379 deletions.
12 changes: 4 additions & 8 deletions src/layouts/BaseLayout/hooks/NavigatorDataQueryOpts.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { queryOptions as queryOptionsV5 } from '@tanstack/react-queryV5'
import { z } from 'zod'

import {
RepoNotFoundErrorSchema,
RepoOwnerNotActivatedErrorSchema,
} from 'services/repo'
import { RepoNotFoundErrorSchema } from 'services/repo/schemas/RepoNotFoundError'
import { RepoOwnerNotActivatedErrorSchema } from 'services/repo/schemas/RepoOwnerNotActivatedError'
import Api from 'shared/api'
import { rejectNetworkError } from 'shared/api/rejectNetworkError'

@@ -67,15 +65,13 @@ export const NavigatorDataQueryOpts = ({
repo,
},
}).then((res) => {
const callingFn = 'NavigatorDataQueryOpts'
const parsedData = RequestSchema.safeParse(res.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'NavigatorDataQueryOpts',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

Original file line number Diff line number Diff line change
@@ -103,14 +103,13 @@ export const useUpdateOktaConfig = ({ provider, owner }: URLParams) => {
})
},
onSuccess: ({ data }) => {
const callingFn = 'useUpdateOktaConfig'
const parsedData = ResponseSchema.safeParse(data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'useUpdateOktaConfig',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ describe('useOktaConfig', () => {
consoleSpy.mockRestore()
})

it('rejects with 404 status', async () => {
it('rejects with 400 status', async () => {
setup({})

const { result } = renderHook(
Original file line number Diff line number Diff line change
@@ -62,15 +62,13 @@ export function OktaConfigQueryOpts({
username,
},
}).then((res) => {
const callingFn = 'OktaConfigQueryOpts'
const parsedRes = OktaConfigRequestSchema.safeParse(res?.data)

if (!parsedRes.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'OktaConfigQueryOpts',
error: parsedRes.error,
},
errorDetails: { callingFn, error: parsedRes.error },
})
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const ADMIN_TOKEN_REQUIRED_BANNER = 'admin-token-required-banner'
export const MEMBER_TOKEN_REQUIRED_BANNER = 'member-token-required-banner'
export const ADMIN_TOKEN_NOT_REQUIRED_BANNER = 'admin-token-not-required-banner'
export const MEMBER_TOKEN_NOT_REQUIRED_BANNER =
'member-token-not-required-banner'
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export { default } from './TokenlessSection'
export {
ADMIN_TOKEN_REQUIRED_BANNER,
MEMBER_TOKEN_REQUIRED_BANNER,
ADMIN_TOKEN_NOT_REQUIRED_BANNER,
MEMBER_TOKEN_NOT_REQUIRED_BANNER,
} from './constants'
Original file line number Diff line number Diff line change
@@ -6,6 +6,14 @@ import { useAddNotification } from 'services/toastNotification'
import Api from 'shared/api'
import { Provider } from 'shared/api/helpers'
import { rejectNetworkError } from 'shared/api/rejectNetworkError'
import { removeFromLocalStorage } from 'ui/TopBanner/TopBanner'

import {
ADMIN_TOKEN_NOT_REQUIRED_BANNER,
ADMIN_TOKEN_REQUIRED_BANNER,
MEMBER_TOKEN_NOT_REQUIRED_BANNER,
MEMBER_TOKEN_REQUIRED_BANNER,
} from './constants'

const TOAST_DURATION = 10000

@@ -73,14 +81,13 @@ export const useSetUploadTokenRequired = ({
},
mutationPath: 'setUploadTokenRequired',
}).then((res) => {
const callingFn = 'useSetUploadTokenRequired'
const parsedData = ResponseSchema.safeParse(res.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'useSetUploadTokenRequired',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

@@ -102,6 +109,13 @@ export const useSetUploadTokenRequired = ({
disappearAfter: TOAST_DURATION,
})

// we want to show the banners again when this setting is changed
// even if the user dismissed them in the past
removeFromLocalStorage(MEMBER_TOKEN_NOT_REQUIRED_BANNER)
removeFromLocalStorage(ADMIN_TOKEN_NOT_REQUIRED_BANNER)
removeFromLocalStorage(MEMBER_TOKEN_REQUIRED_BANNER)
removeFromLocalStorage(ADMIN_TOKEN_REQUIRED_BANNER)

// only want to invalidate the query if the mutation was successful
// otherwise we're just going to re-fetch the same data
queryClient.invalidateQueries(['GetUploadTokenRequired'])
Original file line number Diff line number Diff line change
@@ -38,15 +38,13 @@ export const useAdminAccessList = () => {
path: `/users?is_admin=true&page=${pageParam}`,
signal,
}).then((res) => {
const callingFn = 'useAdminAccessList'
const parsedData = RequestSchema.safeParse(res)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'useAdminAccessList',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}
return parsedData.data
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ const mockCommitContentData = {
results: [
{
name: 'src',
path: null,
path: 'src',
percentCovered: 50.0,
hits: 24,
misses: 24,
@@ -34,7 +34,7 @@ const mockCommitContentData = {
},
{
name: 'file.ts',
path: null,
path: 'file.ts',
percentCovered: 50.0,
hits: 24,
misses: 24,
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { queryOptions as queryOptionsV5 } from '@tanstack/react-queryV5'
import { z } from 'zod'

import {
RepoNotFoundErrorSchema,
RepoOwnerNotActivatedErrorSchema,
} from 'services/repo'
import { RepoNotFoundErrorSchema } from 'services/repo/schemas/RepoNotFoundError'
import { RepoOwnerNotActivatedErrorSchema } from 'services/repo/schemas/RepoOwnerNotActivatedError'
import Api from 'shared/api'
import { rejectNetworkError } from 'shared/api/rejectNetworkError'
import A from 'ui/A'
@@ -104,15 +102,13 @@ export const CommitHeaderDataQueryOpts = ({
commitId,
},
}).then((res) => {
const callingFn = 'CommitHeaderDataQueryOpts'
const parsedData = CommitHeaderDataSchema.safeParse(res?.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'CommitHeaderDataQueryOpts',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

@@ -121,14 +117,14 @@ export const CommitHeaderDataQueryOpts = ({
if (data?.owner?.repository?.__typename === 'NotFoundError') {
return rejectNetworkError({
errorName: 'Not Found Error',
errorDetails: { callingFn: 'CommitHeaderDataQueryOpts' },
errorDetails: { callingFn },
})
}

if (data?.owner?.repository?.__typename === 'OwnerNotActivatedError') {
return rejectNetworkError({
errorName: 'Owner Not Activated',
errorDetails: { callingFn: 'CommitHeaderDataQueryOpts' },
errorDetails: { callingFn },
data: {
detail: (
<p>
Original file line number Diff line number Diff line change
@@ -7,10 +7,8 @@ import { MissingBaseReportSchema } from 'services/comparison/schemas/MissingBase
import { MissingComparisonSchema } from 'services/comparison/schemas/MissingComparison'
import { MissingHeadCommitSchema } from 'services/comparison/schemas/MissingHeadCommit'
import { MissingHeadReportSchema } from 'services/comparison/schemas/MissingHeadReport'
import {
RepoNotFoundErrorSchema,
RepoOwnerNotActivatedErrorSchema,
} from 'services/repo'
import { RepoNotFoundErrorSchema } from 'services/repo/schemas/RepoNotFoundError'
import { RepoOwnerNotActivatedErrorSchema } from 'services/repo/schemas/RepoOwnerNotActivatedError'
import Api from 'shared/api'
import { rejectNetworkError } from 'shared/api/rejectNetworkError'
import A from 'ui/A'
@@ -163,15 +161,13 @@ export const CommitHeaderDataTeamQueryOpts = ({
commitId,
},
}).then((res) => {
const callingFn = 'CommitHeaderDataTeamQueryOpts'
const parsedData = CommitHeaderDataTeamSchema.safeParse(res?.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'CommitHeaderDataTeamQueryOpts',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

@@ -180,14 +176,14 @@ export const CommitHeaderDataTeamQueryOpts = ({
if (data?.owner?.repository?.__typename === 'NotFoundError') {
return rejectNetworkError({
errorName: 'Not Found Error',
errorDetails: { callingFn: 'CommitHeaderDataTeamQueryOpts' },
errorDetails: { callingFn },
})
}

if (data?.owner?.repository?.__typename === 'OwnerNotActivatedError') {
return rejectNetworkError({
errorName: 'Owner Not Activated',
errorDetails: { callingFn: 'CommitHeaderDataTeamQueryOpts' },
errorDetails: { callingFn },
data: {
detail: (
<p>
16 changes: 6 additions & 10 deletions src/pages/CommitDetailPage/queries/CommitPageDataQueryOpts.tsx
Original file line number Diff line number Diff line change
@@ -7,10 +7,8 @@ import { MissingBaseReportSchema } from 'services/comparison/schemas/MissingBase
import { MissingComparisonSchema } from 'services/comparison/schemas/MissingComparison'
import { MissingHeadCommitSchema } from 'services/comparison/schemas/MissingHeadCommit'
import { MissingHeadReportSchema } from 'services/comparison/schemas/MissingHeadReport'
import {
RepoNotFoundErrorSchema,
RepoOwnerNotActivatedErrorSchema,
} from 'services/repo'
import { RepoNotFoundErrorSchema } from 'services/repo/schemas/RepoNotFoundError'
import { RepoOwnerNotActivatedErrorSchema } from 'services/repo/schemas/RepoOwnerNotActivatedError'
import Api from 'shared/api'
import { rejectNetworkError } from 'shared/api/rejectNetworkError'
import A from 'ui/A'
@@ -157,15 +155,13 @@ export const CommitPageDataQueryOpts = ({
commitId,
},
}).then((res) => {
const callingFn = 'CommitPageDataQueryOpts'
const parsedData = CommitPageDataSchema.safeParse(res?.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'CommitPageDataQueryOpts',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

@@ -174,14 +170,14 @@ export const CommitPageDataQueryOpts = ({
if (data?.owner?.repository?.__typename === 'NotFoundError') {
return rejectNetworkError({
errorName: 'Not Found Error',
errorDetails: { callingFn: 'CommitPageDataQueryOpts' },
errorDetails: { callingFn },
})
}

if (data?.owner?.repository?.__typename === 'OwnerNotActivatedError') {
return rejectNetworkError({
errorName: 'Owner Not Activated',
errorDetails: { callingFn: 'CommitPageDataQueryOpts' },
errorDetails: { callingFn },
data: {
detail: (
<p>
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import { useAccountDetails } from 'services/account/useAccountDetails'
import { TrialStatuses, usePlanData } from 'services/account/usePlanData'
import A from 'ui/A/A'

import ChangePlanLink from './ChangePlanLink'
import ChangePlanLink from './ChangePlanLink/ChangePlanLink'

function Activation() {
const { owner, provider } = useParams()
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import { BillingRate, Plans } from 'shared/utils/billing'

import Activation from './Activation'

vi.mock('./ChangePlanLink', () => ({
vi.mock('./ChangePlanLink/ChangePlanLink', () => ({
default: vi.fn(() => 'ChangePlanLink'),
}))

This file was deleted.

Loading

0 comments on commit 6fc34b6

Please sign in to comment.