diff --git a/src/pages/PullRequestPage/FirstPullBanner/FirstPullBanner.spec.tsx b/src/pages/PullRequestPage/FirstPullBanner/FirstPullBanner.spec.tsx index a47449b2af..d1c223e431 100644 --- a/src/pages/PullRequestPage/FirstPullBanner/FirstPullBanner.spec.tsx +++ b/src/pages/PullRequestPage/FirstPullBanner/FirstPullBanner.spec.tsx @@ -41,6 +41,7 @@ const mockPullData = ({ resultType }: SetupArgs) => { owner: { repository: { __typename: 'Repository', + private: false, pull: { pullId: 1, head: { @@ -60,6 +61,7 @@ const mockPullData = ({ resultType }: SetupArgs) => { owner: { repository: { __typename: 'Repository', + private: false, pull: { pullId: 1, head: { diff --git a/src/pages/PullRequestPage/PullRequestPage.spec.jsx b/src/pages/PullRequestPage/PullRequestPage.spec.jsx index dc9e8bb1db..5d672bd5f3 100644 --- a/src/pages/PullRequestPage/PullRequestPage.spec.jsx +++ b/src/pages/PullRequestPage/PullRequestPage.spec.jsx @@ -19,6 +19,7 @@ const mockPullHeadData = { owner: { repository: { __typename: 'Repository', + private: false, pull: { pullId: 12, title: 'Cool New Pull Request', @@ -91,6 +92,7 @@ describe('PullRequestPage', () => { owner: { repository: { __typename: 'Repository', + private: false, pull: pullData, }, }, diff --git a/src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx b/src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx index d7dba39e6a..f04c761ef0 100644 --- a/src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx +++ b/src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx @@ -5,6 +5,7 @@ import { pullFileviewString, pullTreeviewString, } from 'pages/PullRequestPage/utils' +import { TierNames, useTier } from 'services/tier' import { useFlags } from 'shared/featureFlags' import ToggleHeader from 'ui/FileViewer/ToggleHeader' import TabNavigation from 'ui/TabNavigation' @@ -18,13 +19,16 @@ function PullRequestPageTabs() { indirectChangesCount, directChangedFilesCount, commitsCount, + isPrivateRepo, } = useTabsCounts() - const { pullRequestPageFlagMultiSelect } = useFlags({ + const { pullRequestPageFlagMultiSelect, multipleTiers } = useFlags({ pullRequestPageFlagMultiSelect: false, + multipleTiers: false, }) const { pathname, search } = useLocation() const { provider, owner, repo, pullId } = useParams() + const { data: tierData, isLoading } = useTier({ provider, owner }) const searchParams = qs.parse(search, { ignoreQueryPrefix: true }) const flags = searchParams?.flags ?? [] @@ -43,6 +47,53 @@ function PullRequestPageTabs() { } } + if (isLoading) { + return null + } + + if (multipleTiers && tierData === TierNames.TEAM && isPrivateRepo) { + return ( + + Files changed + {directChangedFilesCount} + + ), + options: { queryParams: { flags } }, + exact: true, + }, + { + pageName: 'pullCommits', + children: ( + <> + Commits + {commitsCount} + + ), + options: { queryParams: { flags } }, + }, + { + pageName: 'pullTreeView', + children: 'File explorer', + options: { pullId, queryParams: { flags } }, + location: customLocation, + }, + ]} + component={ + + } + /> + ) + } + return ( } /> diff --git a/src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.spec.jsx b/src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.spec.jsx index 6412700a29..e050ee4b8d 100644 --- a/src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.spec.jsx +++ b/src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.spec.jsx @@ -4,6 +4,7 @@ import { graphql } from 'msw' import { setupServer } from 'msw/node' import { MemoryRouter, Route } from 'react-router-dom' +import { TierNames } from 'services/tier' import { useFlags } from 'shared/featureFlags' import PullRequestPageTabs from './PullRequestPageTabs' @@ -21,6 +22,30 @@ const mockCommits = { } const mockPullData = { + owner: { + isCurrentUserPartOfOrg: true, + repository: { + __typename: 'Repository', + private: false, + pull: { + pullId: 1, + head: { + commitid: '123', + }, + compareWithBase: { + __typename: 'Comparison', + directChangedFilesCount: 4, + flagComparisonsCount: 3, + indirectChangedFilesCount: 5, + impactedFilesCount: 0, + componentComparisonsCount: 0, + }, + }, + }, + }, +} + +const mockPullDataPrivate = { owner: { isCurrentUserPartOfOrg: true, repository: { @@ -82,22 +107,40 @@ afterAll(() => { describe('PullRequestPageTabs', () => { function setup( - { pullRequestPageFlagMultiSelect = false } = { + { + pullRequestPageFlagMultiSelect = false, + multipleTiers = false, + plan = TierNames.BASIC, + privateRepo = false, + } = { pullRequestPageFlagMultiSelect: false, + multipleTiers: false, + plan: TierNames.BASIC, + privateRepo: false, } ) { useFlags.mockReturnValue({ pullRequestPageFlagMultiSelect, + multipleTiers, }) server.use( - graphql.query('PullPageData', (req, res, ctx) => - res(ctx.status(200), ctx.data(mockPullData)) - ), + graphql.query('PullPageData', (req, res, ctx) => { + if (privateRepo) { + return res(ctx.status(200), ctx.data(mockPullDataPrivate)) + } + return res(ctx.status(200), ctx.data(mockPullData)) + }), graphql.query('GetCommits', (req, res, ctx) => res(ctx.status(200), ctx.data(mockCommits)) ), graphql.query('BackfillFlagMemberships', (req, res, ctx) => res(ctx.status(200), ctx.data({})) + ), + graphql.query('OwnerTier', (req, res, ctx) => + res( + ctx.status(200), + ctx.data({ owner: { plan: { tierName: plan.toLowerCase() } } }) + ) ) ) } @@ -300,16 +343,654 @@ describe('PullRequestPageTabs', () => { }) }) - // describe('flags select dropdown', () => { - // beforeEach(() => setup({ pullRequestPageFlagMultiSelect: true })) + describe('Team plan', () => { + describe('with pullRequestPageFlagMultiSelect flag', () => { + describe('with multiple tiers flag', () => { + describe('is a team plan on a public repo', () => { + beforeEach(() => + setup({ + plan: TierNames.TEAM, + multipleTiers: true, + privateRepo: false, + pullRequestPageFlagMultiSelect: true, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = await screen.findByText('Search for Flags') + expect(flagSelect).toBeInTheDocument() + }) + }) + + describe('is a team plan on a private repo', () => { + beforeEach(() => + setup({ + plan: TierNames.TEAM, + multipleTiers: true, + privateRepo: true, + pullRequestPageFlagMultiSelect: true, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = screen.queryByText('Indirect changes') + expect(indirect).not.toBeInTheDocument() + + const flags = screen.queryByText('Flags') + expect(flags).not.toBeInTheDocument() + + const componentsTab = screen.queryByText('Components') + expect(componentsTab).not.toBeInTheDocument() + }) + + it('does not render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + + describe('is a pro plan on a public repo', () => { + beforeEach(() => + setup({ + plan: TierNames.PRO, + multipleTiers: true, + privateRepo: false, + pullRequestPageFlagMultiSelect: true, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = await screen.findByText('Search for Flags') + expect(flagSelect).toBeInTheDocument() + }) + }) + + describe('is a pro plan on a private repo', () => { + beforeEach(() => + setup({ + plan: TierNames.PRO, + multipleTiers: true, + privateRepo: true, + pullRequestPageFlagMultiSelect: true, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does not render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + }) + describe('with out multiple tiers flag', () => { + describe('is a team plan on a public repo', () => { + beforeEach(() => + setup({ + plan: TierNames.TEAM, + multipleTiers: false, + privateRepo: false, + pullRequestPageFlagMultiSelect: true, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = await screen.findByText('Search for Flags') + expect(flagSelect).toBeInTheDocument() + }) + }) + + describe('is a team plan on a private repo', () => { + beforeEach(() => + setup({ + plan: TierNames.TEAM, + multipleTiers: false, + privateRepo: true, + pullRequestPageFlagMultiSelect: true, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does not render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + + describe('is a pro plan on a public repo', () => { + beforeEach(() => + setup({ + plan: TierNames.PRO, + multipleTiers: false, + privateRepo: false, + pullRequestPageFlagMultiSelect: true, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = await screen.findByText('Search for Flags') + expect(flagSelect).toBeInTheDocument() + }) + }) + + describe('is a pro plan on a private repo', () => { + beforeEach(() => + setup({ + plan: TierNames.PRO, + multipleTiers: false, + privateRepo: true, + pullRequestPageFlagMultiSelect: true, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does not render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + }) + }) + }) + describe('with out pullRequestPageFlagMultiSelect flag', () => { + describe('with multiple tiers flag', () => { + describe('is a team plan on a public repo', () => { + beforeEach(() => + setup({ + plan: TierNames.TEAM, + multipleTiers: true, + privateRepo: false, + pullRequestPageFlagMultiSelect: false, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() - // it('renders flags select dropdown', async () => { - // render(, { wrapper: wrapper() }) + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() - // const multiSelect = await screen.findByRole('button', { - // name: 'All Flags', - // }) - // expect(multiSelect).toBeInTheDocument() - // }) - // }) + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + + describe('is a team plan on a private repo', () => { + beforeEach(() => + setup({ + plan: TierNames.TEAM, + multipleTiers: true, + privateRepo: true, + pullRequestPageFlagMultiSelect: false, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = screen.queryByText('Indirect changes') + expect(indirect).not.toBeInTheDocument() + + const flags = screen.queryByText('Flags') + expect(flags).not.toBeInTheDocument() + + const componentsTab = screen.queryByText('Components') + expect(componentsTab).not.toBeInTheDocument() + }) + + it('does not render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + + describe('is a pro plan on a public repo', () => { + beforeEach(() => + setup({ + plan: TierNames.PRO, + multipleTiers: true, + privateRepo: false, + pullRequestPageFlagMultiSelect: false, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + + describe('is a pro plan on a private repo', () => { + beforeEach(() => + setup({ + plan: TierNames.PRO, + multipleTiers: true, + privateRepo: true, + pullRequestPageFlagMultiSelect: false, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does not render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + }) + describe('with out multiple tiers flag', () => { + describe('is a team plan on a public repo', () => { + beforeEach(() => + setup({ + plan: TierNames.TEAM, + multipleTiers: false, + privateRepo: false, + pullRequestPageFlagMultiSelect: false, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + + describe('is a team plan on a private repo', () => { + beforeEach(() => + setup({ + plan: TierNames.TEAM, + multipleTiers: true, + privateRepo: true, + pullRequestPageFlagMultiSelect: false, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = screen.queryByText('Indirect changes') + expect(indirect).not.toBeInTheDocument() + + const flags = screen.queryByText('Flags') + expect(flags).not.toBeInTheDocument() + + const componentsTab = screen.queryByText('Components') + expect(componentsTab).not.toBeInTheDocument() + }) + + it('does not render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + + describe('is a pro plan on a public repo', () => { + beforeEach(() => + setup({ + plan: TierNames.PRO, + multipleTiers: false, + privateRepo: false, + pullRequestPageFlagMultiSelect: false, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + + describe('is a pro plan on a private repo', () => { + beforeEach(() => + setup({ + plan: TierNames.PRO, + multipleTiers: true, + privateRepo: true, + pullRequestPageFlagMultiSelect: false, + }) + ) + + it('renders correct tabs', async () => { + render(, { wrapper: wrapper() }) + + const components = await screen.findByText('Files changed') + expect(components).toBeInTheDocument() + + const commits = await screen.findByText('Commits') + expect(commits).toBeInTheDocument() + + const explorer = await screen.findByText('File explorer') + expect(explorer).toBeInTheDocument() + + const indirect = await screen.findByText('Indirect changes') + expect(indirect).toBeInTheDocument() + + const flags = await screen.findByText('Flags') + expect(flags).toBeInTheDocument() + + const componentsTab = await screen.findByText('Components') + expect(componentsTab).toBeInTheDocument() + }) + + it('does not render the flag select', async () => { + render(, { wrapper: wrapper() }) + + const flagSelect = screen.queryByText('Search for Flags') + expect(flagSelect).not.toBeInTheDocument() + }) + }) + }) + }) }) diff --git a/src/pages/PullRequestPage/PullRequestPageTabs/hooks/useTabsCounts.js b/src/pages/PullRequestPage/PullRequestPageTabs/hooks/useTabsCounts.js index 0f246054e4..bbcd6d6f2f 100644 --- a/src/pages/PullRequestPage/PullRequestPageTabs/hooks/useTabsCounts.js +++ b/src/pages/PullRequestPage/PullRequestPageTabs/hooks/useTabsCounts.js @@ -40,5 +40,6 @@ export const useTabsCounts = () => { indirectChangesCount: compareWithBase?.indirectChangedFilesCount, directChangedFilesCount: compareWithBase?.directChangedFilesCount, commitsCount: commitsData?.commitsCount, + isPrivateRepo: pullPageData.private, } } diff --git a/src/pages/PullRequestPage/PullRequestPageTabs/hooks/useTabsCounts.spec.js b/src/pages/PullRequestPage/PullRequestPageTabs/hooks/useTabsCounts.spec.js index 0a3316569d..94d58328c4 100644 --- a/src/pages/PullRequestPage/PullRequestPageTabs/hooks/useTabsCounts.spec.js +++ b/src/pages/PullRequestPage/PullRequestPageTabs/hooks/useTabsCounts.spec.js @@ -99,6 +99,7 @@ describe('useTabsCount', () => { directChangedFilesCount: 4, indirectChangesCount: 0, commitsCount: 11, + isPrivateRepo: true, }) ) }) diff --git a/src/pages/PullRequestPage/PullRequestPageTabs/index.js b/src/pages/PullRequestPage/PullRequestPageTabs/index.ts similarity index 100% rename from src/pages/PullRequestPage/PullRequestPageTabs/index.js rename to src/pages/PullRequestPage/PullRequestPageTabs/index.ts diff --git a/src/pages/PullRequestPage/hooks/usePullPageData.spec.tsx b/src/pages/PullRequestPage/hooks/usePullPageData.spec.tsx index 4a51e35f26..227707bc22 100644 --- a/src/pages/PullRequestPage/hooks/usePullPageData.spec.tsx +++ b/src/pages/PullRequestPage/hooks/usePullPageData.spec.tsx @@ -9,6 +9,7 @@ const mockPullData = { owner: { repository: { __typename: 'Repository', + private: true, pull: { pullId: 1, head: { @@ -128,6 +129,7 @@ describe('usePullPageData', () => { await waitFor(() => expect(result.current.data).toStrictEqual({ + private: true, pull: { pullId: 1, head: { @@ -169,6 +171,7 @@ describe('usePullPageData', () => { await waitFor(() => expect(result.current.data).toStrictEqual({ + private: false, pull: null, }) ) diff --git a/src/pages/PullRequestPage/hooks/usePullPageData.tsx b/src/pages/PullRequestPage/hooks/usePullPageData.tsx index 110f00c772..939a72a9ff 100644 --- a/src/pages/PullRequestPage/hooks/usePullPageData.tsx +++ b/src/pages/PullRequestPage/hooks/usePullPageData.tsx @@ -18,6 +18,7 @@ import A from 'ui/A' const RepositorySchema = z.object({ __typename: z.literal('Repository'), + private: z.boolean(), pull: z .object({ pullId: z.number().nullable(), @@ -68,6 +69,7 @@ query PullPageData($owner: String!, $repo: String!, $pullId: Int!) { repository(name: $repo) { __typename ... on Repository { + private pull(id: $pullId) { pullId head { @@ -176,6 +178,7 @@ export const usePullPageData = ({ return { pull: data?.owner?.repository?.pull ?? null, + private: data?.owner?.repository?.private ?? false, } }), })