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

[Security Solution] [Grouping] Re-add support to custom Group By title in the useGetGroupSelector hook #184165

Merged
merged 4 commits into from
May 29, 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 @@ -73,6 +73,14 @@ describe('group selector', () => {
const { getByTestId } = render(<GroupSelector {...testProps} />);
expect(getByTestId('group-selector-dropdown').textContent).toBe('Group alerts by: Rule name');
});
it('Sets the Group by title from the title prop', () => {
const { getByTestId } = render(
<GroupSelector {...testProps} title="Group custom property by" />
);
expect(getByTestId('group-selector-dropdown').textContent).toBe(
'Group custom property by: Rule name'
);
});
it('Presents correct option when group selector dropdown is clicked', () => {
const { getByTestId } = render(<GroupSelector {...testProps} />);
fireEvent.click(getByTestId('group-selector-dropdown'));
Expand Down
11 changes: 11 additions & 0 deletions packages/kbn-grouping/src/hooks/use_get_group_selector.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,17 @@ describe('Group Selector Hooks', () => {
type: ActionType.updateGroupOptions,
});
});

it('Supports custom group by title', () => {
const result = renderHook(() =>
useGetGroupSelector({
...defaultArgs,
title: 'Group custom property by',
})
);

expect(result.result.current.props.title).toEqual('Group custom property by');
});
});

describe('useGetGroupSelectorStateless', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ export const useGetGroupSelector = ({
fields,
maxGroupingLevels,
options,
title,
}}
/>
);
}, [groupingId, fields, maxGroupingLevels, onChange, selectedGroups, options]);
}, [groupingId, fields, maxGroupingLevels, onChange, selectedGroups, options, title]);
};