-
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.
Add configuration manager tab to repo settings
- Loading branch information
1 parent
d980d71
commit d4a4f83
Showing
9 changed files
with
165 additions
and
83 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 was deleted.
Oops, something went wrong.
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,106 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { MemoryRouter, Route } from 'react-router-dom' | ||
|
||
import { useOwner } from 'services/user' | ||
import { useFlags } from 'shared/featureFlags' | ||
|
||
import SettingsTab from './SettingsTab' | ||
|
||
jest.mock('services/user') | ||
const mockedUseOwner = useOwner as jest.Mock | ||
jest.mock('shared/featureFlags') | ||
const mockedUseFlags = useFlags as jest.Mock | ||
|
||
jest.mock('./tabs/GeneralTab', () => () => 'General Tab') | ||
|
||
const wrapper: (initialEntries?: string) => React.FC<React.PropsWithChildren> = | ||
(initialEntries = '/gh/codecov/codecov-client/settings') => | ||
({ children }) => | ||
( | ||
<MemoryRouter initialEntries={[initialEntries]}> | ||
<Route path="/:provider/:owner/:repo/settings">{children}</Route> | ||
</MemoryRouter> | ||
) | ||
|
||
interface SetupArgs { | ||
isCurrentUserPartOfOrg?: boolean | ||
} | ||
|
||
describe('SettingsTab', () => { | ||
function setup({ isCurrentUserPartOfOrg = true }: SetupArgs) { | ||
mockedUseOwner.mockReturnValue({ data: { isCurrentUserPartOfOrg } }) | ||
mockedUseFlags.mockReturnValue({ inAppMarketingTab: true }) | ||
} | ||
|
||
describe('Render for a repo', () => { | ||
it('renders the right links', async () => { | ||
setup({}) | ||
render(<SettingsTab />, { wrapper: wrapper() }) | ||
|
||
expect( | ||
await screen.findByRole('link', { name: /General/ }) | ||
).toBeInTheDocument() | ||
expect( | ||
await screen.findByRole('link', { name: /Configuration Manager/ }) | ||
).toBeInTheDocument() | ||
expect( | ||
await screen.findByRole('link', { name: /Yaml/ }) | ||
).toBeInTheDocument() | ||
expect( | ||
await screen.findByRole('link', { name: /Badge/ }) | ||
).toBeInTheDocument() | ||
}) | ||
|
||
describe('with feature flag false', () => { | ||
it('does not render the Configuration Manager tab', async () => { | ||
setup({}) | ||
mockedUseFlags.mockReturnValue({ inAppMarketingTab: false }) | ||
render(<SettingsTab />, { wrapper: wrapper() }) | ||
|
||
expect( | ||
await screen.findByRole('link', { name: /General/ }) | ||
).toBeInTheDocument() | ||
expect( | ||
screen.queryByRole('link', { name: /Configuration Manager/ }) | ||
).not.toBeInTheDocument() | ||
expect( | ||
await screen.findByRole('link', { name: /Yaml/ }) | ||
).toBeInTheDocument() | ||
expect( | ||
await screen.findByRole('link', { name: /Badge/ }) | ||
).toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Render with an unknown path', () => { | ||
it('renders the right links', async () => { | ||
setup({}) | ||
render(<SettingsTab />, { | ||
wrapper: wrapper('/gh/codecov/codecov-client/settings/random'), | ||
}) | ||
|
||
expect( | ||
await screen.findByRole('link', { name: /General/ }) | ||
).toBeInTheDocument() | ||
expect( | ||
await screen.findByRole('link', { name: /Configuration Manager/ }) | ||
).toBeInTheDocument() | ||
expect( | ||
await screen.findByRole('link', { name: /Yaml/ }) | ||
).toBeInTheDocument() | ||
expect( | ||
await screen.findByRole('link', { name: /Badge/ }) | ||
).toBeInTheDocument() | ||
}) | ||
}) | ||
|
||
describe('Render with user not part of org', () => { | ||
it('renders 404', async () => { | ||
setup({ isCurrentUserPartOfOrg: false }) | ||
render(<SettingsTab />, { wrapper: wrapper() }) | ||
|
||
expect(await screen.findByText('Error 404')).toBeInTheDocument() | ||
}) | ||
}) | ||
}) |
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 was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/pages/RepoPage/SettingsTab/tabs/ConfigurationManager/ConfigurationManager.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,12 @@ | ||
import { render, screen } from '@testing-library/react' | ||
|
||
import ConfigurationManager from './ConfigurationManager' | ||
|
||
describe('Configuration Manager', () => { | ||
it('temp: renders Configuration Manager', async () => { | ||
render(<ConfigurationManager />) | ||
|
||
const text = await screen.findByText('Configuration Manager') | ||
expect(text).toBeInTheDocument() | ||
}) | ||
}) |
5 changes: 5 additions & 0 deletions
5
src/pages/RepoPage/SettingsTab/tabs/ConfigurationManager/ConfigurationManager.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,5 @@ | ||
function ConfigurationManager() { | ||
return <p>Configuration Manager</p> | ||
} | ||
|
||
export default ConfigurationManager |
1 change: 1 addition & 0 deletions
1
src/pages/RepoPage/SettingsTab/tabs/ConfigurationManager/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 './ConfigurationManager' |
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