[ResponseOps][Rules] Fix bug saving actions when editing rules. (#187767)

## Summary

Fix bug saving actions when editing rules.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Antonio 2024-07-09 12:16:59 +02:00 committed by GitHub
parent 66844f574f
commit 0b9751b245
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 9 deletions

View file

@ -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}}',
});
});
});

View file

@ -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);