Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Typeahead expression search doesn't hit Bean Method with b #1038

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an extremely 💅 💅 , maybe we could simply lowercase the filterValue once before using it in each filter pass, we can do it in another PR 👌

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
Loading