[ResponseOps][Alerts] Add missing featureIds to AlertsClient find (#190486)

## Summary

Forwards `featureIds` from `AlertsClient.find()` to
`AlertsClient.searchAlerts()`

### References

Fixes #190424

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
This commit is contained in:
Umberto Pepato 2024-08-20 10:16:04 +02:00 committed by GitHub
parent e66098a0a4
commit bc4c6d7eac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View file

@ -1017,6 +1017,7 @@ export class AlertsClient {
}
const alertsSearchResponse = await this.searchAlerts<TAggregations>({
featureIds,
query,
aggs,
_source,

View file

@ -74,6 +74,8 @@ beforeEach(() => {
describe('find()', () => {
test('calls ES client with given params', async () => {
const alertsClient = new AlertsClient(alertsClientParams);
const searchAlertsSpy = jest.spyOn(alertsClient as any, 'searchAlerts');
alertsClient.getAuthorizedAlertsIndices = jest.fn().mockResolvedValue([]);
esClientMock.search.mockResponseOnce({
took: 5,
timed_out: false,
@ -107,10 +109,21 @@ describe('find()', () => {
],
},
});
const query = { match: { [ALERT_WORKFLOW_STATUS]: 'open' } };
const index = '.alerts-observability.apm.alerts';
const featureIds = ['siem'];
const result = await alertsClient.find({
query: { match: { [ALERT_WORKFLOW_STATUS]: 'open' } },
index: '.alerts-observability.apm.alerts',
query,
index,
featureIds,
});
expect(searchAlertsSpy).toHaveBeenCalledWith(
expect.objectContaining({
query,
index,
featureIds,
})
);
expect(result).toMatchInlineSnapshot(`
Object {
"_shards": Object {