diff --git a/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx index f9c23be407..7b97a836be 100644 --- a/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx +++ b/plugins/scaffolder/src/components/fields/RepoBranchPicker/RepoBranchPicker.test.tsx @@ -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( + + +
, + }} + onSubmit={onSubmit} + formContext={{ + formData: { repoUrl: 'github.com' }, + }} + /> + + , + ); + + const input = screen.getByRole('textbox'); + + expect(input).toBeDisabled(); + }); + it('should render properly with title and description', async () => { const { getByText } = await renderInTestApp( { 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} /> );