-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.7] [Response Ops][Alerting] Editing rule action does not auto-popu…
…late default summary message (#151048) (#151134) # Backport This will backport the following commits from `main` to `8.7`: - [[Response Ops][Alerting] Editing rule action does not auto-populate default summary message (#151048)](#151048) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Alexi Doak","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-02-14T13:44:43Z","message":"[Response Ops][Alerting] Editing rule action does not auto-populate default summary message (#151048)\n\nResolves https://github.com/elastic/kibana/issues/150715\r\n\r\n## Summary\r\n\r\nWhen editing an existing action on an existing rule, switching between\r\nthe For each alert and Summary alert dropdown does switch the existing\r\naction message to the default message.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n\r\n### To verify\r\n\r\n- create a rule with an action that uses `For each alert` notification\r\nfrequency; use the default message\r\n- edit your new rule and switch the action frequency to `Summary of\r\nalerts`; notice that the message does change to the default summary\r\nmessage\r\n- create a rule with an action that uses `Summary of alerts`\r\nnotification frequency; use the default message\r\n- edit your new rule and switch the action frequency to `For each\r\nalert`; notice that the message does change to the default summary\r\nmessage\r\n- repeat the steps above and but create the rule a with an action that\r\ndoes not use the default message","sha":"96d10f05b325cb2a621b24194f5ebabab578e793","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Feature:Alerting","release_note:skip","Team:ResponseOps","v8.7.0","v8.8.0"],"number":151048,"url":"https://github.com/elastic/kibana/pull/151048","mergeCommit":{"message":"[Response Ops][Alerting] Editing rule action does not auto-populate default summary message (#151048)\n\nResolves https://github.com/elastic/kibana/issues/150715\r\n\r\n## Summary\r\n\r\nWhen editing an existing action on an existing rule, switching between\r\nthe For each alert and Summary alert dropdown does switch the existing\r\naction message to the default message.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n\r\n### To verify\r\n\r\n- create a rule with an action that uses `For each alert` notification\r\nfrequency; use the default message\r\n- edit your new rule and switch the action frequency to `Summary of\r\nalerts`; notice that the message does change to the default summary\r\nmessage\r\n- create a rule with an action that uses `Summary of alerts`\r\nnotification frequency; use the default message\r\n- edit your new rule and switch the action frequency to `For each\r\nalert`; notice that the message does change to the default summary\r\nmessage\r\n- repeat the steps above and but create the rule a with an action that\r\ndoes not use the default message","sha":"96d10f05b325cb2a621b24194f5ebabab578e793"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/151048","number":151048,"mergeCommit":{"message":"[Response Ops][Alerting] Editing rule action does not auto-populate default summary message (#151048)\n\nResolves https://github.com/elastic/kibana/issues/150715\r\n\r\n## Summary\r\n\r\nWhen editing an existing action on an existing rule, switching between\r\nthe For each alert and Summary alert dropdown does switch the existing\r\naction message to the default message.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n\r\n### To verify\r\n\r\n- create a rule with an action that uses `For each alert` notification\r\nfrequency; use the default message\r\n- edit your new rule and switch the action frequency to `Summary of\r\nalerts`; notice that the message does change to the default summary\r\nmessage\r\n- create a rule with an action that uses `Summary of alerts`\r\nnotification frequency; use the default message\r\n- edit your new rule and switch the action frequency to `For each\r\nalert`; notice that the message does change to the default summary\r\nmessage\r\n- repeat the steps above and but create the rule a with an action that\r\ndoes not use the default message","sha":"96d10f05b325cb2a621b24194f5ebabab578e793"}}]}] BACKPORT--> Co-authored-by: Alexi Doak <[email protected]>
- Loading branch information
1 parent
6050429
commit 601e718
Showing
10 changed files
with
236 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,4 +128,62 @@ describe('EmailParamsFields renders', () => { | |
|
||
expect(editAction).not.toHaveBeenCalledWith('message', 'Some different default message', 0); | ||
}); | ||
|
||
test('when useDefaultMessage is set to true and the default message changes, the underlying message is replaced with the default message', () => { | ||
const actionParams = { | ||
cc: [], | ||
bcc: [], | ||
to: ['[email protected]'], | ||
subject: 'test', | ||
}; | ||
|
||
const editAction = jest.fn(); | ||
const wrapper = mountWithIntl( | ||
<EmailParamsFields | ||
actionParams={{ ...actionParams, message: 'not the default message' }} | ||
errors={{ to: [], cc: [], bcc: [], subject: [], message: [] }} | ||
editAction={editAction} | ||
defaultMessage={'Some default message'} | ||
index={0} | ||
/> | ||
); | ||
const text = wrapper.find('[data-test-subj="messageTextArea"]').first().text(); | ||
expect(text).toEqual('not the default message'); | ||
|
||
wrapper.setProps({ | ||
useDefaultMessage: true, | ||
defaultMessage: 'Some different default message', | ||
}); | ||
|
||
expect(editAction).toHaveBeenCalledWith('message', 'Some different default message', 0); | ||
}); | ||
|
||
test('when useDefaultMessage is set to false and the default message changes, the underlying message is not changed', () => { | ||
const actionParams = { | ||
cc: [], | ||
bcc: [], | ||
to: ['[email protected]'], | ||
subject: 'test', | ||
}; | ||
|
||
const editAction = jest.fn(); | ||
const wrapper = mountWithIntl( | ||
<EmailParamsFields | ||
actionParams={{ ...actionParams, message: 'not the default message' }} | ||
errors={{ to: [], cc: [], bcc: [], subject: [], message: [] }} | ||
editAction={editAction} | ||
defaultMessage={'Some default message'} | ||
index={0} | ||
/> | ||
); | ||
const text = wrapper.find('[data-test-subj="messageTextArea"]').first().text(); | ||
expect(text).toEqual('not the default message'); | ||
|
||
wrapper.setProps({ | ||
useDefaultMessage: false, | ||
defaultMessage: 'Some different default message', | ||
}); | ||
|
||
expect(editAction).not.toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters