Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove summary section of PR page for team tier customers #2345

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/pages/PullRequestPage/PullRequestPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { useParams } from 'react-router-dom'

import NotFound from 'pages/NotFound'
import { TierNames, useTier } from 'services/tier'
import Breadcrumb from 'ui/Breadcrumb'
import Spinner from 'ui/Spinner'

Expand All @@ -23,6 +24,7 @@
function PullRequestPage() {
const { owner, repo, pullId, provider } = useParams()
const { data, isLoading } = usePullPageData({ provider, owner, repo, pullId })
const { data: tierName } = useTier({ owner, provider })

Check warning on line 27 in src/pages/PullRequestPage/PullRequestPage.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/PullRequestPage/PullRequestPage.jsx#L27

Added line #L27 was not covered by tests

Check warning on line 27 in src/pages/PullRequestPage/PullRequestPage.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/PullRequestPage/PullRequestPage.jsx#L27

Added line #L27 was not covered by tests

Check warning on line 27 in src/pages/PullRequestPage/PullRequestPage.jsx

View check run for this annotation

Codecov Public QA / codecov/patch

src/pages/PullRequestPage/PullRequestPage.jsx#L27

Added line #L27 was not covered by tests

if (!isLoading && !data?.pull) {
return <NotFound />
Expand All @@ -45,7 +47,7 @@
/>
<Header />
<Suspense fallback={<CompareSummarySkeleton />}>
<CompareSummary />
{tierName !== TierNames.TEAM && <CompareSummary />}
<FirstPullBanner />
</Suspense>
<Suspense fallback={<Loader />}>
Expand Down
85 changes: 82 additions & 3 deletions src/pages/PullRequestPage/PullRequestPage.spec.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { render, screen } from 'custom-testing-library'
import { render, screen, waitFor } from 'custom-testing-library'

import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { graphql } from 'msw'
import { setupServer } from 'msw/node'
import { MemoryRouter, Route } from 'react-router-dom'

import { TierNames } from 'services/tier'

import PullRequestPage from './PullRequestPage'

jest.mock('shared/featureFlags')
Expand Down Expand Up @@ -79,7 +81,7 @@
})

describe('PullRequestPage', () => {
function setup({ pullData = mockPullPageData }) {
function setup({ pullData = mockPullPageData, tierValue = TierNames.PRO }) {
server.use(
graphql.query('PullHeadData', (req, res, ctx) =>
res(ctx.status(200), ctx.data(mockPullHeadData))
Expand All @@ -96,7 +98,19 @@
},
})
)
)
),
graphql.query('OwnerTier', (req, res, ctx) => {
if (tierValue === TierNames.TEAM) {
return res(
ctx.status(200),
ctx.data({ owner: { plan: { tierName: TierNames.TEAM } } })
)
}
return res(
ctx.status(200),
ctx.data({ owner: { plan: { tierName: TierNames.PRO } } })
)
})
)
}

Expand Down Expand Up @@ -160,6 +174,71 @@
})
})

describe('when there is pull data and the customer is team tier', () => {
beforeEach(() => {
setup({ tierValue: TierNames.TEAM })
})

it('renders breadcrumb', async () => {
render(<PullRequestPage />, { wrapper: wrapper() })

const org = await screen.findByRole('link', { name: 'test-org' })
expect(org).toBeInTheDocument()
expect(org).toHaveAttribute('href', '/gh/test-org')

const repo = await screen.findByRole('link', { name: 'test-repo' })
expect(repo).toBeInTheDocument()
expect(repo).toHaveAttribute('href', '/gh/test-org/test-repo')

const pulls = await screen.findByRole('link', { name: 'Pulls' })
expect(pulls).toBeInTheDocument()
expect(pulls).toHaveAttribute('href', '/gh/test-org/test-repo/pulls')

const pullId = await screen.findByText('12')
expect(pullId).toBeInTheDocument()
})

it('renders header', async () => {
render(<PullRequestPage />, { wrapper: wrapper() })

const header = await screen.findByText(/Header/)
expect(header).toBeInTheDocument()
})

it('does not render compare summary', async () => {
render(<PullRequestPage />, { wrapper: wrapper() })

await waitFor(() => queryClient.isFetching)
await waitFor(() => !queryClient.isFetching)

const compareSummary = screen.queryByText(/CompareSummary/)
expect(compareSummary).not.toBeInTheDocument()

Check failure on line 215 in src/pages/PullRequestPage/PullRequestPage.spec.jsx

View workflow job for this annotation

GitHub Actions / JEST Tests

PullRequestPage ► PullRequestPage when there is pull data and the customer is team tier does not render compare summary ► PullRequestPage when there is pull data and the customer is team tier does not render compare summary

Failed test found in: reports/junit/junit.xml Error: Error: expect(element).not.toBeInTheDocument()
Raw output
Error: expect(element).not.toBeInTheDocument()

expected document not to contain element, found <div class="mx-4 flex flex-col gap-4 md:mx-0"><nav class="flex flex-1 items-center truncate text-ds-gray-octonary [&>*]:mr-1"><a class="
  font-sans cursor-pointer

  hover:underline

  focus:ring-2
 text-ds-blue inline-flex items-center gap-1" data-cy="owner" data-marketing="owner" href="/gh/test-org" text="test-org">test-org</a><span>/</span><a class="
  font-sans cursor-pointer

  hover:underline

  focus:ring-2
 text-ds-blue inline-flex items-center gap-1" data-cy="repo" data-marketing="repo" href="/gh/test-org/test-repo" text="test-repo">test-repo</a><span>/</span><a class="
  font-sans cursor-pointer

  hover:underline

  focus:ring-2
 text-ds-blue inline-flex items-center gap-1" data-cy="pulls" data-marketing="pulls" href="/gh/test-org/test-repo/pulls" text="Pulls">Pulls</a><span>/</span><span class="flex items-center font-semibold">12</span></nav>HeaderCompareSummaryFirstPullBanner<div class="grid grid-cols-1 gap-4 space-y-2 lg:grid-cols-2"><article class="col-span-2 flex flex-col gap-3 md:gap-0">PullRequestPageTabsPullRequestPageContent</article></div></div> instead
    at Object.<anonymous> (/home/runner/work/gazebo/gazebo/src/pages/PullRequestPage/PullRequestPage.spec.jsx:215:34)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:533:9)
    at processTimers (node:internal/timers:507:7)
})

it('renders pull request page tabs', async () => {
render(<PullRequestPage />, { wrapper: wrapper() })

const pullRequestPageTabs = await screen.findByText(/PullRequestPageTabs/)
expect(pullRequestPageTabs).toBeInTheDocument()
})

it('renders pull request page content', async () => {
render(<PullRequestPage />, { wrapper: wrapper() })

const pullRequestPageContent = await screen.findByText(
/PullRequestPageContent/
)
expect(pullRequestPageContent).toBeInTheDocument()
})

it('renders the first pull request banner', async () => {
render(<PullRequestPage />, { wrapper: wrapper() })

const firstPullRequestBanner = await screen.findByText(/FirstPullBanner/)
expect(firstPullRequestBanner).toBeInTheDocument()
})
})

describe('when there is no pull data', () => {
beforeEach(() => setup({ pullData: null }))

Expand Down
Loading