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

feat: Fetch isCached Field with CommitPageDataQueryOpts #3621

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
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const mockCommitPageData = ({
__typename: 'Comparison',
},
bundleAnalysis: {
bundleAnalysisReport: {
__typename: 'BundleAnalysisReport',
isCached: false,
},
bundleAnalysisCompareWithParent: {
__typename: firstPullRequest
? 'FirstPullRequest'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ const mockCommitPageData = (
: 'Comparison',
},
bundleAnalysis: {
bundleAnalysisReport: {
__typename: 'BundleAnalysisReport',
isCached: false,
},
bundleAnalysisCompareWithParent: {
__typename: 'BundleAnalysisComparison',
},
Expand Down
4 changes: 4 additions & 0 deletions src/pages/CommitDetailPage/CommitDetailPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const mockCommitPageData = ({
__typename: 'Comparison',
},
bundleAnalysis: {
bundleAnalysisReport: {
__typename: 'BundleAnalysisReport',
isCached: false,
},
bundleAnalysisCompareWithParent: {
__typename: 'BundleAnalysisComparison',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const mockCommitData = {
__typename: 'Comparison',
},
bundleAnalysis: {
bundleAnalysisReport: {
__typename: 'BundleAnalysisReport',
isCached: false,
},
bundleAnalysisCompareWithParent: {
__typename: 'BundleAnalysisComparison',
},
Expand Down Expand Up @@ -89,7 +93,7 @@ interface SetupArgs {
isNullOwner?: boolean
}

describe('useCommitPageData', () => {
describe('CommitPageData', () => {
function setup({
isNotFoundError = false,
isOwnerNotActivatedError = false,
Expand Down Expand Up @@ -146,6 +150,10 @@ describe('useCommitPageData', () => {
__typename: 'Comparison',
},
bundleAnalysis: {
bundleAnalysisReport: {
__typename: 'BundleAnalysisReport',
isCached: false,
},
bundleAnalysisCompareWithParent: {
__typename: 'BundleAnalysisComparison',
},
Expand Down
20 changes: 19 additions & 1 deletion src/pages/CommitDetailPage/queries/CommitPageDataQueryOpts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ import Api from 'shared/api'
import { rejectNetworkError } from 'shared/api/helpers'
import A from 'ui/A'

const BundleAnalysisReportSchema = z.object({
__typename: z.literal('BundleAnalysisReport'),
isCached: z.boolean(),
})

const BundleAnalysisReportUnion = z.union([
BundleAnalysisReportSchema,
MissingHeadReportSchema.shape.__typename,
])

const BundleAnalysisComparisonResult = z.union([
z.literal('BundleAnalysisComparison'),
FirstPullRequestSchema.shape.__typename,
Expand Down Expand Up @@ -54,6 +64,7 @@ const RepositorySchema = z.object({
.nullable(),
bundleAnalysis: z
.object({
bundleAnalysisReport: BundleAnalysisReportUnion.nullable(),
bundleAnalysisCompareWithParent: z
.object({
__typename: BundleAnalysisComparisonResult,
Expand Down Expand Up @@ -98,6 +109,12 @@ query CommitPageData($owner: String!, $repo: String!, $commitId: String!) {
__typename
}
bundleAnalysis {
bundleAnalysisReport {
__typename
... on BundleAnalysisReport {
isCached
}
}
bundleAnalysisCompareWithParent {
__typename
}
Expand All @@ -112,7 +129,8 @@ query CommitPageData($owner: String!, $repo: String!, $commitId: String!) {
}
}
}
}`
}
`

interface CommitPageDataQueryArgs {
provider: string
Expand Down
Loading