feat: ui:disabled allowed in RepoBranchPicker
Signed-off-by: Nikunj Hudka <nikunjhudka123@gmail.com>
This commit is contained in:
+35
-1
@@ -31,7 +31,7 @@ import {
|
||||
useTemplateSecrets,
|
||||
ScaffolderRJSFField,
|
||||
} from '@backstage/plugin-scaffolder-react';
|
||||
import { act, fireEvent } from '@testing-library/react';
|
||||
import { act, fireEvent, screen } from '@testing-library/react';
|
||||
import { RepoBranchPicker } from './RepoBranchPicker';
|
||||
|
||||
describe('RepoBranchPicker', () => {
|
||||
@@ -92,6 +92,40 @@ describe('RepoBranchPicker', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should disable the picker when ui:disabled', async () => {
|
||||
const onSubmit = jest.fn();
|
||||
|
||||
await renderInTestApp(
|
||||
<TestApiProvider
|
||||
apis={[
|
||||
[scmIntegrationsApiRef, mockIntegrationsApi],
|
||||
[scmAuthApiRef, {}],
|
||||
[scaffolderApiRef, {}],
|
||||
]}
|
||||
>
|
||||
<SecretsContextProvider>
|
||||
<Form
|
||||
validator={validator}
|
||||
schema={{ type: 'string' }}
|
||||
uiSchema={{ 'ui:field': 'RepoBranchPicker', 'ui:disabled': true }}
|
||||
fields={{
|
||||
RepoBranchPicker:
|
||||
RepoBranchPicker as ScaffolderRJSFField<string>,
|
||||
}}
|
||||
onSubmit={onSubmit}
|
||||
formContext={{
|
||||
formData: { repoUrl: 'github.com' },
|
||||
}}
|
||||
/>
|
||||
</SecretsContextProvider>
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
const input = screen.getByRole('textbox');
|
||||
|
||||
expect(input).toBeDisabled();
|
||||
});
|
||||
|
||||
it('should render properly with title and description', async () => {
|
||||
const { getByText } = await renderInTestApp(
|
||||
<TestApiProvider
|
||||
|
||||
@@ -133,6 +133,7 @@ export const RepoBranchPicker = (props: RepoBranchPickerProps) => {
|
||||
uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey &&
|
||||
secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey]
|
||||
}
|
||||
isDisabled={uiSchema?.['ui:disabled'] ?? false}
|
||||
required={required}
|
||||
/>
|
||||
);
|
||||
@@ -146,6 +147,7 @@ export const RepoBranchPicker = (props: RepoBranchPickerProps) => {
|
||||
uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey &&
|
||||
secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey]
|
||||
}
|
||||
isDisabled={uiSchema?.['ui:disabled'] ?? false}
|
||||
required={required}
|
||||
/>
|
||||
);
|
||||
@@ -155,6 +157,7 @@ export const RepoBranchPicker = (props: RepoBranchPickerProps) => {
|
||||
onChange={updateLocalState}
|
||||
state={state}
|
||||
rawErrors={rawErrors}
|
||||
isDisabled={uiSchema?.['ui:disabled'] ?? false}
|
||||
required={required}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user