chore: fix free solo

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2022-02-23 11:39:53 +01:00
parent b698a20195
commit 3825dab8d9
2 changed files with 8 additions and 7 deletions
@@ -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}