diff --git a/src/pages/CommitDetailPage/CommitDetailPage.spec.jsx b/src/pages/CommitDetailPage/CommitDetailPage.spec.jsx
index 9bcc2c7866..8d6138ddef 100644
--- a/src/pages/CommitDetailPage/CommitDetailPage.spec.jsx
+++ b/src/pages/CommitDetailPage/CommitDetailPage.spec.jsx
@@ -5,6 +5,7 @@ import { setupServer } from 'msw/node'
import { Suspense } from 'react'
import { MemoryRouter, Route } from 'react-router-dom'
+import { TierNames } from 'services/tier'
import { useTruncation } from 'ui/TruncatedMessage/hooks'
import CommitPage from './CommitDetailPage'
@@ -13,6 +14,29 @@ jest.mock('./CommitDetailPageContent', () => () => 'CommitDetailPageContent')
jest.mock('./UploadsCard', () => () => 'UploadsCard')
jest.mock('ui/TruncatedMessage/hooks')
+const mockProTier = {
+ owner: {
+ plan: {
+ tierName: TierNames.PRO,
+ },
+ },
+}
+
+const mockRepoSettings = (isPrivate) => ({
+ owner: {
+ repository: {
+ defaultBranch: 'master',
+ private: isPrivate,
+ uploadToken: 'token',
+ graphToken: 'token',
+ yaml: 'yaml',
+ bot: {
+ username: 'test',
+ },
+ },
+ },
+})
+
const mockCommit = {
owner: {
isCurrentUserPartOfOrg: true,
@@ -182,6 +206,12 @@ describe('CommitPage', () => {
}),
rest.get('/internal/gh/codecov/account-details/', (req, res, ctx) => {
return res(ctx.status(200), ctx.json({}))
+ }),
+ graphql.query('GetRepoSettingsTeam', (req, res, ctx) => {
+ return res(ctx.status(200), ctx.data(mockRepoSettings(false)))
+ }),
+ graphql.query('OwnerTier', (req, res, ctx) => {
+ return res(ctx.status(200), ctx.data(mockProTier))
})
)
diff --git a/src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTab.spec.tsx b/src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTab.spec.tsx
index c5860d6b99..a2ad90a8ac 100644
--- a/src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTab.spec.tsx
+++ b/src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTab.spec.tsx
@@ -31,6 +31,21 @@ const mockProTier = {
},
}
+const mockRepoSettings = (isPrivate: boolean) => ({
+ owner: {
+ repository: {
+ defaultBranch: 'master',
+ private: isPrivate,
+ uploadToken: 'token',
+ graphToken: 'token',
+ yaml: 'yaml',
+ bot: {
+ username: 'test',
+ },
+ },
+ },
+})
+
const server = setupServer()
const queryClient = new QueryClient()
@@ -58,10 +73,11 @@ afterAll(() => {
interface SetupArgs {
planValue: 'team' | 'pro'
flagValue: boolean
+ isPrivate?: boolean
}
describe('FilesChangedTab', () => {
- function setup({ planValue, flagValue }: SetupArgs) {
+ function setup({ planValue, flagValue, isPrivate = false }: SetupArgs) {
mockedUseFlags.mockReturnValue({
multipleTiers: flagValue,
})
@@ -73,13 +89,16 @@ describe('FilesChangedTab', () => {
}
return res(ctx.status(200), ctx.data(mockProTier))
+ }),
+ graphql.query('GetRepoSettingsTeam', (req, res, ctx) => {
+ return res(ctx.status(200), ctx.data(mockRepoSettings(isPrivate)))
})
)
}
describe('user has pro tier', () => {
it('renders files changed table', async () => {
- setup({ planValue: 'pro', flagValue: false })
+ setup({ planValue: TierNames.PRO, flagValue: false })
render(, { wrapper })
const table = await screen.findByText('FilesChangedTable')
@@ -88,13 +107,25 @@ describe('FilesChangedTab', () => {
})
describe('user has team tier', () => {
- it('renders team files changed table', async () => {
- setup({ planValue: 'team', flagValue: true })
+ describe('repo is private', () => {
+ it('renders team files changed table', async () => {
+ setup({ planValue: TierNames.TEAM, flagValue: true, isPrivate: true })
- render(, { wrapper })
+ render(, { wrapper })
- const table = await screen.findByText('FilesChangedTableTeam')
- expect(table).toBeInTheDocument()
+ const table = await screen.findByText('FilesChangedTableTeam')
+ expect(table).toBeInTheDocument()
+ })
+ })
+
+ describe('repo is public', () => {
+ it('renders files changed table', async () => {
+ setup({ planValue: TierNames.TEAM, flagValue: false, isPrivate: false })
+ render(, { wrapper })
+
+ const table = await screen.findByText('FilesChangedTable')
+ expect(table).toBeInTheDocument()
+ })
})
})
})
diff --git a/src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTab.tsx b/src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTab.tsx
index 32ad90658e..419fd044cc 100644
--- a/src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTab.tsx
+++ b/src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTab.tsx
@@ -1,7 +1,8 @@
import { lazy, Suspense } from 'react'
import { useParams } from 'react-router-dom'
-import { useTier } from 'services/tier'
+import { useRepoSettingsTeam } from 'services/repo'
+import { TierNames, useTier } from 'services/tier'
import { useFlags } from 'shared/featureFlags'
import Spinner from 'ui/Spinner'
@@ -21,6 +22,7 @@ interface URLParams {
function FilesChanged() {
const { provider, owner } = useParams()
+ const { data: repoSettings } = useRepoSettingsTeam()
const { multipleTiers } = useFlags({
multipleTiers: false,
@@ -28,7 +30,11 @@ function FilesChanged() {
const { data: tierData } = useTier({ provider, owner })
- if (tierData === 'team' && multipleTiers) {
+ if (
+ tierData === TierNames.TEAM &&
+ !!repoSettings?.repository.private &&
+ multipleTiers
+ ) {
return (
}>