diff --git a/src/pages/RepoPage/BundlesTab/BundleOnboarding/BundleOnboarding.spec.tsx b/src/pages/RepoPage/BundlesTab/BundleOnboarding/BundleOnboarding.spec.tsx index 37072914b6..8497d17f7c 100644 --- a/src/pages/RepoPage/BundlesTab/BundleOnboarding/BundleOnboarding.spec.tsx +++ b/src/pages/RepoPage/BundlesTab/BundleOnboarding/BundleOnboarding.spec.tsx @@ -32,6 +32,7 @@ const mockGetRepo = (hasUploadToken: boolean, isActive: boolean) => ({ activated: false, oldestCommitAt: '', active: isActive, + isFirstPullRequest: false, }, }, }) diff --git a/src/pages/RepoPage/BundlesTab/BundleOnboarding/RollupOnboarding/RollupOnboarding.spec.tsx b/src/pages/RepoPage/BundlesTab/BundleOnboarding/RollupOnboarding/RollupOnboarding.spec.tsx index 6eaf0d232c..95c2c340a8 100644 --- a/src/pages/RepoPage/BundlesTab/BundleOnboarding/RollupOnboarding/RollupOnboarding.spec.tsx +++ b/src/pages/RepoPage/BundlesTab/BundleOnboarding/RollupOnboarding/RollupOnboarding.spec.tsx @@ -23,6 +23,7 @@ const mockGetRepo = { activated: false, oldestCommitAt: '', active: true, + isFirstPullRequest: false, }, }, } diff --git a/src/pages/RepoPage/BundlesTab/BundleOnboarding/ViteOnboarding/ViteOnboarding.spec.tsx b/src/pages/RepoPage/BundlesTab/BundleOnboarding/ViteOnboarding/ViteOnboarding.spec.tsx index 73cfebd52e..3139d5debb 100644 --- a/src/pages/RepoPage/BundlesTab/BundleOnboarding/ViteOnboarding/ViteOnboarding.spec.tsx +++ b/src/pages/RepoPage/BundlesTab/BundleOnboarding/ViteOnboarding/ViteOnboarding.spec.tsx @@ -23,6 +23,7 @@ const mockGetRepo = { activated: false, oldestCommitAt: '', active: true, + isFirstPullRequest: false, }, }, } diff --git a/src/pages/RepoPage/BundlesTab/BundleOnboarding/WebpackOnboarding/WebpackOnboarding.spec.tsx b/src/pages/RepoPage/BundlesTab/BundleOnboarding/WebpackOnboarding/WebpackOnboarding.spec.tsx index 2466c6a9aa..d345566e05 100644 --- a/src/pages/RepoPage/BundlesTab/BundleOnboarding/WebpackOnboarding/WebpackOnboarding.spec.tsx +++ b/src/pages/RepoPage/BundlesTab/BundleOnboarding/WebpackOnboarding/WebpackOnboarding.spec.tsx @@ -23,6 +23,7 @@ const mockGetRepo = { activated: false, oldestCommitAt: '', active: true, + isFirstPullRequest: false, }, }, } diff --git a/src/pages/RepoPage/ComponentsTab/subroute/ComponentsTable/ComponentsTable.spec.tsx b/src/pages/RepoPage/ComponentsTab/subroute/ComponentsTable/ComponentsTable.spec.tsx index 14badc3fcb..8d96e2dd24 100644 --- a/src/pages/RepoPage/ComponentsTab/subroute/ComponentsTable/ComponentsTable.spec.tsx +++ b/src/pages/RepoPage/ComponentsTab/subroute/ComponentsTable/ComponentsTable.spec.tsx @@ -34,6 +34,7 @@ const mockGetRepo = { activated: true, oldestCommitAt: '2020-01-01T12:00:00', active: true, + isFirstPullRequest: false, }, }, } diff --git a/src/pages/RepoPage/ComponentsTab/subroute/ComponentsTable/hooks/useRepoComponentsTable.spec.tsx b/src/pages/RepoPage/ComponentsTab/subroute/ComponentsTable/hooks/useRepoComponentsTable.spec.tsx index b2bc8879eb..36b06c9f5b 100644 --- a/src/pages/RepoPage/ComponentsTab/subroute/ComponentsTable/hooks/useRepoComponentsTable.spec.tsx +++ b/src/pages/RepoPage/ComponentsTab/subroute/ComponentsTable/hooks/useRepoComponentsTable.spec.tsx @@ -71,6 +71,7 @@ const mockGetRepo = ({ activated: isRepoActivated, oldestCommitAt: '2022-10-10T11:59:59', active: isRepoActive, + isFirstPullRequest: false, }, }, }) diff --git a/src/pages/RepoPage/CoverageOnboarding/CircleCI/CircleCI.spec.tsx b/src/pages/RepoPage/CoverageOnboarding/CircleCI/CircleCI.spec.tsx index c304d580a3..3a8152994c 100644 --- a/src/pages/RepoPage/CoverageOnboarding/CircleCI/CircleCI.spec.tsx +++ b/src/pages/RepoPage/CoverageOnboarding/CircleCI/CircleCI.spec.tsx @@ -28,6 +28,7 @@ const mockGetRepo = { activated: false, oldestCommitAt: '', active: true, + isFirstPullRequest: false, }, }, } diff --git a/src/pages/RepoPage/CoverageOnboarding/GitHubActions/GitHubActions.spec.tsx b/src/pages/RepoPage/CoverageOnboarding/GitHubActions/GitHubActions.spec.tsx index 6480a4d9c6..0b5cbae796 100644 --- a/src/pages/RepoPage/CoverageOnboarding/GitHubActions/GitHubActions.spec.tsx +++ b/src/pages/RepoPage/CoverageOnboarding/GitHubActions/GitHubActions.spec.tsx @@ -28,6 +28,7 @@ const mockGetRepo = { activated: false, oldestCommitAt: '', active: true, + isFirstPullRequest: false, }, }, } diff --git a/src/pages/RepoPage/CoverageOnboarding/NewRepoTab.spec.tsx b/src/pages/RepoPage/CoverageOnboarding/NewRepoTab.spec.tsx index bbb637d14b..4a16c1bb80 100644 --- a/src/pages/RepoPage/CoverageOnboarding/NewRepoTab.spec.tsx +++ b/src/pages/RepoPage/CoverageOnboarding/NewRepoTab.spec.tsx @@ -46,6 +46,7 @@ const mockGetRepo = ( activated: false, oldestCommitAt: '', active: hasCommits, + isFirstPullRequest: false, }, }, }) diff --git a/src/pages/RepoPage/CoverageOnboarding/OtherCI/OtherCI.spec.tsx b/src/pages/RepoPage/CoverageOnboarding/OtherCI/OtherCI.spec.tsx index 4f686e0f12..d9ecb9ad9a 100644 --- a/src/pages/RepoPage/CoverageOnboarding/OtherCI/OtherCI.spec.tsx +++ b/src/pages/RepoPage/CoverageOnboarding/OtherCI/OtherCI.spec.tsx @@ -28,6 +28,7 @@ const mockGetRepo = { activated: false, oldestCommitAt: '', active: true, + isFirstPullRequest: false, }, }, } diff --git a/src/pages/RepoPage/CoverageTab/CoverageTab.jsx b/src/pages/RepoPage/CoverageTab/CoverageTab.jsx index 7bcf33e5a9..5fc276bf1f 100644 --- a/src/pages/RepoPage/CoverageTab/CoverageTab.jsx +++ b/src/pages/RepoPage/CoverageTab/CoverageTab.jsx @@ -4,11 +4,12 @@ import { Switch, useParams } from 'react-router-dom' import { SentryRoute } from 'sentry' import SilentNetworkErrorWrapper from 'layouts/shared/SilentNetworkErrorWrapper' -import { useRepoSettingsTeam } from 'services/repo' +import { useRepo } from 'services/repo' import { TierNames, useTier } from 'services/tier' import { useFlags } from 'shared/featureFlags' import Spinner from 'ui/Spinner' +import FirstPullRequestBanner from './FirstPullRequestBanner' import Summary from './Summary' import SummaryTeamPlan from './SummaryTeamPlan' import ToggleElement from './ToggleElement' @@ -25,11 +26,16 @@ const Loader = () => ( ) function CoverageTab() { - const { data: repoData } = useRepoSettingsTeam() + const { provider, owner, repo } = useParams() + const { data: repoData } = useRepo({ + provider, + owner, + repo, + }) + const { multipleTiers } = useFlags({ multipleTiers: false, }) - const { provider, owner } = useParams() const { data: tierName } = useTier({ provider, owner }) const showTeamSummary = @@ -39,6 +45,9 @@ function CoverageTab() { return (
+ {repoData?.repository?.isFirstPullRequest ? ( + + ) : null} {showTeamSummary ? : } {!showTeamSummary && ( ({ - owner: { - repository: { - __typename: 'Repository', - activated: true, - defaultBranch: 'master', - private: isPrivate, - uploadToken: 'token', - graphToken: 'token', - yaml: 'yaml', - bot: { - username: 'test', - }, - }, - }, -}) - const wrapper = (initialEntries = ['/gh/codecov/cool-repo/tree/main']) => ({ children }) => @@ -53,13 +36,24 @@ const wrapper = ) -const mockRepo = { +const mockRepo = (isPrivate = false, isFirstPullRequest = false) => ({ owner: { + isCurrentUserPartOfOrg: true, + isAdmin: null, + isCurrentUserActivated: null, repository: { + __typename: 'Repository', + private: isPrivate, + uploadToken: '9e6a6189-20f1-482d-ab62-ecfaa2629295', defaultBranch: 'main', + yaml: '', + activated: false, + oldestCommitAt: '', + active: true, + isFirstPullRequest, }, }, -} +}) const repoConfigMock = { owner: { @@ -208,10 +202,14 @@ afterAll(() => { describe('Coverage Tab', () => { function setup( - { repoData = mockRepo, isPrivate = false, tierValue = TierNames.PRO } = { - repoData: mockRepo, + { + isPrivate = false, + tierValue = TierNames.PRO, + isFirstPullRequest = false, + } = { isPrivate: false, tierValue: TierNames.PRO, + isFirstPullRequest: false, } ) { useFlags.mockReturnValue({ @@ -220,7 +218,7 @@ describe('Coverage Tab', () => { server.use( graphql.query('GetRepo', (req, res, ctx) => - res(ctx.status(200), ctx.data(repoData)) + res(ctx.status(200), ctx.data(mockRepo(isPrivate, isFirstPullRequest))) ), graphql.query('GetBranches', (req, res, ctx) => res(ctx.status(200), ctx.data(branchesMock)) @@ -268,10 +266,7 @@ describe('Coverage Tab', () => { (req, res, ctx) => { return res(ctx.status(200), ctx.json({ data: {} })) } - ), - graphql.query('GetRepoSettingsTeam', (req, res, ctx) => { - return res(ctx.status(200), ctx.data(mockRepoSettings(isPrivate))) - }) + ) ) } @@ -328,4 +323,15 @@ describe('Coverage Tab', () => { expect(coverageChart).not.toBeInTheDocument() }) }) + + it('renders first pull request banner', async () => { + setup({ isFirstPullRequest: true }) + + render(, { wrapper: wrapper(['/gh/test-org/repoName']) }) + + const firstPullRequestBanner = await screen.findByText( + /Once merged to your default branch, Codecov will show your report results on this dashboard./ + ) + expect(firstPullRequestBanner).toBeInTheDocument() + }) }) diff --git a/src/pages/RepoPage/CoverageTab/FirstPullRequestBanner/FirstPullRequestBanner.spec.tsx b/src/pages/RepoPage/CoverageTab/FirstPullRequestBanner/FirstPullRequestBanner.spec.tsx new file mode 100644 index 0000000000..3555cc6eea --- /dev/null +++ b/src/pages/RepoPage/CoverageTab/FirstPullRequestBanner/FirstPullRequestBanner.spec.tsx @@ -0,0 +1,26 @@ +import { render, screen } from '@testing-library/react' +import { MemoryRouter, Route } from 'react-router-dom' + +import FirstPullRequestBanner from './FirstPullRequestBanner' + +const wrapper: React.FC = ({ children }) => ( + + {children} + +) + +describe('FirstPullRequestBanner', () => { + it('renders content', () => { + render(, { wrapper }) + const content = screen.getByText( + 'Once merged to your default branch, Codecov will show your report results on this dashboard.' + ) + expect(content).toBeInTheDocument() + }) + + it('renders the correct link', () => { + render(, { wrapper }) + const link = screen.getByRole('link', { name: 'edit default branch' }) + expect(link).toHaveAttribute('href', '/gh/codecov/gazebo/settings') + }) +}) diff --git a/src/pages/RepoPage/CoverageTab/FirstPullRequestBanner/FirstPullRequestBanner.tsx b/src/pages/RepoPage/CoverageTab/FirstPullRequestBanner/FirstPullRequestBanner.tsx new file mode 100644 index 0000000000..14a9861453 --- /dev/null +++ b/src/pages/RepoPage/CoverageTab/FirstPullRequestBanner/FirstPullRequestBanner.tsx @@ -0,0 +1,27 @@ +import A from 'ui/A' +import Banner from 'ui/Banner' +import BannerContent from 'ui/Banner/BannerContent' + +const FirstPullRequestBanner = () => { + return ( + + +

+ Once merged to your default branch, Codecov will show your report + results on this dashboard.{' '} + + edit default branch + +

+
+
+ ) +} + +export default FirstPullRequestBanner diff --git a/src/pages/RepoPage/CoverageTab/FirstPullRequestBanner/index.ts b/src/pages/RepoPage/CoverageTab/FirstPullRequestBanner/index.ts new file mode 100644 index 0000000000..b373c968bb --- /dev/null +++ b/src/pages/RepoPage/CoverageTab/FirstPullRequestBanner/index.ts @@ -0,0 +1 @@ +export { default } from './FirstPullRequestBanner' diff --git a/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/CodeTreeTable/CodeTreeTable.spec.tsx b/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/CodeTreeTable/CodeTreeTable.spec.tsx index 9738e63cfa..86288fc067 100644 --- a/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/CodeTreeTable/CodeTreeTable.spec.tsx +++ b/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/CodeTreeTable/CodeTreeTable.spec.tsx @@ -356,22 +356,6 @@ describe('CodeTreeTable', () => { }) }) - describe('there is no results found', () => { - it('displays error fetching data message', async () => { - setup({ noFiles: true }) - render(, { wrapper: wrapper() }) - - const message = await screen.findByText( - 'Once merged to your default branch, Codecov will show your report results on this dashboard.' - ) - expect(message).toBeInTheDocument() - - const link = await screen.findByTestId('settings-page') - expect(link).toBeInTheDocument() - expect(link).toHaveAttribute('href', '/gh/codecov/cool-repo/settings') - }) - }) - describe('when head commit has no reports', () => { it('renders no report uploaded message', async () => { setup({ noHeadReport: true }) diff --git a/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/FileListTable/FileListTable.spec.tsx b/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/FileListTable/FileListTable.spec.tsx index 4bcc89efda..07424b2fda 100644 --- a/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/FileListTable/FileListTable.spec.tsx +++ b/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/FileListTable/FileListTable.spec.tsx @@ -290,24 +290,6 @@ describe('FileListTable', () => { }) }) - describe('there is no results found', () => { - it('displays error fetching data message', async () => { - setup({ noFiles: true }) - render(, { - wrapper: wrapper('/gh/codecov/cool-repo/tree/main/'), - }) - - const message = await screen.findByText( - 'Once merged to your default branch, Codecov will show your report results on this dashboard.' - ) - expect(message).toBeInTheDocument() - - const link = await screen.findByTestId('settings-page') - expect(link).toBeInTheDocument() - expect(link).toHaveAttribute('href', '/gh/codecov/cool-repo/settings') - }) - }) - describe('when head commit has no reports', () => { it('renders no report uploaded message', async () => { setup({ noHeadReport: true }) diff --git a/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/shared/RepoContentsResult.tsx b/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/shared/RepoContentsResult.tsx index 0b68d90220..9153c9a43b 100644 --- a/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/shared/RepoContentsResult.tsx +++ b/src/pages/RepoPage/CoverageTab/subroute/FileExplorer/shared/RepoContentsResult.tsx @@ -37,8 +37,8 @@ const RepoContentsResult: React.FC = ({ head commit ` } else { - copy = ( -

+ return ( +

Once merged to your default branch, Codecov will show your report results on this dashboard.{' '} { activated: false, oldestCommitAt: '', active: false, + isFirstPullRequest: false, }, }, }) diff --git a/src/pages/RepoPage/FlagsTab/subroute/FlagsTable/FlagsTable.spec.tsx b/src/pages/RepoPage/FlagsTab/subroute/FlagsTable/FlagsTable.spec.tsx index 263f4d4949..0dca4d20d4 100644 --- a/src/pages/RepoPage/FlagsTab/subroute/FlagsTable/FlagsTable.spec.tsx +++ b/src/pages/RepoPage/FlagsTab/subroute/FlagsTable/FlagsTable.spec.tsx @@ -41,6 +41,7 @@ const mockGetRepo = ({ isAdmin = true }) => ({ activated: true, oldestCommitAt: '2020-01-01T12:00:00', active: true, + isFirstPullRequest: false, }, }, }) diff --git a/src/pages/RepoPage/RepoPage.spec.tsx b/src/pages/RepoPage/RepoPage.spec.tsx index 650e6d69f4..f73e0f2f8d 100644 --- a/src/pages/RepoPage/RepoPage.spec.tsx +++ b/src/pages/RepoPage/RepoPage.spec.tsx @@ -52,6 +52,7 @@ const mockGetRepo = ({ activated: isRepoActivated, oldestCommitAt: '', active: isRepoActive, + isFirstPullRequest: false, }, }, }) diff --git a/src/pages/RepoPage/RepoPageTabs.spec.tsx b/src/pages/RepoPage/RepoPageTabs.spec.tsx index 64798153ad..4d36897566 100644 --- a/src/pages/RepoPage/RepoPageTabs.spec.tsx +++ b/src/pages/RepoPage/RepoPageTabs.spec.tsx @@ -61,6 +61,7 @@ const mockRepo = ({ isCurrentUserPartOfOrg = true }) => ({ activated: true, oldestCommitAt: '2022-10-10T11:59:59', active: true, + isFirstPullRequest: false, }, }, }) @@ -839,7 +840,7 @@ describe('useRepoTabs', () => { ) }) }) - + describe('repo is private and tier is team', () => { it('does not add the components link to the array', async () => { setup({ isRepoPrivate: true, tierName: TierNames.TEAM }) @@ -865,7 +866,7 @@ describe('useRepoTabs', () => { ) }) }) - + describe('feature flag is off', () => { it('does not add the components link to the array', async () => { mockedUseFlags.mockReturnValueOnce({ @@ -896,7 +897,6 @@ describe('useRepoTabs', () => { }) }) }) - describe('commits and pulls tab', () => { describe('bundle analysis is enabled', () => { diff --git a/src/pages/RepoPage/context.spec.js b/src/pages/RepoPage/context.spec.js index 33521d0489..28e4505234 100644 --- a/src/pages/RepoPage/context.spec.js +++ b/src/pages/RepoPage/context.spec.js @@ -76,6 +76,7 @@ describe('Repo breadcrumb context', () => { owner: { repository: { private: false, + isFirstPullRequest: false, }, }, }) diff --git a/src/services/repo/hooks.spec.tsx b/src/services/repo/hooks.spec.tsx index 2e9ad04595..8cf8bca6ef 100644 --- a/src/services/repo/hooks.spec.tsx +++ b/src/services/repo/hooks.spec.tsx @@ -99,6 +99,7 @@ describe('useRepo', () => { active: true, activated: true, oldestCommitAt: '', + isFirstPullRequest: false, }, }, } @@ -129,6 +130,7 @@ describe('useRepo', () => { active: true, activated: true, oldestCommitAt: '', + isFirstPullRequest: false, }, } diff --git a/src/services/repo/useRepo.spec.tsx b/src/services/repo/useRepo.spec.tsx index aa98f16d05..edeed1d90b 100644 --- a/src/services/repo/useRepo.spec.tsx +++ b/src/services/repo/useRepo.spec.tsx @@ -20,6 +20,7 @@ const mockRepo = { activated: false, oldestCommitAt: '', active: true, + isFirstPullRequest: false, }, }, } @@ -124,6 +125,7 @@ describe('useRepo', () => { activated: false, oldestCommitAt: '', active: true, + isFirstPullRequest: false, }, }) ) diff --git a/src/services/repo/useRepo.tsx b/src/services/repo/useRepo.tsx index 92ca2d978a..73992fa936 100644 --- a/src/services/repo/useRepo.tsx +++ b/src/services/repo/useRepo.tsx @@ -18,6 +18,7 @@ const RepositorySchema = z.object({ activated: z.boolean(), oldestCommitAt: z.string().nullable(), active: z.boolean(), + isFirstPullRequest: z.boolean(), }) export const RepoSchema = z.object({ @@ -53,6 +54,7 @@ const query = ` activated oldestCommitAt active + isFirstPullRequest } ... on NotFoundError { message