Skip to content

Commit bd76de4

Browse files
authored
chore: remove cached bundle feature flag (#3638)
1 parent ac9e926 commit bd76de4

File tree

4 files changed

+96
-147
lines changed

4 files changed

+96
-147
lines changed

src/pages/CommitDetailPage/CommitBundleAnalysis/CommitBundleAnalysis.test.tsx

Lines changed: 38 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ import { MemoryRouter, Route } from 'react-router-dom'
1111

1212
import CommitBundleAnalysis from './CommitBundleAnalysis'
1313

14-
const mocks = vi.hoisted(() => ({
15-
useFlags: vi.fn(),
16-
}))
17-
18-
vi.mock('shared/featureFlags', () => ({
19-
useFlags: mocks.useFlags,
20-
}))
21-
2214
vi.mock('./CommitBundleAnalysisTable', () => ({
2315
default: () => <div>CommitBundleAnalysisTable</div>,
2416
}))
@@ -190,7 +182,6 @@ interface SetupArgs {
190182
firstPullRequest?: boolean
191183
comparisonError?: boolean
192184
hasCachedBundle?: boolean
193-
featureFlag?: boolean
194185
}
195186

196187
describe('CommitBundleAnalysis', () => {
@@ -203,7 +194,6 @@ describe('CommitBundleAnalysis', () => {
203194
firstPullRequest = false,
204195
comparisonError = false,
205196
hasCachedBundle = false,
206-
featureFlag = false,
207197
}: SetupArgs = {
208198
coverageEnabled: true,
209199
bundleAnalysisEnabled: true,
@@ -212,11 +202,8 @@ describe('CommitBundleAnalysis', () => {
212202
firstPullRequest: false,
213203
comparisonError: false,
214204
hasCachedBundle: false,
215-
featureFlag: false,
216205
}
217206
) {
218-
mocks.useFlags.mockReturnValue({ displayCachedBundleBanner: featureFlag })
219-
220207
server.use(
221208
graphql.query('CommitPageData', () => {
222209
return HttpResponse.json({
@@ -259,32 +246,30 @@ describe('CommitBundleAnalysis', () => {
259246
expect(commitBundleAnalysisTable).toBeInTheDocument()
260247
})
261248

262-
describe('feature flag is enabled', () => {
263-
describe('there are cached bundles', () => {
264-
it('renders CachedBundleContentBanner', async () => {
265-
setup({ featureFlag: true, hasCachedBundle: true })
266-
render(<CommitBundleAnalysis />, { wrapper })
249+
describe('there are cached bundles', () => {
250+
it('renders CachedBundleContentBanner', async () => {
251+
setup({ hasCachedBundle: true })
252+
render(<CommitBundleAnalysis />, { wrapper })
267253

268-
const cachedBundleContentBanner = await screen.findByText(
269-
'The reported bundle size includes cached data from previous commits'
270-
)
271-
expect(cachedBundleContentBanner).toBeInTheDocument()
272-
})
254+
const cachedBundleContentBanner = await screen.findByText(
255+
'The reported bundle size includes cached data from previous commits'
256+
)
257+
expect(cachedBundleContentBanner).toBeInTheDocument()
273258
})
259+
})
274260

275-
describe('there are no cached bundles', () => {
276-
it('does not render CachedBundleContentBanner', async () => {
277-
setup({ featureFlag: true, hasCachedBundle: false })
278-
render(<CommitBundleAnalysis />, { wrapper })
261+
describe('there are no cached bundles', () => {
262+
it('does not render CachedBundleContentBanner', async () => {
263+
setup({ hasCachedBundle: false })
264+
render(<CommitBundleAnalysis />, { wrapper })
279265

280-
await waitFor(() => queryClientV5.isFetching())
281-
await waitFor(() => !queryClientV5.isFetching())
266+
await waitFor(() => queryClientV5.isFetching())
267+
await waitFor(() => !queryClientV5.isFetching())
282268

283-
const cachedBundleContentBanner = screen.queryByText(
284-
'The reported bundle size includes cached data from previous commits'
285-
)
286-
expect(cachedBundleContentBanner).not.toBeInTheDocument()
287-
})
269+
const cachedBundleContentBanner = screen.queryByText(
270+
'The reported bundle size includes cached data from previous commits'
271+
)
272+
expect(cachedBundleContentBanner).not.toBeInTheDocument()
288273
})
289274
})
290275

@@ -562,32 +547,30 @@ describe('CommitBundleAnalysis', () => {
562547
})
563548
})
564549

565-
describe('feature flag is enabled', () => {
566-
describe('there are cached bundles', () => {
567-
it('renders CachedBundleContentBanner', async () => {
568-
setup({ featureFlag: true, hasCachedBundle: true })
569-
render(<CommitBundleAnalysis />, { wrapper })
550+
describe('there are cached bundles', () => {
551+
it('renders CachedBundleContentBanner', async () => {
552+
setup({ hasCachedBundle: true })
553+
render(<CommitBundleAnalysis />, { wrapper })
570554

571-
const cachedBundleContentBanner = await screen.findByText(
572-
'The reported bundle size includes cached data from previous commits'
573-
)
574-
expect(cachedBundleContentBanner).toBeInTheDocument()
575-
})
555+
const cachedBundleContentBanner = await screen.findByText(
556+
'The reported bundle size includes cached data from previous commits'
557+
)
558+
expect(cachedBundleContentBanner).toBeInTheDocument()
576559
})
560+
})
577561

578-
describe('there are no cached bundles', () => {
579-
it('does not render CachedBundleContentBanner', async () => {
580-
setup({ featureFlag: true, hasCachedBundle: false })
581-
render(<CommitBundleAnalysis />, { wrapper })
562+
describe('there are no cached bundles', () => {
563+
it('does not render CachedBundleContentBanner', async () => {
564+
setup({ hasCachedBundle: false })
565+
render(<CommitBundleAnalysis />, { wrapper })
582566

583-
await waitFor(() => queryClientV5.isFetching())
584-
await waitFor(() => !queryClientV5.isFetching())
567+
await waitFor(() => queryClientV5.isFetching())
568+
await waitFor(() => !queryClientV5.isFetching())
585569

586-
const cachedBundleContentBanner = screen.queryByText(
587-
'The reported bundle size includes cached data from previous commits'
588-
)
589-
expect(cachedBundleContentBanner).not.toBeInTheDocument()
590-
})
570+
const cachedBundleContentBanner = screen.queryByText(
571+
'The reported bundle size includes cached data from previous commits'
572+
)
573+
expect(cachedBundleContentBanner).not.toBeInTheDocument()
591574
})
592575
})
593576

src/pages/CommitDetailPage/CommitBundleAnalysis/CommitBundleAnalysis.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useParams } from 'react-router-dom'
44

55
import { CachedBundleContentBanner } from 'shared/CachedBundleContentBanner/CachedBundleContentBanner'
66
import ComparisonErrorBanner from 'shared/ComparisonErrorBanner'
7-
import { useFlags } from 'shared/featureFlags'
87
import { ReportUploadType } from 'shared/utils/comparison'
98
import Spinner from 'ui/Spinner'
109

@@ -43,10 +42,6 @@ const BundleContent: React.FC<BundleContentProps> = ({
4342
bundleCompareType,
4443
hasCachedBundle,
4544
}) => {
46-
const { displayCachedBundleBanner } = useFlags({
47-
displayCachedBundleBanner: false,
48-
})
49-
5045
if (bundleCompareType === 'FirstPullRequest') {
5146
return (
5247
<>
@@ -70,9 +65,7 @@ const BundleContent: React.FC<BundleContentProps> = ({
7065

7166
return (
7267
<>
73-
{hasCachedBundle && displayCachedBundleBanner ? (
74-
<CachedBundleContentBanner />
75-
) : null}
68+
{hasCachedBundle ? <CachedBundleContentBanner /> : null}
7669
<Suspense fallback={<Loader />}>
7770
<CommitBundleAnalysisTable />
7871
</Suspense>

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

Lines changed: 56 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ import PullBundleAnalysis from './PullBundleAnalysis'
1818

1919
import { TBundleAnalysisComparisonResult } from '../queries/PullPageDataQueryOpts'
2020

21-
const mocks = vi.hoisted(() => ({
22-
useFlags: vi.fn(),
23-
}))
24-
25-
vi.mock('shared/featureFlags', () => ({
26-
useFlags: mocks.useFlags,
27-
}))
28-
2921
vi.mock('./EmptyTable', () => ({
3022
default: () => <div>EmptyTable</div>,
3123
}))
@@ -159,7 +151,6 @@ interface SetupArgs {
159151
coverageEnabled?: boolean
160152
bundleAnalysisEnabled?: boolean
161153
hasCachedBundle?: boolean
162-
featureFlag?: boolean
163154
}
164155

165156
describe('PullBundleAnalysis', () => {
@@ -169,10 +160,7 @@ describe('PullBundleAnalysis', () => {
169160
coverageEnabled = false,
170161
bundleAnalysisEnabled = false,
171162
hasCachedBundle = false,
172-
featureFlag = false,
173163
}: SetupArgs) {
174-
mocks.useFlags.mockReturnValue({ displayCachedBundleBanner: featureFlag })
175-
176164
server.use(
177165
graphql.query('PullPageData', () => {
178166
return HttpResponse.json({
@@ -217,42 +205,38 @@ describe('PullBundleAnalysis', () => {
217205
expect(table).toBeInTheDocument()
218206
})
219207

220-
describe('feature flag is enabled', () => {
221-
describe('there is a cached bundle', () => {
222-
it('renders the CachedBundleContentBanner', async () => {
223-
setup({
224-
coverageEnabled: true,
225-
bundleAnalysisEnabled: true,
226-
hasCachedBundle: true,
227-
featureFlag: true,
228-
})
229-
render(<PullBundleAnalysis />, { wrapper })
230-
231-
const cachedBundleContentBanner = await screen.findByText(
232-
'The reported bundle size includes cached data from previous commits'
233-
)
234-
expect(cachedBundleContentBanner).toBeInTheDocument()
208+
describe('there is a cached bundle', () => {
209+
it('renders the CachedBundleContentBanner', async () => {
210+
setup({
211+
coverageEnabled: true,
212+
bundleAnalysisEnabled: true,
213+
hasCachedBundle: true,
235214
})
215+
render(<PullBundleAnalysis />, { wrapper })
216+
217+
const cachedBundleContentBanner = await screen.findByText(
218+
'The reported bundle size includes cached data from previous commits'
219+
)
220+
expect(cachedBundleContentBanner).toBeInTheDocument()
236221
})
222+
})
237223

238-
describe('there is not a cached bundle', () => {
239-
it('does not render the CachedBundleContentBanner', async () => {
240-
setup({
241-
coverageEnabled: true,
242-
bundleAnalysisEnabled: true,
243-
hasCachedBundle: false,
244-
featureFlag: true,
245-
})
246-
render(<PullBundleAnalysis />, { wrapper })
247-
248-
await waitFor(() => queryClientV5.isFetching())
249-
await waitFor(() => !queryClientV5.isFetching())
250-
251-
const cachedBundleContentBanner = screen.queryByText(
252-
'The reported bundle size includes cached data from previous commits'
253-
)
254-
expect(cachedBundleContentBanner).not.toBeInTheDocument()
224+
describe('there is not a cached bundle', () => {
225+
it('does not render the CachedBundleContentBanner', async () => {
226+
setup({
227+
coverageEnabled: true,
228+
bundleAnalysisEnabled: true,
229+
hasCachedBundle: false,
255230
})
231+
render(<PullBundleAnalysis />, { wrapper })
232+
233+
await waitFor(() => queryClientV5.isFetching())
234+
await waitFor(() => !queryClientV5.isFetching())
235+
236+
const cachedBundleContentBanner = screen.queryByText(
237+
'The reported bundle size includes cached data from previous commits'
238+
)
239+
expect(cachedBundleContentBanner).not.toBeInTheDocument()
256240
})
257241
})
258242
})
@@ -371,42 +355,38 @@ describe('PullBundleAnalysis', () => {
371355
expect(table).toBeInTheDocument()
372356
})
373357

374-
describe('feature flag is enabled', () => {
375-
describe('there is a cached bundle', () => {
376-
it('renders the CachedBundleContentBanner', async () => {
377-
setup({
378-
coverageEnabled: false,
379-
bundleAnalysisEnabled: true,
380-
hasCachedBundle: true,
381-
featureFlag: true,
382-
})
383-
render(<PullBundleAnalysis />, { wrapper })
384-
385-
const cachedBundleContentBanner = await screen.findByText(
386-
'The reported bundle size includes cached data from previous commits'
387-
)
388-
expect(cachedBundleContentBanner).toBeInTheDocument()
358+
describe('there is a cached bundle', () => {
359+
it('renders the CachedBundleContentBanner', async () => {
360+
setup({
361+
coverageEnabled: false,
362+
bundleAnalysisEnabled: true,
363+
hasCachedBundle: true,
389364
})
365+
render(<PullBundleAnalysis />, { wrapper })
366+
367+
const cachedBundleContentBanner = await screen.findByText(
368+
'The reported bundle size includes cached data from previous commits'
369+
)
370+
expect(cachedBundleContentBanner).toBeInTheDocument()
390371
})
372+
})
391373

392-
describe('there is not a cached bundle', () => {
393-
it('does not render the CachedBundleContentBanner', async () => {
394-
setup({
395-
coverageEnabled: false,
396-
bundleAnalysisEnabled: true,
397-
hasCachedBundle: false,
398-
featureFlag: true,
399-
})
400-
render(<PullBundleAnalysis />, { wrapper })
401-
402-
await waitFor(() => queryClientV5.isFetching())
403-
await waitFor(() => !queryClientV5.isFetching())
404-
405-
const cachedBundleContentBanner = screen.queryByText(
406-
'The reported bundle size includes cached data from previous commits'
407-
)
408-
expect(cachedBundleContentBanner).not.toBeInTheDocument()
374+
describe('there is not a cached bundle', () => {
375+
it('does not render the CachedBundleContentBanner', async () => {
376+
setup({
377+
coverageEnabled: false,
378+
bundleAnalysisEnabled: true,
379+
hasCachedBundle: false,
409380
})
381+
render(<PullBundleAnalysis />, { wrapper })
382+
383+
await waitFor(() => queryClientV5.isFetching())
384+
await waitFor(() => !queryClientV5.isFetching())
385+
386+
const cachedBundleContentBanner = screen.queryByText(
387+
'The reported bundle size includes cached data from previous commits'
388+
)
389+
expect(cachedBundleContentBanner).not.toBeInTheDocument()
410390
})
411391
})
412392
})

src/pages/PullRequestPage/PullBundleAnalysis/PullBundleAnalysis.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useParams } from 'react-router-dom'
44

55
import { CachedBundleContentBanner } from 'shared/CachedBundleContentBanner/CachedBundleContentBanner'
66
import ComparisonErrorBanner from 'shared/ComparisonErrorBanner'
7-
import { useFlags } from 'shared/featureFlags'
87
import { ReportUploadType } from 'shared/utils/comparison'
98
import Spinner from 'ui/Spinner'
109

@@ -46,10 +45,6 @@ const BundleContent: React.FC<BundleContentProps> = ({
4645
headHasBundle,
4746
hasCachedBundle,
4847
}) => {
49-
const { displayCachedBundleBanner } = useFlags({
50-
displayCachedBundleBanner: false,
51-
})
52-
5348
if (bundleCompareType === 'FirstPullRequest') {
5449
return (
5550
<>
@@ -85,9 +80,7 @@ const BundleContent: React.FC<BundleContentProps> = ({
8580

8681
return (
8782
<>
88-
{hasCachedBundle && displayCachedBundleBanner ? (
89-
<CachedBundleContentBanner />
90-
) : null}
83+
{hasCachedBundle ? <CachedBundleContentBanner /> : null}
9184
<Suspense fallback={<Loader />}>
9285
<PullBundleComparisonTable />
9386
</Suspense>

0 commit comments

Comments
 (0)