diff --git a/src/pages/CommitDetailPage/CommitDetailPage.spec.tsx b/src/pages/CommitDetailPage/CommitDetailPage.spec.tsx index 8e41b9e19e..06bcb49cae 100644 --- a/src/pages/CommitDetailPage/CommitDetailPage.spec.tsx +++ b/src/pages/CommitDetailPage/CommitDetailPage.spec.tsx @@ -5,8 +5,6 @@ import { setupServer } from 'msw/node' import { Suspense } from 'react' import { MemoryRouter, Route } from 'react-router-dom' -import { useFlags } from 'shared/featureFlags' - import CommitPage from './CommitDetailPage' jest.mock('ui/TruncatedMessage/hooks') @@ -14,11 +12,6 @@ jest.mock('./Header', () => () => 'Header') jest.mock('./CommitCoverage', () => () => 'CommitCoverage') jest.mock('./CommitBundleAnalysis', () => () => 'CommitBundleAnalysis') -jest.mock('shared/featureFlags') -const mockedUseFlags = useFlags as jest.Mock<{ - bundleAnalysisPrAndCommitPages: boolean -}> - const mockNotFoundCommit = { owner: { isCurrentUserPartOfOrg: false, @@ -146,10 +139,6 @@ describe('CommitDetailPage', () => { bundleAnalysisEnabled: false, } ) { - mockedUseFlags.mockReturnValue({ - bundleAnalysisPrAndCommitPages: true, - }) - server.use( graphql.query('CommitPageData', (req, res, ctx) => { if (notFoundCommit) { diff --git a/src/pages/CommitDetailPage/CommitDetailPage.tsx b/src/pages/CommitDetailPage/CommitDetailPage.tsx index 09673c2f4a..1ce56205a2 100644 --- a/src/pages/CommitDetailPage/CommitDetailPage.tsx +++ b/src/pages/CommitDetailPage/CommitDetailPage.tsx @@ -4,7 +4,6 @@ import { lazy, Suspense } from 'react' import { useLocation, useParams } from 'react-router-dom' import NotFound from 'pages/NotFound' -import { useFlags } from 'shared/featureFlags' import Breadcrumb from 'ui/Breadcrumb' import Spinner from 'ui/Spinner' import SummaryDropdown from 'ui/SummaryDropdown' @@ -43,10 +42,6 @@ const CommitDetailPage: React.FC = () => { const { provider, owner, repo, commit: commitSha } = useParams() const shortSHA = commitSha?.slice(0, 7) - const { bundleAnalysisPrAndCommitPages } = useFlags({ - bundleAnalysisPrAndCommitPages: false, - }) - // reset cache when user navigates to the commit detail page const queryClient = useQueryClient() queryClient.setQueryData(['IgnoredUploadIds'], []) @@ -71,8 +66,7 @@ const CommitDetailPage: React.FC = () => { let displayMode: TDisplayMode = DISPLAY_MODE.COVERAGE if ( commitPageData?.bundleAnalysisEnabled && - commitPageData?.coverageEnabled && - bundleAnalysisPrAndCommitPages + commitPageData?.coverageEnabled ) { const queryString = qs.parse(location.search, { ignoreQueryPrefix: true, @@ -86,10 +80,7 @@ const CommitDetailPage: React.FC = () => { } displayMode = DISPLAY_MODE.BOTH - } else if ( - commitPageData?.bundleAnalysisEnabled && - bundleAnalysisPrAndCommitPages - ) { + } else if (commitPageData?.bundleAnalysisEnabled) { displayMode = DISPLAY_MODE.BUNDLE_ANALYSIS } diff --git a/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTable/CommitsTable.spec.tsx b/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTable/CommitsTable.spec.tsx index d890c510be..1aec063fd4 100644 --- a/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTable/CommitsTable.spec.tsx +++ b/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTable/CommitsTable.spec.tsx @@ -9,15 +9,8 @@ import { setupServer } from 'msw/node' import { mockIsIntersecting } from 'react-intersection-observer/test-utils' import { MemoryRouter, Route } from 'react-router-dom' -import { useFlags } from 'shared/featureFlags' - import CommitsTable from './CommitsTable' -jest.mock('shared/featureFlags') -const mockedUseFlags = useFlags as jest.Mock<{ - bundleAnalysisPrAndCommitPages: boolean -}> - const mockRepoOverview = (bundleAnalysisEnabled = false) => ({ owner: { repository: { @@ -152,10 +145,6 @@ describe('CommitsTable', () => { }: SetupArgs) { const queryClient = new QueryClient() - mockedUseFlags.mockReturnValue({ - bundleAnalysisPrAndCommitPages: true, - }) - server.use( graphql.query('GetRepoOverview', (req, res, ctx) => { return res( diff --git a/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTable/CommitsTable.tsx b/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTable/CommitsTable.tsx index 91549a1ed7..39df40ab72 100644 --- a/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTable/CommitsTable.tsx +++ b/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTable/CommitsTable.tsx @@ -12,7 +12,6 @@ import { useParams } from 'react-router-dom' import { useCommits } from 'services/commits/useCommits' import { useRepoOverview } from 'services/repo' -import { useFlags } from 'shared/featureFlags' import Spinner from 'ui/Spinner' import { createCommitsTableData } from './createCommitsTableData' @@ -89,9 +88,6 @@ const CommitsTable = () => { const { ref, inView } = useInView() const { provider, owner, repo, pullId } = useParams() const { data: overview } = useRepoOverview({ provider, owner, repo }) - const { bundleAnalysisPrAndCommitPages } = useFlags({ - bundleAnalysisPrAndCommitPages: false, - }) const { data: commitsData, @@ -122,8 +118,7 @@ const CommitsTable = () => { const columns = useMemo(() => { if ( overview?.bundleAnalysisEnabled && - !baseColumns.some((column) => column.id === 'bundleAnalysis') && - bundleAnalysisPrAndCommitPages + !baseColumns.some((column) => column.id === 'bundleAnalysis') ) { return [ ...baseColumns, @@ -136,7 +131,7 @@ const CommitsTable = () => { } return baseColumns - }, [bundleAnalysisPrAndCommitPages, overview?.bundleAnalysisEnabled]) + }, [overview?.bundleAnalysisEnabled]) const table = useReactTable({ columns, diff --git a/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTableTeam/CommitsTableTeam.spec.tsx b/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTableTeam/CommitsTableTeam.spec.tsx index 403bd8adb0..6f12399707 100644 --- a/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTableTeam/CommitsTableTeam.spec.tsx +++ b/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTableTeam/CommitsTableTeam.spec.tsx @@ -9,15 +9,8 @@ import { setupServer } from 'msw/node' import { mockIsIntersecting } from 'react-intersection-observer/test-utils' import { MemoryRouter, Route } from 'react-router-dom' -import { useFlags } from 'shared/featureFlags' - import CommitsTableTeam from './CommitsTableTeam' -jest.mock('shared/featureFlags') -const mockedUseFlags = useFlags as jest.Mock<{ - bundleAnalysisPrAndCommitPages: boolean -}> - const mockRepoOverview = (bundleAnalysisEnabled = false) => ({ owner: { repository: { @@ -128,10 +121,6 @@ describe('CommitsTableTeam', () => { }: SetupArgs) { const queryClient = new QueryClient() - mockedUseFlags.mockReturnValue({ - bundleAnalysisPrAndCommitPages: true, - }) - server.use( graphql.query('GetRepoOverview', (req, res, ctx) => { return res( diff --git a/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTableTeam/CommitsTableTeam.tsx b/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTableTeam/CommitsTableTeam.tsx index 93bd7ba40b..f421ede287 100644 --- a/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTableTeam/CommitsTableTeam.tsx +++ b/src/pages/PullRequestPage/PullCoverage/routes/CommitsTab/CommitsTableTeam/CommitsTableTeam.tsx @@ -12,7 +12,6 @@ import { useParams } from 'react-router-dom' import { useCommitsTeam } from 'services/commits' import { useRepoOverview } from 'services/repo' -import { useFlags } from 'shared/featureFlags' import Spinner from 'ui/Spinner' import 'ui/Table/Table.css' @@ -77,9 +76,6 @@ export default function CommitsTableTeam() { const { provider, owner, repo, pullId } = useParams() const { ref, inView } = useInView() const { data: overview } = useRepoOverview({ provider, owner, repo }) - const { bundleAnalysisPrAndCommitPages } = useFlags({ - bundleAnalysisPrAndCommitPages: false, - }) const { data: commitsData, @@ -110,8 +106,7 @@ export default function CommitsTableTeam() { const columns = useMemo(() => { if ( overview?.bundleAnalysisEnabled && - !baseColumns.some((column) => column.id === 'bundleAnalysis') && - bundleAnalysisPrAndCommitPages + !baseColumns.some((column) => column.id === 'bundleAnalysis') ) { return [ ...baseColumns, @@ -124,7 +119,7 @@ export default function CommitsTableTeam() { } return baseColumns - }, [bundleAnalysisPrAndCommitPages, overview?.bundleAnalysisEnabled]) + }, [overview?.bundleAnalysisEnabled]) const table = useReactTable({ columns, diff --git a/src/pages/PullRequestPage/PullRequestPage.spec.tsx b/src/pages/PullRequestPage/PullRequestPage.spec.tsx index cb8b63d2f4..348887dc3b 100644 --- a/src/pages/PullRequestPage/PullRequestPage.spec.tsx +++ b/src/pages/PullRequestPage/PullRequestPage.spec.tsx @@ -13,7 +13,6 @@ import PullRequestPage from './PullRequestPage' jest.mock('shared/featureFlags') const mockedUseFlags = useFlags as jest.Mock<{ multipleTiers: boolean - bundleAnalysisPrAndCommitPages: boolean }> jest.mock('./Header', () => () => 'Header') @@ -189,7 +188,6 @@ describe('PullRequestPage', () => { }: SetupArgs) { mockedUseFlags.mockReturnValue({ multipleTiers: true, - bundleAnalysisPrAndCommitPages: true, }) server.use( diff --git a/src/pages/PullRequestPage/PullRequestPage.tsx b/src/pages/PullRequestPage/PullRequestPage.tsx index 435a179b94..d7653408f4 100644 --- a/src/pages/PullRequestPage/PullRequestPage.tsx +++ b/src/pages/PullRequestPage/PullRequestPage.tsx @@ -42,9 +42,8 @@ const Loader = () => ( function PullRequestPage() { const location = useLocation() const { provider, owner, repo, pullId } = useParams() - const { multipleTiers, bundleAnalysisPrAndCommitPages } = useFlags({ + const { multipleTiers } = useFlags({ multipleTiers: false, - bundleAnalysisPrAndCommitPages: false, }) const { data: overview } = useRepoOverview({ provider, owner, repo }) @@ -68,11 +67,7 @@ function PullRequestPage() { let defaultDropdown: Array<'coverage' | 'bundle'> = [] // default to displaying only coverage let displayMode: TDisplayMode = DISPLAY_MODE.COVERAGE - if ( - data?.bundleAnalysisEnabled && - data?.coverageEnabled && - bundleAnalysisPrAndCommitPages - ) { + if (data?.bundleAnalysisEnabled && data?.coverageEnabled) { const queryString = qs.parse(location.search, { ignoreQueryPrefix: true, depth: 1, @@ -85,7 +80,7 @@ function PullRequestPage() { } displayMode = DISPLAY_MODE.BOTH - } else if (data?.bundleAnalysisEnabled && bundleAnalysisPrAndCommitPages) { + } else if (data?.bundleAnalysisEnabled) { displayMode = DISPLAY_MODE.BUNDLE_ANALYSIS } diff --git a/src/pages/RepoPage/BundlesTab/BundleContent/BundleContent.spec.tsx b/src/pages/RepoPage/BundlesTab/BundleContent/BundleContent.spec.tsx index cd702be023..50b457a284 100644 --- a/src/pages/RepoPage/BundlesTab/BundleContent/BundleContent.spec.tsx +++ b/src/pages/RepoPage/BundlesTab/BundleContent/BundleContent.spec.tsx @@ -6,15 +6,8 @@ import { setupServer } from 'msw/node' import { Suspense } from 'react' import { MemoryRouter, Route } from 'react-router-dom' -import { useFlags } from 'shared/featureFlags' - import BundleContent from './BundleContent' -jest.mock('shared/featureFlags') -const mockedUseFlags = useFlags as jest.Mock<{ - newBundleTab: boolean -}> - jest.mock('./BundleSummary', () => () =>
BundleSummary
) const mockRepoOverview = { @@ -166,13 +159,10 @@ afterAll(() => { interface SetupArgs { isBundleError?: boolean - flagValue?: boolean } describe('BundleContent', () => { - function setup({ isBundleError = false, flagValue = false }: SetupArgs) { - mockedUseFlags.mockReturnValue({ newBundleTab: flagValue }) - + function setup({ isBundleError = false }: SetupArgs) { server.use( graphql.query('BranchBundleSummaryData', (req, res, ctx) => { if (isBundleError) { @@ -208,116 +198,61 @@ describe('BundleContent', () => { }) describe('rendering summary section', () => { - describe('flag is off', () => { - it('renders the bundle summary', async () => { - setup({ flagValue: false }) - render(, { wrapper: wrapper() }) - - const report = await screen.findByText(/Report:/) - expect(report).toBeInTheDocument() - }) - }) + it('renders the bundle summary', async () => { + setup({}) + render(, { wrapper: wrapper() }) - describe('flag is on', () => { - it('renders the new bundle summary', async () => { - setup({ flagValue: true }) - render(, { wrapper: wrapper() }) - - const report = await screen.findByText(/BundleSummary/) - expect(report).toBeInTheDocument() - }) + const report = await screen.findByText(/BundleSummary/) + expect(report).toBeInTheDocument() }) }) describe('rendering content section', () => { - describe('flag is on', () => { - describe('when the bundle type is BundleAnalysisReport', () => { - it('renders the bundle table', async () => { - setup({ flagValue: true }) - render(, { - wrapper: wrapper('/gh/codecov/test-repo/bundles/main/test-bundle'), - }) - - const bundleName = await screen.findByText(/asset-1/) - expect(bundleName).toBeInTheDocument() - - const [type] = await screen.findAllByText('js') - expect(type).toBeInTheDocument() - - const [bundleSize] = await screen.findAllByText(/3kB/) - expect(bundleSize).toBeInTheDocument() - - const [bundleLoadTime] = await screen.findAllByText(/2s/) - expect(bundleLoadTime).toBeInTheDocument() + describe('when the bundle type is BundleAnalysisReport', () => { + it('renders the bundle table', async () => { + setup({}) + render(, { + wrapper: wrapper('/gh/codecov/test-repo/bundles/main/test-bundle'), }) - }) - - describe('when the bundle type is not BundleAnalysisReport', () => { - it('renders the error banner', async () => { - setup({ isBundleError: true, flagValue: true }) - render(, { - wrapper: wrapper('/gh/codecov/test-repo/bundles/main/test-bundle'), - }) - const bannerHeader = await screen.findByText(/Missing Head Report/) - expect(bannerHeader).toBeInTheDocument() + const bundleName = await screen.findByText(/asset-1/) + expect(bundleName).toBeInTheDocument() - const bannerMessage = await screen.findByText( - 'Unable to compare commits because the head of the pull request did not upload a bundle stats file.' - ) - expect(bannerMessage).toBeInTheDocument() - }) + const [type] = await screen.findAllByText('js') + expect(type).toBeInTheDocument() - it('renders the empty table', async () => { - setup({ isBundleError: true, flagValue: true }) - render(, { - wrapper: wrapper('/gh/codecov/test-repo/bundles/main/test-bundle'), - }) + const [bundleSize] = await screen.findAllByText(/3kB/) + expect(bundleSize).toBeInTheDocument() - const dashes = await screen.findAllByText('-') - expect(dashes).toHaveLength(4) - }) + const [bundleLoadTime] = await screen.findAllByText(/2s/) + expect(bundleLoadTime).toBeInTheDocument() }) }) - describe('flag is off', () => { - describe('when the bundle type is BundleAnalysisReport', () => { - it('renders the bundle table', async () => { - setup({}) - render(, { wrapper: wrapper() }) - - const bundleName = await screen.findByText(/bundle1/) - expect(bundleName).toBeInTheDocument() - - const bundleSize = await screen.findByText(/50B/) - expect(bundleSize).toBeInTheDocument() - - const bundleLoadTime = await screen.findByText(/100ms/) - expect(bundleLoadTime).toBeInTheDocument() + describe('when the bundle type is not BundleAnalysisReport', () => { + it('renders the error banner', async () => { + setup({ isBundleError: true }) + render(, { + wrapper: wrapper('/gh/codecov/test-repo/bundles/main/test-bundle'), }) - }) - describe('when the bundle type is not BundleAnalysisReport', () => { - it('renders the error banner', async () => { - setup({ isBundleError: true }) - render(, { wrapper: wrapper() }) + const bannerHeader = await screen.findByText(/Missing Head Report/) + expect(bannerHeader).toBeInTheDocument() - const bannerHeader = await screen.findByText(/Missing Head Report/) - expect(bannerHeader).toBeInTheDocument() + const bannerMessage = await screen.findByText( + 'Unable to compare commits because the head of the pull request did not upload a bundle stats file.' + ) + expect(bannerMessage).toBeInTheDocument() + }) - const bannerMessage = await screen.findByText( - 'Unable to compare commits because the head of the pull request did not upload a bundle stats file.' - ) - expect(bannerMessage).toBeInTheDocument() + it('renders the empty table', async () => { + setup({ isBundleError: true }) + render(, { + wrapper: wrapper('/gh/codecov/test-repo/bundles/main/test-bundle'), }) - it('renders the empty table', async () => { - setup({ isBundleError: true }) - render(, { wrapper: wrapper() }) - - const dashes = await screen.findAllByText('-') - expect(dashes).toHaveLength(3) - }) + const dashes = await screen.findAllByText('-') + expect(dashes).toHaveLength(4) }) }) }) diff --git a/src/pages/RepoPage/BundlesTab/BundleContent/BundleContent.tsx b/src/pages/RepoPage/BundlesTab/BundleContent/BundleContent.tsx index 474bf51b4b..6b4be14dfb 100644 --- a/src/pages/RepoPage/BundlesTab/BundleContent/BundleContent.tsx +++ b/src/pages/RepoPage/BundlesTab/BundleContent/BundleContent.tsx @@ -2,18 +2,14 @@ import { lazy, Suspense, useEffect } from 'react' import { Route, Switch, useParams } from 'react-router-dom' import { useBranchBundleSummary } from 'services/bundleAnalysis' -import { useFlags } from 'shared/featureFlags' import { metrics } from 'shared/utils/metrics' import Spinner from 'ui/Spinner' import AssetsTable from './AssetsTable' import BundleSummary from './BundleSummary' -import BundleSummaryOld from './BundleSummaryOld' -const EmptyTable = lazy(() => import('./EmptyTable')) const AssetEmptyTable = lazy(() => import('./AssetsTable/EmptyTable')) const ErrorBanner = lazy(() => import('./ErrorBanner')) -const BundleTable = lazy(() => import('./BundleTable')) interface URLParams { provider: string @@ -30,9 +26,6 @@ const Loader = () => ( const BundleContent: React.FC = () => { const { provider, owner, repo, branch } = useParams() - const { newBundleTab } = useFlags({ - newBundleTab: false, - }) useEffect(() => { metrics.increment('bundles_tab.bundle_details.visited_page', 1) @@ -44,30 +37,21 @@ const BundleContent: React.FC = () => { return (
- {newBundleTab ? : } + }> {bundleType === 'BundleAnalysisReport' ? ( - newBundleTab ? ( - - - - - - - - - ) : ( - - ) - ) : newBundleTab ? ( - <> - - - + + + + + + + + ) : ( <> - + )} diff --git a/src/pages/RepoPage/BundlesTab/BundleContent/BundleSummaryOld/BundleSummaryOld.spec.tsx b/src/pages/RepoPage/BundlesTab/BundleContent/BundleSummaryOld/BundleSummaryOld.spec.tsx deleted file mode 100644 index 561262c88c..0000000000 --- a/src/pages/RepoPage/BundlesTab/BundleContent/BundleSummaryOld/BundleSummaryOld.spec.tsx +++ /dev/null @@ -1,224 +0,0 @@ -import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { render, screen } from '@testing-library/react' -import { graphql } from 'msw' -import { setupServer } from 'msw/node' -import { Suspense } from 'react' -import { MemoryRouter, Route } from 'react-router-dom' - -import BundleSummaryOld from './BundleSummaryOld' - -const mockRepoOverview = { - owner: { - repository: { - __typename: 'Repository', - private: false, - defaultBranch: 'main', - oldestCommitAt: '2022-10-10T11:59:59', - coverageEnabled: true, - bundleAnalysisEnabled: true, - languages: ['javascript'], - }, - }, -} - -const mockUnknownError = { - owner: { - repository: { - __typename: 'Repository', - branch: null, - }, - }, -} - -const mockBranchBundles = ( - commitid: string | null = '543a5268dce725d85be7747c0f9b61e9a68dea57' -) => ({ - owner: { - repository: { - __typename: 'Repository', - branch: { - head: { - commitid, - bundleAnalysisReport: { - __typename: 'BundleAnalysisReport', - - bundleData: { - loadTime: { threeG: 200 }, - size: { uncompress: 100 }, - }, - bundles: [ - { - name: 'bundle1', - bundleData: { - loadTime: { threeG: 100 }, - size: { uncompress: 50 }, - }, - }, - ], - }, - }, - }, - }, - }, -}) - -const mockBranchBundlesError = { - owner: { - repository: { - __typename: 'Repository', - branch: { - head: { - commitid: '543a5268dce725d85be7747c0f9b61e9a68dea57', - bundleAnalysisReport: { - __typename: 'MissingHeadReport', - message: 'Missing head report', - }, - }, - }, - }, - }, -} - -const server = setupServer() -const queryClient = new QueryClient({ - defaultOptions: { - queries: { - retry: false, - suspense: true, - }, - }, -}) - -const wrapper: React.FC = ({ children }) => ( - - - - Loading

}>{children}
-
-
-
-) - -beforeAll(() => { - server.listen() -}) - -afterEach(() => { - queryClient.clear() - server.resetHandlers() -}) - -interface SetupArgs { - hasBranchBundleError?: boolean - hasCommitId?: boolean - isUnknownError?: boolean -} - -describe('BundleSummaryOld', () => { - function setup({ - hasBranchBundleError = false, - hasCommitId = true, - isUnknownError = false, - }: SetupArgs) { - server.use( - graphql.query('BranchBundleSummaryData', (req, res, ctx) => { - if (hasBranchBundleError) { - return res(ctx.status(200), ctx.data(mockBranchBundlesError)) - } else if (isUnknownError) { - return res(ctx.status(200), ctx.data(mockUnknownError)) - } - - let data = mockBranchBundles() - if (!hasCommitId) { - data = mockBranchBundles(null) - } - - return res(ctx.status(200), ctx.data(data)) - }), - graphql.query('GetRepoOverview', (req, res, ctx) => { - return res(ctx.status(200), ctx.data(mockRepoOverview)) - }) - ) - } - - describe('there is a bundle report', () => { - it('renders the bundle summary message', async () => { - setup({}) - render(, { wrapper }) - - const report = await screen.findByText(/Report:/) - expect(report).toBeInTheDocument() - - const totalSize = await screen.findByText( - /total combined bundle size 100B/ - ) - expect(totalSize).toBeInTheDocument() - }) - - it('renders link to the commit page', async () => { - setup({}) - render(, { wrapper }) - - const source = await screen.findByText(/Source:/) - expect(source).toBeInTheDocument() - - const latestCommit = await screen.findByText(/latest commit/) - expect(latestCommit).toBeInTheDocument() - - const commitLink = await screen.findByRole('link', { - name: '543a526', - }) - expect(commitLink).toBeInTheDocument() - expect(commitLink).toHaveAttribute( - 'href', - '/gh/codecov/test-repo/commit/543a5268dce725d85be7747c0f9b61e9a68dea57' - ) - }) - }) - - describe('there is a known error', () => { - it('renders the known error message', async () => { - setup({ hasBranchBundleError: true }) - render(, { wrapper }) - - const report = await screen.findByText(/Report:/) - expect(report).toBeInTheDocument() - - const message = await screen.findByText(/missing head report/) - expect(message).toBeInTheDocument() - }) - - it('renders the link to the commit page', async () => { - setup({ hasBranchBundleError: true }) - render(, { wrapper }) - - const source = await screen.findByText(/Source:/) - expect(source).toBeInTheDocument() - - const latestCommit = await screen.findByText(/latest commit/) - expect(latestCommit).toBeInTheDocument() - - const commitLink = await screen.findByRole('link', { - name: '543a526', - }) - expect(commitLink).toBeInTheDocument() - expect(commitLink).toHaveAttribute( - 'href', - '/gh/codecov/test-repo/commit/543a5268dce725d85be7747c0f9b61e9a68dea57' - ) - }) - }) - - describe('there is an unknown error', () => { - it('renders the unknown error message', async () => { - setup({ isUnknownError: true }) - render(, { wrapper }) - - const report = await screen.findByText(/Report:/) - expect(report).toBeInTheDocument() - - const message = await screen.findByText(/an unknown error has occurred/) - expect(message).toBeInTheDocument() - }) - }) -}) diff --git a/src/pages/RepoPage/BundlesTab/BundleContent/BundleSummaryOld/BundleSummaryOld.tsx b/src/pages/RepoPage/BundlesTab/BundleContent/BundleSummaryOld/BundleSummaryOld.tsx deleted file mode 100644 index 00ee41f03b..0000000000 --- a/src/pages/RepoPage/BundlesTab/BundleContent/BundleSummaryOld/BundleSummaryOld.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import isString from 'lodash/isString' -import { useParams } from 'react-router-dom' - -import { useBranchBundleSummary } from 'services/bundleAnalysis' -import { formatSizeToString } from 'shared/utils/bundleAnalysis' -import A from 'ui/A' - -interface URLParams { - provider: string - owner: string - repo: string -} - -const BundleSummaryOld: React.FC = () => { - const { provider, owner, repo } = useParams() - const { data: branchBundle } = useBranchBundleSummary({ - provider, - owner, - repo, - }) - - const branchHead = branchBundle?.branch?.head - - if (branchHead?.bundleAnalysisReport?.__typename === 'BundleAnalysisReport') { - const shortSha = branchHead?.commitid?.slice(0, 7) - const sizeTotal = - branchHead?.bundleAnalysisReport?.bundleData?.size?.uncompress - - return ( -
-

- Report: total combined bundle - size {formatSizeToString(sizeTotal)} ℹ -

-

- Source: latest commit{' '} - - {shortSha} - -

-
- ) - } - - let message = branchHead?.bundleAnalysisReport?.message - if (!isString(message)) { - message = 'an unknown error has occurred' - } - - return ( -
-

- Report: - {message.toLowerCase()} ⚠️ -

- {isString(branchHead?.commitid) ? ( -

- Source: latest commit{' '} - - - {branchHead?.commitid?.slice(0, 7)} - - -

- ) : null} -
- ) -} - -export default BundleSummaryOld diff --git a/src/pages/RepoPage/BundlesTab/BundleContent/BundleSummaryOld/index.ts b/src/pages/RepoPage/BundlesTab/BundleContent/BundleSummaryOld/index.ts deleted file mode 100644 index bc47503ee1..0000000000 --- a/src/pages/RepoPage/BundlesTab/BundleContent/BundleSummaryOld/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './BundleSummaryOld' diff --git a/src/pages/RepoPage/BundlesTab/BundleContent/BundleTable/BundleTable.spec.tsx b/src/pages/RepoPage/BundlesTab/BundleContent/BundleTable/BundleTable.spec.tsx deleted file mode 100644 index f38e93f268..0000000000 --- a/src/pages/RepoPage/BundlesTab/BundleContent/BundleTable/BundleTable.spec.tsx +++ /dev/null @@ -1,288 +0,0 @@ -import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { render, renderHook, screen, waitFor } from '@testing-library/react' -import userEvent from '@testing-library/user-event' -import { graphql } from 'msw' -import { setupServer } from 'msw/node' -import { Suspense } from 'react' -import { MemoryRouter, Route } from 'react-router-dom' - -import BundleTable, { useTableData } from './BundleTable' - -const mockRepoOverview = { - owner: { - repository: { - __typename: 'Repository', - private: false, - defaultBranch: 'main', - oldestCommitAt: '2022-10-10T11:59:59', - coverageEnabled: true, - bundleAnalysisEnabled: true, - languages: ['javascript'], - }, - }, -} - -const mockBranchBundles = { - owner: { - repository: { - __typename: 'Repository', - branch: { - head: { - commitid: '543a5268dce725d85be7747c0f9b61e9a68dea57', - bundleAnalysisReport: { - __typename: 'BundleAnalysisReport', - bundleData: { - loadTime: { threeG: 200 }, - size: { uncompress: 100 }, - }, - bundles: [ - { - name: 'bundle1', - bundleData: { - loadTime: { threeG: 100 }, - size: { uncompress: 50 }, - }, - }, - ], - }, - }, - }, - }, - }, -} - -const mockBranchBundlesEmpty = { - owner: { - repository: { - __typename: 'Repository', - branch: { - head: { - commitid: '543a5268dce725d85be7747c0f9b61e9a68dea57', - bundleAnalysisReport: { - __typename: 'BundleAnalysisReport', - bundleData: { - loadTime: { threeG: 0 }, - size: { uncompress: 0 }, - }, - bundles: [], - }, - }, - }, - }, - }, -} - -const mockBranchBundlesError = { - owner: { - repository: { - __typename: 'Repository', - branch: { - head: { - commitid: '543a5268dce725d85be7747c0f9b61e9a68dea57', - bundleAnalysisReport: { - __typename: 'MissingHeadReport', - message: 'Missing head report', - }, - }, - }, - }, - }, -} - -const server = setupServer() -const queryClient = new QueryClient({ - defaultOptions: { - queries: { - suspense: true, - }, - }, -}) - -const wrapper: React.FC = ({ children }) => ( - - - - Loading...

}>{children}
-
-
-
-) - -beforeAll(() => { - server.listen() -}) - -afterEach(() => { - queryClient.clear() - server.resetHandlers() -}) - -afterAll(() => { - server.close() -}) - -interface SetupArgs { - isEmptyList?: boolean - isUnknownError?: boolean -} - -describe('BundleTable', () => { - function setup( - { isEmptyList = false, isUnknownError = false }: SetupArgs = { - isEmptyList: false, - isUnknownError: false, - } - ) { - const user = userEvent.setup() - server.use( - graphql.query('BranchBundleSummaryData', (req, res, ctx) => { - if (isEmptyList) { - return res(ctx.status(200), ctx.data(mockBranchBundlesEmpty)) - } else if (isUnknownError) { - return res(ctx.status(200), ctx.data(mockBranchBundlesError)) - } - - return res(ctx.status(200), ctx.data(mockBranchBundles)) - }), - graphql.query('GetRepoOverview', (req, res, ctx) => { - return res(ctx.status(200), ctx.data(mockRepoOverview)) - }) - ) - - return { user } - } - - describe('there are bundles present', () => { - describe('renders header', () => { - it('renders name column', async () => { - setup() - render(, { wrapper }) - - const nameColumn = await screen.findByText('Bundle name') - expect(nameColumn).toBeInTheDocument() - }) - - it('renders current size column', async () => { - setup() - render(, { wrapper }) - - const currSize = await screen.findByText('Current size') - expect(currSize).toBeInTheDocument() - }) - - it('renders load time column', async () => { - setup() - render(, { wrapper }) - - const loadTimeColumn = await screen.findByText( - 'Estimated load time (3G)' - ) - expect(loadTimeColumn).toBeInTheDocument() - }) - }) - - describe('renders rows', () => { - it('renders bundle name', async () => { - setup() - render(, { wrapper }) - - const bundleName = await screen.findByText('bundle1') - expect(bundleName).toBeInTheDocument() - }) - - it('renders previous size', async () => { - setup() - render(, { wrapper }) - - const currSize = await screen.findByText('50B') - expect(currSize).toBeInTheDocument() - }) - - it('renders load time size', async () => { - setup() - render(, { wrapper }) - - const loadTime = await screen.findByText('100ms') - expect(loadTime).toBeInTheDocument() - }) - }) - }) - - describe('there are no bundles present', () => { - it('renders no bundles message', async () => { - setup({ isEmptyList: true }) - render(, { wrapper }) - - const noBundlesMessage = await screen.findByText( - 'No bundles were found in this commit' - ) - expect(noBundlesMessage).toBeInTheDocument() - }) - }) - - describe('an error type is returned', () => { - it('renders no bundles message', async () => { - setup({ isEmptyList: true }) - render(, { wrapper }) - - const noBundlesMessage = await screen.findByText( - 'No bundles were found in this commit' - ) - expect(noBundlesMessage).toBeInTheDocument() - }) - }) -}) - -describe('useTableData', () => { - function setup( - { isEmptyList = false, isUnknownError = false }: SetupArgs = { - isEmptyList: false, - isUnknownError: false, - } - ) { - server.use( - graphql.query('BranchBundleSummaryData', (req, res, ctx) => { - if (isEmptyList) { - return res(ctx.status(200), ctx.data(mockBranchBundlesEmpty)) - } else if (isUnknownError) { - return res(ctx.status(200), ctx.data(mockBranchBundlesError)) - } - - return res(ctx.status(200), ctx.data(mockBranchBundles)) - }), - graphql.query('GetRepoOverview', (req, res, ctx) => { - return res(ctx.status(200), ctx.data(mockRepoOverview)) - }) - ) - } - - describe('valid bundle data is returned', () => { - it('creates a table data object', async () => { - setup() - const { result } = renderHook(() => useTableData(), { wrapper }) - - await waitFor(() => - expect(result.current).toStrictEqual([ - { - name: 'bundle1', - currSize: 50, - loadTime: 100, - }, - ]) - ) - }) - }) - - describe('invalid bundle data is returned', () => { - it('returns an empty list', async () => { - setup({ isUnknownError: true }) - const { result } = renderHook(() => useTableData(), { wrapper }) - - await waitFor(() => expect(result.current).toStrictEqual([])) - }) - }) -}) diff --git a/src/pages/RepoPage/BundlesTab/BundleContent/BundleTable/BundleTable.tsx b/src/pages/RepoPage/BundlesTab/BundleContent/BundleTable/BundleTable.tsx deleted file mode 100644 index 0045d2a24a..0000000000 --- a/src/pages/RepoPage/BundlesTab/BundleContent/BundleTable/BundleTable.tsx +++ /dev/null @@ -1,153 +0,0 @@ -import { - createColumnHelper, - flexRender, - getCoreRowModel, - getSortedRowModel, - useReactTable, -} from '@tanstack/react-table' -import cs from 'classnames' -import isEmpty from 'lodash/isEmpty' -import { useMemo, useState } from 'react' -import { useParams } from 'react-router-dom' - -import { useBranchBundleSummary } from 'services/bundleAnalysis' -import { - formatSizeToString, - formatTimeToString, -} from 'shared/utils/bundleAnalysis' -import Icon from 'ui/Icon' - -import 'ui/Table/Table.css' - -interface URLParams { - provider: string - owner: string - repo: string -} - -interface BundleColumn { - name: string - currSize: number - loadTime: number -} - -const columnHelper = createColumnHelper() - -const columns = [ - columnHelper.accessor('name', { - header: 'Bundle name', - cell: (info) => info.renderValue(), - }), - columnHelper.accessor('currSize', { - header: 'Current size', - cell: (info) => formatSizeToString(info.getValue()), - }), - columnHelper.accessor('loadTime', { - header: 'Estimated load time (3G)', - cell: (info) => formatTimeToString(info.getValue()), - }), -] - -export const useTableData = () => { - const { provider, owner, repo } = useParams() - const { data } = useBranchBundleSummary({ provider, owner, repo }) - - return useMemo(() => { - if ( - data?.branch?.head?.bundleAnalysisReport?.__typename !== - 'BundleAnalysisReport' - ) { - return [] - } - - return data?.branch?.head?.bundleAnalysisReport?.bundles?.map((bundle) => ({ - name: bundle.name, - currSize: bundle.bundleData.size.uncompress, - loadTime: bundle.bundleData.loadTime.threeG, - })) - }, [data]) -} - -const BundleTable: React.FC = () => { - const [sorting, setSorting] = useState([{ id: 'currSize', desc: true }]) - - const data = useTableData() - const table = useReactTable({ - data, - columns, - state: { - sorting, - }, - onSortingChange: setSorting, - getCoreRowModel: getCoreRowModel(), - getSortedRowModel: getSortedRowModel(), - }) - - if (isEmpty(data)) { - return

No bundles were found in this commit

- } - - return ( -
- - - - - - - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => ( - - ))} - - ))} - - - {table.getRowModel().rows.map((row) => ( - - {row.getVisibleCells().map((cell) => ( - - ))} - - ))} - -
-
- {flexRender( - header.column.columnDef.header, - header.getContext() - )} - - - -
-
- {flexRender(cell.column.columnDef.cell, cell.getContext())} -
-
- ) -} - -export default BundleTable diff --git a/src/pages/RepoPage/BundlesTab/BundleContent/BundleTable/index.ts b/src/pages/RepoPage/BundlesTab/BundleContent/BundleTable/index.ts deleted file mode 100644 index 1bc04668aa..0000000000 --- a/src/pages/RepoPage/BundlesTab/BundleContent/BundleTable/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './BundleTable' diff --git a/src/pages/RepoPage/BundlesTab/BundleContent/EmptyTable/EmptyTable.spec.tsx b/src/pages/RepoPage/BundlesTab/BundleContent/EmptyTable/EmptyTable.spec.tsx deleted file mode 100644 index e7a82cae98..0000000000 --- a/src/pages/RepoPage/BundlesTab/BundleContent/EmptyTable/EmptyTable.spec.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { render, screen } from '@testing-library/react' - -import EmptyTable from './EmptyTable' - -describe('EmptyTable', () => { - describe('renders table header', () => { - it('renders name column', () => { - render() - - const name = screen.getByText('Bundle name') - expect(name).toBeInTheDocument() - }) - - it('renders currSize column', () => { - render() - - const currSize = screen.getByText('Current size') - expect(currSize).toBeInTheDocument() - }) - - it('renders loadTime column', () => { - render() - - const loadTime = screen.getByText('Estimated load time (3G)') - expect(loadTime).toBeInTheDocument() - }) - }) - - it('renders three dashes for table body', () => { - render() - - const dashes = screen.getAllByText('-') - expect(dashes).toHaveLength(3) - }) -}) diff --git a/src/pages/RepoPage/BundlesTab/BundleContent/EmptyTable/EmptyTable.tsx b/src/pages/RepoPage/BundlesTab/BundleContent/EmptyTable/EmptyTable.tsx deleted file mode 100644 index 6ecffba64e..0000000000 --- a/src/pages/RepoPage/BundlesTab/BundleContent/EmptyTable/EmptyTable.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import 'ui/Table/Table.css' - -const EmptyTable: React.FC = () => { - return ( -
- - - - - - - - - - - - - - - - - - - - -
Bundle name -
- Current size -
-
-
- Estimated load time (3G) -
-
- -
-
-
-
-
-
-
- ) -} - -export default EmptyTable diff --git a/src/pages/RepoPage/BundlesTab/BundleContent/EmptyTable/index.ts b/src/pages/RepoPage/BundlesTab/BundleContent/EmptyTable/index.ts deleted file mode 100644 index 86c60fcc68..0000000000 --- a/src/pages/RepoPage/BundlesTab/BundleContent/EmptyTable/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './EmptyTable' diff --git a/src/pages/RepoPage/CommitsTab/CommitsTable/CommitsTable.spec.tsx b/src/pages/RepoPage/CommitsTab/CommitsTable/CommitsTable.spec.tsx index 5488e73aee..af1837e605 100644 --- a/src/pages/RepoPage/CommitsTab/CommitsTable/CommitsTable.spec.tsx +++ b/src/pages/RepoPage/CommitsTab/CommitsTable/CommitsTable.spec.tsx @@ -9,15 +9,8 @@ import { setupServer } from 'msw/node' import { mockIsIntersecting } from 'react-intersection-observer/test-utils' import { MemoryRouter, Route } from 'react-router-dom' -import { useFlags } from 'shared/featureFlags' - import CommitsTable from './CommitsTable' -jest.mock('shared/featureFlags') -const mockedUseFlags = useFlags as jest.Mock<{ - bundleAnalysisPrAndCommitPages: boolean -}> - const mockRepoOverview = (bundleAnalysisEnabled = false) => ({ owner: { repository: { @@ -152,10 +145,6 @@ describe('CommitsTable', () => { }: SetupArgs) { const queryClient = new QueryClient() - mockedUseFlags.mockReturnValue({ - bundleAnalysisPrAndCommitPages: true, - }) - server.use( graphql.query('GetRepoOverview', (req, res, ctx) => { return res( diff --git a/src/pages/RepoPage/CommitsTab/CommitsTable/CommitsTable.tsx b/src/pages/RepoPage/CommitsTab/CommitsTable/CommitsTable.tsx index 69a67935da..e1dd08b650 100644 --- a/src/pages/RepoPage/CommitsTab/CommitsTable/CommitsTable.tsx +++ b/src/pages/RepoPage/CommitsTab/CommitsTable/CommitsTable.tsx @@ -12,7 +12,6 @@ import { useParams } from 'react-router-dom' import { type CommitStatsEnum, useCommits } from 'services/commits/useCommits' import { useRepoOverview } from 'services/repo' -import { useFlags } from 'shared/featureFlags' import Spinner from 'ui/Spinner' import { createCommitsTableData } from './createCommitsTableData' @@ -98,9 +97,6 @@ const CommitsTable: React.FC = ({ const { provider, owner, repo } = useParams() const { ref, inView } = useInView() const { data: overview } = useRepoOverview({ provider, owner, repo }) - const { bundleAnalysisPrAndCommitPages } = useFlags({ - bundleAnalysisPrAndCommitPages: false, - }) const { data: commitsData, @@ -136,8 +132,7 @@ const CommitsTable: React.FC = ({ const columns = useMemo(() => { if ( overview?.bundleAnalysisEnabled && - !baseColumns.some((column) => column.id === 'bundleAnalysis') && - bundleAnalysisPrAndCommitPages + !baseColumns.some((column) => column.id === 'bundleAnalysis') ) { return [ ...baseColumns, @@ -150,7 +145,7 @@ const CommitsTable: React.FC = ({ } return baseColumns - }, [bundleAnalysisPrAndCommitPages, overview?.bundleAnalysisEnabled]) + }, [overview?.bundleAnalysisEnabled]) const table = useReactTable({ columns, diff --git a/src/pages/RepoPage/CommitsTab/CommitsTableTeam/CommitsTableTeam.spec.tsx b/src/pages/RepoPage/CommitsTab/CommitsTableTeam/CommitsTableTeam.spec.tsx index 9f95b5cf7e..445cf4b821 100644 --- a/src/pages/RepoPage/CommitsTab/CommitsTableTeam/CommitsTableTeam.spec.tsx +++ b/src/pages/RepoPage/CommitsTab/CommitsTableTeam/CommitsTableTeam.spec.tsx @@ -9,15 +9,8 @@ import { setupServer } from 'msw/node' import { mockIsIntersecting } from 'react-intersection-observer/test-utils' import { MemoryRouter, Route } from 'react-router-dom' -import { useFlags } from 'shared/featureFlags' - import CommitsTableTeam from './CommitsTableTeam' -jest.mock('shared/featureFlags') -const mockedUseFlags = useFlags as jest.Mock<{ - bundleAnalysisPrAndCommitPages: boolean -}> - const mockRepoOverview = (bundleAnalysisEnabled = false) => ({ owner: { repository: { @@ -128,10 +121,6 @@ describe('CommitsTableTeam', () => { }: SetupArgs) { const queryClient = new QueryClient() - mockedUseFlags.mockReturnValue({ - bundleAnalysisPrAndCommitPages: true, - }) - server.use( graphql.query('GetRepoOverview', (req, res, ctx) => { return res( diff --git a/src/pages/RepoPage/CommitsTab/CommitsTableTeam/CommitsTableTeam.tsx b/src/pages/RepoPage/CommitsTab/CommitsTableTeam/CommitsTableTeam.tsx index addc227795..f014882b20 100644 --- a/src/pages/RepoPage/CommitsTab/CommitsTableTeam/CommitsTableTeam.tsx +++ b/src/pages/RepoPage/CommitsTab/CommitsTableTeam/CommitsTableTeam.tsx @@ -15,7 +15,6 @@ import { useCommitsTeam, } from 'services/commits/useCommitsTeam' import { useRepoOverview } from 'services/repo' -import { useFlags } from 'shared/featureFlags' import Spinner from 'ui/Spinner' import { createCommitsTableTeamData } from './createCommitsTableTeamData' @@ -89,9 +88,6 @@ const CommitsTableTeam: React.FC = ({ const { provider, owner, repo } = useParams() const { ref, inView } = useInView() const { data: overview } = useRepoOverview({ provider, owner, repo }) - const { bundleAnalysisPrAndCommitPages } = useFlags({ - bundleAnalysisPrAndCommitPages: false, - }) const { data: commitsData, @@ -124,8 +120,7 @@ const CommitsTableTeam: React.FC = ({ const columns = useMemo(() => { if ( overview?.bundleAnalysisEnabled && - !baseColumns.some((column) => column.id === 'bundleAnalysis') && - bundleAnalysisPrAndCommitPages + !baseColumns.some((column) => column.id === 'bundleAnalysis') ) { return [ ...baseColumns, @@ -138,7 +133,7 @@ const CommitsTableTeam: React.FC = ({ } return baseColumns - }, [bundleAnalysisPrAndCommitPages, overview?.bundleAnalysisEnabled]) + }, [overview?.bundleAnalysisEnabled]) const table = useReactTable({ columns, diff --git a/src/pages/RepoPage/PullsTab/PullsTable/PullsTable.spec.tsx b/src/pages/RepoPage/PullsTab/PullsTable/PullsTable.spec.tsx index 966d363495..0d65b7a841 100644 --- a/src/pages/RepoPage/PullsTab/PullsTable/PullsTable.spec.tsx +++ b/src/pages/RepoPage/PullsTab/PullsTable/PullsTable.spec.tsx @@ -9,15 +9,8 @@ import { setupServer } from 'msw/node' import { mockIsIntersecting } from 'react-intersection-observer/test-utils' import { MemoryRouter, Route } from 'react-router-dom' -import { useFlags } from 'shared/featureFlags' - import PullsTable from './PullsTable' -jest.mock('shared/featureFlags') -const mockedUseFlags = useFlags as jest.Mock<{ - bundleAnalysisPrAndCommitPages: boolean -}> - const mockRepoOverview = (bundleAnalysisEnabled = false) => ({ owner: { repository: { @@ -144,10 +137,6 @@ describe('PullsTable', () => { noEntries = false, bundleAnalysisEnabled = false, }: SetupArgs) { - mockedUseFlags.mockReturnValue({ - bundleAnalysisPrAndCommitPages: true, - }) - const queryClient = new QueryClient() server.use( diff --git a/src/pages/RepoPage/PullsTab/PullsTable/PullsTable.tsx b/src/pages/RepoPage/PullsTab/PullsTable/PullsTable.tsx index adb467b4db..69e9f9a5ca 100644 --- a/src/pages/RepoPage/PullsTab/PullsTable/PullsTable.tsx +++ b/src/pages/RepoPage/PullsTab/PullsTable/PullsTable.tsx @@ -14,7 +14,6 @@ import { useLocationParams } from 'services/navigation' import { usePulls } from 'services/pulls' import 'ui/Table/Table.css' import { useRepoOverview } from 'services/repo' -import { useFlags } from 'shared/featureFlags' import Spinner from 'ui/Spinner' import { createPullsTableData } from './createPullsTableData' @@ -94,9 +93,6 @@ export default function PullsTableTeam() { // we really need to TS'ify and generic'ify useLocationParams const { params } = useLocationParams(defaultParams) const { data: overview } = useRepoOverview({ provider, owner, repo }) - const { bundleAnalysisPrAndCommitPages } = useFlags({ - bundleAnalysisPrAndCommitPages: false, - }) const { data: pullsData, @@ -135,8 +131,7 @@ export default function PullsTableTeam() { const columns = useMemo(() => { if ( overview?.bundleAnalysisEnabled && - !baseColumns.some((column) => column.id === 'bundleAnalysis') && - bundleAnalysisPrAndCommitPages + !baseColumns.some((column) => column.id === 'bundleAnalysis') ) { return [ ...baseColumns, @@ -149,7 +144,7 @@ export default function PullsTableTeam() { } return baseColumns - }, [bundleAnalysisPrAndCommitPages, overview?.bundleAnalysisEnabled]) + }, [overview?.bundleAnalysisEnabled]) const table = useReactTable({ columns, diff --git a/src/pages/RepoPage/PullsTab/PullsTableTeam/PullsTableTeam.spec.tsx b/src/pages/RepoPage/PullsTab/PullsTableTeam/PullsTableTeam.spec.tsx index 58d5fed7f4..f64cfd5c74 100644 --- a/src/pages/RepoPage/PullsTab/PullsTableTeam/PullsTableTeam.spec.tsx +++ b/src/pages/RepoPage/PullsTab/PullsTableTeam/PullsTableTeam.spec.tsx @@ -9,15 +9,8 @@ import { setupServer } from 'msw/node' import { mockIsIntersecting } from 'react-intersection-observer/test-utils' import { MemoryRouter, Route } from 'react-router-dom' -import { useFlags } from 'shared/featureFlags' - import PullsTableTeam from './PullsTableTeam' -jest.mock('shared/featureFlags') -const mockedUseFlags = useFlags as jest.Mock<{ - bundleAnalysisPrAndCommitPages: boolean -}> - const mockRepoOverview = (bundleAnalysisEnabled = false) => ({ owner: { repository: { @@ -133,9 +126,6 @@ describe('PullsTableTeam', () => { bundleAnalysisEnabled = false, }: SetupArgs) { const queryClient = new QueryClient() - mockedUseFlags.mockReturnValue({ - bundleAnalysisPrAndCommitPages: true, - }) server.use( graphql.query('GetRepoOverview', (req, res, ctx) => { diff --git a/src/pages/RepoPage/PullsTab/PullsTableTeam/PullsTableTeam.tsx b/src/pages/RepoPage/PullsTab/PullsTableTeam/PullsTableTeam.tsx index d3ddd4c854..2abd38a0e6 100644 --- a/src/pages/RepoPage/PullsTab/PullsTableTeam/PullsTableTeam.tsx +++ b/src/pages/RepoPage/PullsTab/PullsTableTeam/PullsTableTeam.tsx @@ -14,7 +14,6 @@ import { useLocationParams } from 'services/navigation' import { usePullsTeam } from 'services/pulls/usePullsTeam' import 'ui/Table/Table.css' import { useRepoOverview } from 'services/repo' -import { useFlags } from 'shared/featureFlags' import Spinner from 'ui/Spinner' import { createPullsTableTeamData } from './createPullsTableTeamData' @@ -74,9 +73,6 @@ export default function PullsTableTeam() { // we really need to TS'ify and generic'ify useLocationParams const { params } = useLocationParams(defaultParams) const { data: overview } = useRepoOverview({ provider, owner, repo }) - const { bundleAnalysisPrAndCommitPages } = useFlags({ - bundleAnalysisPrAndCommitPages: false, - }) const { data: pullsData, @@ -115,8 +111,7 @@ export default function PullsTableTeam() { const columns = useMemo(() => { if ( overview?.bundleAnalysisEnabled && - !baseColumns.some((column) => column.id === 'bundleAnalysis') && - bundleAnalysisPrAndCommitPages + !baseColumns.some((column) => column.id === 'bundleAnalysis') ) { return [ ...baseColumns, @@ -129,7 +124,7 @@ export default function PullsTableTeam() { } return baseColumns - }, [bundleAnalysisPrAndCommitPages, overview?.bundleAnalysisEnabled]) + }, [overview?.bundleAnalysisEnabled]) const table = useReactTable({ columns, diff --git a/src/pages/RepoPage/RepoPage.spec.tsx b/src/pages/RepoPage/RepoPage.spec.tsx index afb1460b78..430a80a5fe 100644 --- a/src/pages/RepoPage/RepoPage.spec.tsx +++ b/src/pages/RepoPage/RepoPage.spec.tsx @@ -8,10 +8,10 @@ import { MemoryRouter, Route, useLocation } from 'react-router-dom' import NetworkErrorBoundary from 'layouts/shared/NetworkErrorBoundary' import { TierNames } from 'services/tier' -import { useFlags } from 'shared/featureFlags' import { RepoBreadcrumbProvider } from './context' import RepoPage from './RepoPage' +import { useFlags } from 'shared/featureFlags' jest.mock('./BundlesTab', () => () => 'BundlesTab') jest.mock('./CommitsTab', () => () => 'CommitsTab') @@ -24,7 +24,6 @@ jest.mock('shared/featureFlags') jest.mock('shared/featureFlags') const mockedUseFlags = useFlags as jest.Mock<{ - bundleAnalysisPrAndCommitPages: boolean componentTab: boolean }> @@ -179,7 +178,6 @@ describe('RepoPage', () => { } ) { mockedUseFlags.mockReturnValue({ - bundleAnalysisPrAndCommitPages: true, componentTab: true, }) diff --git a/src/pages/RepoPage/RepoPage.tsx b/src/pages/RepoPage/RepoPage.tsx index 302c04fb66..f1a2bae0cf 100644 --- a/src/pages/RepoPage/RepoPage.tsx +++ b/src/pages/RepoPage/RepoPage.tsx @@ -52,9 +52,8 @@ function Routes({ bundleAnalysisEnabled, jsOrTsPresent, }: RoutesProps) { - const { bundleAnalysisPrAndCommitPages, componentTab } = useFlags({ + const { componentTab } = useFlags({ bundleAnalysisPrAndCommitPages: false, - componentTab: false, }) // repo is currently active and activated @@ -87,7 +86,7 @@ function Routes({ )} - {bundleAnalysisEnabled && bundleAnalysisPrAndCommitPages ? ( + {bundleAnalysisEnabled ? ( - ) : jsOrTsPresent && bundleAnalysisPrAndCommitPages ? ( + ) : jsOrTsPresent ? ( - {jsOrTsPresent && bundleAnalysisPrAndCommitPages ? ( + {jsOrTsPresent ? ( @@ -137,7 +136,6 @@ describe('RepoPageTabs', () => { isCurrentUserPartOfOrg = true, }: SetupArgs) { mockedUseFlags.mockReturnValue({ - bundleAnalysisPrAndCommitPages: true, componentTab: true, }) @@ -463,7 +461,6 @@ describe('useRepoTabs', () => { isCurrentUserPartOfOrg = true, }: SetupArgs) { mockedUseFlags.mockReturnValue({ - bundleAnalysisPrAndCommitPages: true, componentTab: true, }) @@ -846,7 +843,6 @@ describe('useRepoTabs', () => { describe('feature flag is off', () => { it('does not add the components link to the array', async () => { mockedUseFlags.mockReturnValueOnce({ - bundleAnalysisPrAndCommitPages: true, componentTab: false, }) diff --git a/src/pages/RepoPage/RepoPageTabs.tsx b/src/pages/RepoPage/RepoPageTabs.tsx index 26108b6069..69d6f0915d 100644 --- a/src/pages/RepoPage/RepoPageTabs.tsx +++ b/src/pages/RepoPage/RepoPageTabs.tsx @@ -42,8 +42,7 @@ export const useRepoTabs = ({ refetchEnabled }: UseRepoTabsArgs) => { }, }) - const { bundleAnalysisPrAndCommitPages, componentTab } = useFlags({ - bundleAnalysisPrAndCommitPages: false, + const { componentTab } = useFlags({ componentTab: false, }) @@ -71,9 +70,8 @@ export const useRepoTabs = ({ refetchEnabled }: UseRepoTabsArgs) => { const jsOrTsPresent = repoOverview?.jsOrTsPresent if ( - ((jsOrTsPresent && isCurrentUserPartOfOrg) || - repoOverview?.bundleAnalysisEnabled) && - bundleAnalysisPrAndCommitPages + (jsOrTsPresent && isCurrentUserPartOfOrg) || + repoOverview?.bundleAnalysisEnabled ) { tabs.push({ pageName: 'bundles',