-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into Ajay/2140-failed-tests-hook-link
- Loading branch information
Showing
19 changed files
with
815 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
...oPage/SettingsTab/tabs/ConfigurationManager/components/FeatureGroup/FeatureGroup.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { render, screen, waitFor } from '@testing-library/react' | ||
import { MemoryRouter, Route } from 'react-router' | ||
|
||
import FeatureGroup from './FeatureGroup' | ||
|
||
const wrapper: React.FC<React.PropsWithChildren> = ({ children }) => ( | ||
<MemoryRouter initialEntries={['/gh/codecov/cool-repo/settings/config']}> | ||
<Route path="/:provider/:owner/:repo/settings/config">{children}</Route> | ||
</MemoryRouter> | ||
) | ||
|
||
describe('FeatureGroup', () => { | ||
it('renders title', async () => { | ||
render(<FeatureGroup title="Title" getStartedLink="repo" />, { wrapper }) | ||
|
||
const title = await screen.findByText('Title') | ||
expect(title).toBeInTheDocument() | ||
}) | ||
|
||
it('renders get started button', async () => { | ||
render( | ||
<FeatureGroup | ||
title="Title" | ||
getStartedLink="repo" | ||
showGetStartedLink={true} | ||
/>, | ||
{ wrapper } | ||
) | ||
|
||
const button = await screen.findByRole('link', { name: 'Get Started' }) | ||
expect(button).toBeInTheDocument() | ||
}) | ||
|
||
it('renders children', async () => { | ||
render( | ||
<FeatureGroup title="Title" getStartedLink="repo"> | ||
<p>child</p> | ||
</FeatureGroup>, | ||
{ wrapper } | ||
) | ||
|
||
const child = await screen.findByText('child') | ||
expect(child).toBeInTheDocument() | ||
}) | ||
|
||
describe('composition with UniversalItems and ProItems', () => { | ||
it('renders children', async () => { | ||
render( | ||
<FeatureGroup title="Title" getStartedLink="repo"> | ||
<FeatureGroup.UniversalItems> | ||
<p>Universal child</p> | ||
</FeatureGroup.UniversalItems> | ||
<FeatureGroup.ProItems> | ||
<p>Pro child</p> | ||
</FeatureGroup.ProItems> | ||
</FeatureGroup>, | ||
{ wrapper } | ||
) | ||
|
||
const universalChild = await screen.findByText('Universal child') | ||
expect(universalChild).toBeInTheDocument() | ||
|
||
const proChild = await screen.findByText('Pro child') | ||
expect(proChild).toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('UniversalItems', () => { | ||
it('renders children', async () => { | ||
render( | ||
<FeatureGroup.UniversalItems> | ||
<p>child</p> | ||
</FeatureGroup.UniversalItems>, | ||
{ wrapper } | ||
) | ||
|
||
const child = await screen.findByText('child') | ||
expect(child).toBeInTheDocument() | ||
}) | ||
}) | ||
|
||
describe('ProItems', () => { | ||
it('renders children', async () => { | ||
render( | ||
<FeatureGroup.ProItems> | ||
<p>child</p> | ||
</FeatureGroup.ProItems>, | ||
{ wrapper } | ||
) | ||
|
||
const child = await screen.findByText('child') | ||
expect(child).toBeInTheDocument() | ||
}) | ||
|
||
describe('when on team plan', () => { | ||
it('renders upgrade to pro CTA', async () => { | ||
render(<FeatureGroup.ProItems isTeamPlan={true} />, { wrapper }) | ||
|
||
const cta = await screen.findByText('Available with Pro Plan') | ||
expect(cta).toBeInTheDocument() | ||
|
||
const upgrade = await screen.findByRole('link', { name: 'upgrade' }) | ||
expect(upgrade).toBeInTheDocument() | ||
}) | ||
}) | ||
|
||
describe('when not on team plan', () => { | ||
it('does not render upgrade to pro CTA', async () => { | ||
render( | ||
<FeatureGroup.ProItems isTeamPlan={false}> | ||
<p>child</p> | ||
</FeatureGroup.ProItems>, | ||
{ wrapper } | ||
) | ||
|
||
await waitFor(() => screen.findByText('child')) | ||
|
||
const cta = screen.queryByText('Available with Pro Plan') | ||
expect(cta).not.toBeInTheDocument() | ||
|
||
const upgrade = screen.queryByRole('link', { name: 'upgrade' }) | ||
expect(upgrade).not.toBeInTheDocument() | ||
}) | ||
}) | ||
}) |
83 changes: 83 additions & 0 deletions
83
...s/RepoPage/SettingsTab/tabs/ConfigurationManager/components/FeatureGroup/FeatureGroup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import A from 'ui/A' | ||
import Button from 'ui/Button' | ||
import { Card } from 'ui/Card' | ||
|
||
interface FeatureGroupProps extends React.PropsWithChildren { | ||
title: string | ||
getStartedLink: string // navLink key | ||
showGetStartedLink?: boolean | ||
} | ||
|
||
function FeatureGroup({ | ||
title, | ||
getStartedLink, | ||
showGetStartedLink, | ||
children, | ||
}: FeatureGroupProps) { | ||
return ( | ||
<Card className="pb-5"> | ||
<Card.Header className="flex"> | ||
<Card.Title size="xl" className="flex-1"> | ||
{title} | ||
</Card.Title> | ||
{showGetStartedLink ? ( | ||
<Button | ||
to={{ pageName: getStartedLink }} | ||
disabled={false} | ||
variant="primary" | ||
hook="configuration-get-started" | ||
> | ||
Get Started | ||
</Button> | ||
) : null} | ||
</Card.Header> | ||
{children} | ||
</Card> | ||
) | ||
} | ||
|
||
function UniversalItems({ children }: React.PropsWithChildren) { | ||
return ( | ||
<Card.Content className="mb-0 flex flex-col gap-2">{children}</Card.Content> | ||
) | ||
} | ||
|
||
interface ProItemsProps extends React.PropsWithChildren { | ||
isTeamPlan?: boolean | ||
} | ||
|
||
function ProItems({ isTeamPlan, children }: ProItemsProps) { | ||
if (isTeamPlan) { | ||
return ( | ||
<Card.Footer className="mt-5 flex flex-col gap-2 pb-0"> | ||
<p className="flex items-baseline gap-1"> | ||
<span className="font-medium text-ds-gray-quinary"> | ||
Available with Pro Plan | ||
</span> | ||
<span className="h-min text-xs"> | ||
<A | ||
to={{ pageName: 'upgradeOrgPlan' }} | ||
hook="configuration-upgrade" | ||
isExternal={false} | ||
variant="medium" | ||
> | ||
upgrade | ||
</A> | ||
</span> | ||
</p> | ||
{children} | ||
</Card.Footer> | ||
) | ||
} | ||
|
||
return ( | ||
<Card.Content className="mb-0 mt-2 flex flex-col gap-2"> | ||
{children} | ||
</Card.Content> | ||
) | ||
} | ||
|
||
export default Object.assign(FeatureGroup, { | ||
UniversalItems, | ||
ProItems, | ||
}) |
1 change: 1 addition & 0 deletions
1
src/pages/RepoPage/SettingsTab/tabs/ConfigurationManager/components/FeatureGroup/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './FeatureGroup' |
Oops, something went wrong.