Skip to content

Commit

Permalink
[ResponseOps][Alerts] Add missing featureIds to AlertsClient find (el…
Browse files Browse the repository at this point in the history
…astic#190486)

## Summary

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

### References

Fixes elastic#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
  • Loading branch information
umbopepato authored Aug 20, 2024
1 parent e66098a commit bc4c6d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ export class AlertsClient {
}

const alertsSearchResponse = await this.searchAlerts<TAggregations>({
featureIds,
query,
aggs,
_source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit bc4c6d7

Please sign in to comment.