Skip to content

Commit

Permalink
fix: Typeahead expression search doesn't hit Bean Method with b
Browse files Browse the repository at this point in the history
Fixes: #1027
  • Loading branch information
igarashitm authored and lordrip committed Apr 26, 2024
1 parent 2dc6c93 commit a3aeb55
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,29 @@ describe('ExpressionEditor', () => {
});
expect(inputElement).toHaveValue('');
});

it('find bean method with a word bean', async () => {
const language = ExpressionService.getDefinitionFromModelName(
languageCatalog as unknown as Record<string, ICamelLanguageDefinition>,
'method',
);
render(
<ExpressionEditor
language={language}
expressionModel={{}}
onChangeExpressionModel={onChangeMock}
></ExpressionEditor>,
);
const inputElement = screen.getAllByRole('combobox')[0];
await act(async () => {
fireEvent.change(inputElement, { target: { value: 'b' } });
});
const dropdownItems = screen.getAllByTestId(/expression-dropdownitem-.*/);
expect(dropdownItems).toHaveLength(6);
await act(async () => {
fireEvent.change(inputElement, { target: { value: 'bean' } });
});
const dropdownItems2 = screen.getAllByTestId(/expression-dropdownitem-.*/);
expect(dropdownItems2).toHaveLength(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ export const ExpressionEditor: FunctionComponent<ExpressionEditorProps> = ({

// Filter menu items based on the text input value when one exists
if (filterValue) {
newSelectOptions = languageCatalogMap.filter((menuItem) =>
String(menuItem.value).toLowerCase().includes(filterValue.toLowerCase()),
newSelectOptions = languageCatalogMap.filter(
(menuItem) =>
String(menuItem.value).toLowerCase().includes(filterValue.toLowerCase()) ||
String(menuItem.children).toLowerCase().includes(filterValue.toLowerCase()) ||
String(menuItem.description).toLowerCase().includes(filterValue.toLowerCase()),
);
// When no options are found after filtering, display 'No results found'
if (!newSelectOptions.length) {
Expand Down

0 comments on commit a3aeb55

Please sign in to comment.