-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spalmurray/account details card (#3382)
- Loading branch information
1 parent
c21959b
commit b3910ea
Showing
7 changed files
with
129 additions
and
11 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/pages/PlanPage/subRoutes/CurrentOrgPlan/AccountOrgs/AccountOrgs.test.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,66 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { MemoryRouter, Route } from 'react-router' | ||
|
||
import AccountOrgs from './AccountOrgs' | ||
|
||
import { Account } from '../hooks/useEnterpriseAccountDetails' | ||
|
||
const mockAccount: Account = { | ||
name: 'my-account', | ||
totalSeatCount: 10, | ||
activatedUserCount: 3, | ||
organizations: { | ||
totalCount: 4, | ||
}, | ||
} | ||
|
||
const wrapper: React.FC<React.PropsWithChildren> = ({ children }) => ( | ||
<MemoryRouter initialEntries={['/plan/gh/codecov']}> | ||
<Route path="/plan/:provider/:owner">{children}</Route> | ||
</MemoryRouter> | ||
) | ||
|
||
describe('AccountOrgs', () => { | ||
it('renders Header', async () => { | ||
render(<AccountOrgs account={mockAccount} />, { wrapper }) | ||
|
||
const header = await screen.findByText('Account details') | ||
expect(header).toBeInTheDocument() | ||
const description = await screen.findByText( | ||
/To modify your orgs and seats, please/ | ||
) | ||
expect(description).toBeInTheDocument() | ||
}) | ||
|
||
it('renders total orgs', async () => { | ||
render(<AccountOrgs account={mockAccount} />, { wrapper }) | ||
|
||
const label = await screen.findByText('Total organizations') | ||
expect(label).toBeInTheDocument() | ||
|
||
const number = await screen.findByText(mockAccount.organizations.totalCount) | ||
expect(number).toBeInTheDocument() | ||
}) | ||
|
||
it('renders total seats', async () => { | ||
render(<AccountOrgs account={mockAccount} />, { wrapper }) | ||
|
||
const label = await screen.findByText('Total seats') | ||
expect(label).toBeInTheDocument() | ||
|
||
const number = await screen.findByText(mockAccount.totalSeatCount) | ||
expect(number).toBeInTheDocument() | ||
}) | ||
|
||
it('renders seats remaining', async () => { | ||
render(<AccountOrgs account={mockAccount} />, { wrapper }) | ||
|
||
const label = await screen.findByText('Seats remaining') | ||
expect(label).toBeInTheDocument() | ||
|
||
const number = await screen.findByText( | ||
mockAccount.totalSeatCount - mockAccount.activatedUserCount | ||
) | ||
expect(number).toBeInTheDocument() | ||
}) | ||
}) |
38 changes: 38 additions & 0 deletions
38
src/pages/PlanPage/subRoutes/CurrentOrgPlan/AccountOrgs/AccountOrgs.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,38 @@ | ||
import A from 'ui/A' | ||
import { Card } from 'ui/Card' | ||
|
||
import { Account } from '../hooks/useEnterpriseAccountDetails' | ||
|
||
interface AccountOrgsArgs { | ||
account: Account | ||
} | ||
|
||
export default function AccountOrgs({ account }: AccountOrgsArgs) { | ||
return ( | ||
<Card> | ||
<Card.Header> | ||
<Card.Title size="sm">Account details</Card.Title> | ||
<Card.Description className="text-sm text-ds-gray-quinary"> | ||
To modify your orgs and seats, please {/* @ts-ignore-error */} | ||
<A to={{ pageName: 'enterpriseSupport' }}>contact support</A>. | ||
</Card.Description> | ||
</Card.Header> | ||
<Card.Content className="m-0 flex divide-x font-medium"> | ||
<div className="flex-1 p-4"> | ||
<p>Total organizations</p> | ||
<p className="pt-2 text-xl">{account.organizations.totalCount}</p> | ||
</div> | ||
<div className="flex-1 p-4"> | ||
<p>Total seats</p> | ||
<p className="pt-2 text-xl">{account.totalSeatCount}</p> | ||
</div> | ||
<div className="flex-1 p-4"> | ||
<p>Seats remaining</p> | ||
<p className="pt-2 text-xl"> | ||
{account.totalSeatCount - account.activatedUserCount} | ||
</p> | ||
</div> | ||
</Card.Content> | ||
</Card> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
src/pages/PlanPage/subRoutes/CurrentOrgPlan/AccountOrgs/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 './AccountOrgs' |
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