@@ -18,7 +18,7 @@ import { Entity } from '@backstage/catalog-model';
|
||||
import { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
|
||||
import { FieldProps } from '@rjsf/core';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { fireEvent } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { EntityPicker } from './EntityPicker';
|
||||
|
||||
@@ -92,15 +92,16 @@ describe('<EntityPicker />', () => {
|
||||
});
|
||||
|
||||
it('updates even if there is not an exact match', async () => {
|
||||
const { getByLabelText } = await renderInTestApp(
|
||||
const { getByRole } = await renderInTestApp(
|
||||
<Wrapper>
|
||||
<EntityPicker {...props} />
|
||||
</Wrapper>,
|
||||
);
|
||||
const input = getByLabelText('Entity');
|
||||
|
||||
userEvent.type(input, 'squ');
|
||||
input.blur();
|
||||
const input = getByRole('textbox');
|
||||
|
||||
fireEvent.change(input, { target: { value: 'squ' } });
|
||||
fireEvent.blur(input);
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith('squ');
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ export const EntityPicker = (
|
||||
formData,
|
||||
idSchema,
|
||||
} = props;
|
||||
const allowedKinds = uiSchema['ui:options']?.allowedKinds ?? [];
|
||||
const allowedKinds = uiSchema['ui:options']?.allowedKinds;
|
||||
const defaultKind = uiSchema['ui:options']?.defaultKind;
|
||||
|
||||
const catalogApi = useApi(catalogApiRef);
|
||||
@@ -85,7 +85,7 @@ export const EntityPicker = (
|
||||
onChange={onSelect}
|
||||
options={entityRefs || []}
|
||||
autoSelect
|
||||
freeSolo={uiSchema['ui:options']?.allowArbitraryValues}
|
||||
freeSolo={uiSchema['ui:options']?.allowArbitraryValues ?? true}
|
||||
renderInput={params => (
|
||||
<TextField
|
||||
{...params}
|
||||
|
||||
Reference in New Issue
Block a user