Skip to content

Commit

Permalink
[ResponseOps][Rules] Fix bug saving actions when editing rules. (#187767
Browse files Browse the repository at this point in the history
)

## Summary

Fix bug saving actions when editing rules.

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
adcoelho and elasticmachine authored Jul 9, 2024
1 parent 66844f5 commit 0b9751b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,9 @@ describe('updateRule', () => {
},
],
});
expect(http.put.mock.calls[0]).toMatchInlineSnapshot(`
Array [
"/api/alerting/rule/12%2F3",
Object {
"body": "{\\"name\\":\\"test\\",\\"tags\\":[\\"foo\\"],\\"schedule\\":{\\"interval\\":\\"1m\\"},\\"params\\":{},\\"actions\\":[],\\"alert_delay\\":{\\"active\\":10}}",
},
]
`);

expect(http.put).toHaveBeenCalledWith('/api/alerting/rule/12%2F3', {
body: '{"name":"test","tags":["foo"],"schedule":{"interval":"1m"},"params":{},"actions":[{"group":"default","id":"2","params":{},"frequency":{"notify_when":"onActionGroupChange","throttle":null,"summary":false},"use_alert_data_for_template":false},{"id":".test-system-action","params":{}}],"alert_delay":{"active":10}}',
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function updateRule({
const res = await http.put<AsApiContract<Rule>>(
`${BASE_ALERTING_API_PATH}/rule/${encodeURIComponent(id)}`,
{
body: JSON.stringify(transformUpdateRuleBody(pick(rule, UPDATE_FIELDS))),
body: JSON.stringify(transformUpdateRuleBody(pick(rule, UPDATE_FIELDS_WITH_ACTIONS))),
}
);
return transformRule(res);
Expand Down

0 comments on commit 0b9751b

Please sign in to comment.