Update test coverage and export docs
Signed-off-by: Andrew Kundrock <akundrock@somalogic.com>
This commit is contained in:
committed by
Camila Belo
parent
8f9864e8e2
commit
afda8319d9
@@ -3,4 +3,8 @@
|
||||
'@backstage/plugin-scaffolder-backend': minor
|
||||
---
|
||||
|
||||
Add field selection rendering of allowed Projects for BitbucketRepoPicker. Allows a user to define allowed projects via the ui:field RepoUrlPicker ui:options allowed Projects
|
||||
Add field selection rendering of allowed Projects for BitbucketRepoPicker. Allows a user to define allowed projects via the ui:field RepoUrlPicker ui:options allowed Projects.
|
||||
|
||||
Add comments about expected values for BitbucketRepoPicker: Projects and workspaces
|
||||
|
||||
Update tests to cover null, empty list, and list values for allowed Bitbucket projects
|
||||
|
||||
@@ -20,15 +20,17 @@ spec:
|
||||
ui:options:
|
||||
allowedHosts:
|
||||
- bitbucket.org
|
||||
allowedOwners:
|
||||
- WORKSPACE1
|
||||
- WORKSPACE2
|
||||
allowedProjects:
|
||||
- PROJECT1
|
||||
- PROJECT2
|
||||
allowedRepos:
|
||||
- REPO1
|
||||
- REPO2
|
||||
# The rest of these options are optional.
|
||||
# You can read more at: https://backstage.io/docs/reference/plugin-scaffolder.repourlpickerfieldextension
|
||||
# allowedOwners:
|
||||
# - WORKSPACE1
|
||||
# - WORKSPACE2
|
||||
# allowedProjects:
|
||||
# - PROJECT1
|
||||
# - PROJECT2
|
||||
# allowedRepos:
|
||||
# - REPO1
|
||||
# - REPO2
|
||||
- title: Fill in some steps
|
||||
required:
|
||||
- name
|
||||
|
||||
+42
-15
@@ -57,21 +57,6 @@ describe('BitbucketRepoPicker', () => {
|
||||
expect(getAllByRole('textbox')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('renders a select if there is a list of allowed projects', async () => {
|
||||
const allowedProjects = ['project1', 'project2'];
|
||||
const { findByText } = render(
|
||||
<BitbucketRepoPicker
|
||||
onChange={jest.fn()}
|
||||
rawErrors={[]}
|
||||
state={{ host: 'bitbucket.org', repoName: 'repo' }}
|
||||
allowedProjects={allowedProjects}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(await findByText('project1')).toBeInTheDocument();
|
||||
expect(await findByText('project2')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('workspace field', () => {
|
||||
it('calls onChange when the workspace changes', () => {
|
||||
const onChange = jest.fn();
|
||||
@@ -108,5 +93,47 @@ describe('BitbucketRepoPicker', () => {
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith({ project: 'test-project' });
|
||||
});
|
||||
|
||||
it('Does not render a select if the list of allowed projects does not exist', async () => {
|
||||
const { getAllByRole } = render(
|
||||
<BitbucketRepoPicker
|
||||
onChange={jest.fn()}
|
||||
rawErrors={[]}
|
||||
state={{ host: 'bitbucket.org', repoName: 'repo' }}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(getAllByRole('textbox')).toHaveLength(2);
|
||||
expect(getAllByRole('textbox')[1]).toHaveValue('');
|
||||
});
|
||||
|
||||
it('Does not render a select if the list of allowed projects is empty', async () => {
|
||||
const { getAllByRole } = render(
|
||||
<BitbucketRepoPicker
|
||||
onChange={jest.fn()}
|
||||
rawErrors={[]}
|
||||
state={{ host: 'bitbucket.org', repoName: 'repo' }}
|
||||
allowedProjects={[]}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(getAllByRole('textbox')).toHaveLength(2);
|
||||
expect(getAllByRole('textbox')[1]).toHaveValue('');
|
||||
});
|
||||
|
||||
it('Does render a select if there is a list of allowed projects', async () => {
|
||||
const allowedProjects = ['project1', 'project2'];
|
||||
const { findByText } = render(
|
||||
<BitbucketRepoPicker
|
||||
onChange={jest.fn()}
|
||||
rawErrors={[]}
|
||||
state={{ host: 'bitbucket.org', repoName: 'repo' }}
|
||||
allowedProjects={allowedProjects}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(await findByText('project1')).toBeInTheDocument();
|
||||
expect(await findByText('project2')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,6 +21,15 @@ import InputLabel from '@material-ui/core/InputLabel';
|
||||
import { Select, SelectItem } from '@backstage/core-components';
|
||||
import { RepoUrlPickerState } from './types';
|
||||
|
||||
/**
|
||||
* The underlying component that is rendered in the form for the `BitbucketRepoPicker`
|
||||
* field extension.
|
||||
*
|
||||
* @public
|
||||
* @param allowedOwners - Allowed workspaces for the Bitbucket cloud repository
|
||||
* @param allowedProjects - Allowed projects for the Bitbucket cloud repository
|
||||
*
|
||||
*/
|
||||
export const BitbucketRepoPicker = (props: {
|
||||
allowedOwners?: string[];
|
||||
allowedProjects?: string[];
|
||||
|
||||
Reference in New Issue
Block a user