Skip to content

Commit d88bff4

Browse files
authored
feat: Fetch isCached Field in PullPageDataQueryOpts (#3622)
1 parent 113a97f commit d88bff4

File tree

7 files changed

+29
-6
lines changed

7 files changed

+29
-6
lines changed

src/pages/PullRequestPage/PullBundleAnalysis/PullBundleAnalysis.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ const mockPullPageData = (
4848
bundleAnalysis: {
4949
bundleAnalysisReport: {
5050
__typename: headBundleType,
51+
isCached:
52+
headBundleType === 'BundleAnalysisReport' ? false : undefined,
5153
},
5254
},
5355
},

src/pages/PullRequestPage/PullCoverage/PullCoverageTabs/PullCoverageTabs.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ const mockPullData = {
9696
bundleAnalysis: {
9797
bundleAnalysisReport: {
9898
__typename: 'BundleAnalysisReport',
99+
isCached: false,
99100
},
100101
},
101102
},

src/pages/PullRequestPage/PullCoverage/PullCoverageTabs/useTabsCounts.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const mockPullData = {
2626
bundleAnalysis: {
2727
bundleAnalysisReport: {
2828
__typename: 'BundleAnalysisReport',
29+
isCached: false,
2930
},
3031
},
3132
},

src/pages/PullRequestPage/PullCoverage/routes/FileViewer/FileViewer.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const mockPullData = {
102102
bundleAnalysis: {
103103
bundleAnalysisReport: {
104104
__typename: 'BundleAnalysisReport',
105+
isCached: false,
105106
},
106107
},
107108
},

src/pages/PullRequestPage/PullRequestPage.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const mockPullPageData = {
4949
bundleAnalysis: {
5050
bundleAnalysisReport: {
5151
__typename: 'BundleAnalysisReport',
52+
isCached: false,
5253
},
5354
},
5455
},
@@ -75,6 +76,7 @@ const mockPullPageDataTeam = {
7576
bundleAnalysis: {
7677
bundleAnalysisReport: {
7778
__typename: 'BundleAnalysisReport',
79+
isCached: false,
7880
},
7981
},
8082
},

src/pages/PullRequestPage/queries/PullPageDataQueryOpts.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const mockPullData = {
2525
bundleAnalysis: {
2626
bundleAnalysisReport: {
2727
__typename: 'BundleAnalysisReport',
28+
isCached: false,
2829
},
2930
},
3031
},
@@ -60,6 +61,7 @@ const mockPullDataTeam = {
6061
bundleAnalysis: {
6162
bundleAnalysisReport: {
6263
__typename: 'BundleAnalysisReport',
64+
isCached: false,
6365
},
6466
},
6567
},
@@ -195,6 +197,7 @@ describe('PullPageDataQueryOpts', () => {
195197
bundleAnalysis: {
196198
bundleAnalysisReport: {
197199
__typename: 'BundleAnalysisReport',
200+
isCached: false,
198201
},
199202
},
200203
},
@@ -402,6 +405,7 @@ describe('PullPageDataQueryOpts', () => {
402405
bundleAnalysis: {
403406
bundleAnalysisReport: {
404407
__typename: 'BundleAnalysisReport',
408+
isCached: false,
405409
},
406410
},
407411
},

src/pages/PullRequestPage/queries/PullPageDataQueryOpts.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ import Api from 'shared/api'
1717
import { rejectNetworkError } from 'shared/api/helpers'
1818
import A from 'ui/A'
1919

20+
const BundleAnalysisReportSchema = z.object({
21+
__typename: z.literal('BundleAnalysisReport'),
22+
isCached: z.boolean(),
23+
})
24+
25+
const BundleAnalysisReportUnion = z.discriminatedUnion('__typename', [
26+
BundleAnalysisReportSchema,
27+
z.object({ __typename: MissingHeadReportSchema.shape.__typename }),
28+
])
29+
2030
const BundleAnalysisComparisonResult = z.union([
2131
z.literal('BundleAnalysisComparison'),
2232
FirstPullRequestSchema.shape.__typename,
@@ -48,12 +58,7 @@ const RepositorySchema = z.object({
4858
commitid: z.string(),
4959
bundleAnalysis: z
5060
.object({
51-
bundleAnalysisReport: z
52-
.discriminatedUnion('__typename', [
53-
z.object({ __typename: z.literal('BundleAnalysisReport') }),
54-
z.object({ __typename: z.literal('MissingHeadReport') }),
55-
])
56-
.nullable(),
61+
bundleAnalysisReport: BundleAnalysisReportUnion.nullable(),
5762
})
5863
.nullable(),
5964
})
@@ -120,6 +125,12 @@ query PullPageData(
120125
head {
121126
commitid
122127
bundleAnalysis {
128+
bundleAnalysisReport {
129+
__typename
130+
... on BundleAnalysisReport {
131+
isCached
132+
}
133+
}
123134
bundleAnalysisReport {
124135
__typename
125136
}
@@ -155,6 +166,7 @@ query PullPageData(
155166
}
156167
bundleAnalysisCompareWithBase {
157168
__typename
169+
158170
}
159171
}
160172
}

0 commit comments

Comments
 (0)