feat: ui:disabled allowed in BitbucketRepoBranchPicker
Signed-off-by: Nikunj Hudka <nikunjhudka123@gmail.com>
This commit is contained in:
+26
-1
@@ -20,7 +20,13 @@ import {
|
||||
scaffolderApiRef,
|
||||
} from '@backstage/plugin-scaffolder-react';
|
||||
import { BitbucketRepoBranchPicker } from './BitbucketRepoBranchPicker';
|
||||
import { act, fireEvent, render, waitFor } from '@testing-library/react';
|
||||
import {
|
||||
act,
|
||||
fireEvent,
|
||||
render,
|
||||
waitFor,
|
||||
screen,
|
||||
} from '@testing-library/react';
|
||||
import { TestApiProvider } from '@backstage/test-utils';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
@@ -44,6 +50,25 @@ describe('BitbucketRepoBranchPicker', () => {
|
||||
expect(getByRole('textbox')).toHaveValue('main');
|
||||
});
|
||||
|
||||
it('input field disabled', () => {
|
||||
render(
|
||||
<TestApiProvider apis={[[scaffolderApiRef, scaffolderApiMock]]}>
|
||||
<BitbucketRepoBranchPicker
|
||||
onChange={jest.fn()}
|
||||
isDisabled
|
||||
state={{ branch: 'main' }}
|
||||
rawErrors={[]}
|
||||
/>
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
const input = screen.getByRole('textbox');
|
||||
|
||||
// Expect input to be disabled
|
||||
expect(input).toBeDisabled();
|
||||
expect(input).toHaveValue('main');
|
||||
});
|
||||
|
||||
it('calls onChange when the input field changes', () => {
|
||||
const onChange = jest.fn();
|
||||
|
||||
|
||||
+8
-1
@@ -36,6 +36,7 @@ export const BitbucketRepoBranchPicker = ({
|
||||
state,
|
||||
rawErrors,
|
||||
accessToken,
|
||||
isDisabled,
|
||||
required,
|
||||
}: BaseRepoBranchPickerProps<{
|
||||
accessToken?: string;
|
||||
@@ -86,9 +87,15 @@ export const BitbucketRepoBranchPicker = ({
|
||||
onChange={(_, newValue) => {
|
||||
onChange({ branch: newValue || '' });
|
||||
}}
|
||||
disabled={isDisabled}
|
||||
options={availableBranches}
|
||||
renderInput={params => (
|
||||
<TextField {...params} label="Branch" required={required} />
|
||||
<TextField
|
||||
{...params}
|
||||
label="Branch"
|
||||
disabled={isDisabled}
|
||||
required={required}
|
||||
/>
|
||||
)}
|
||||
freeSolo
|
||||
autoSelect
|
||||
|
||||
Reference in New Issue
Block a user