[8.16] [ResponseOps] Snooze Scheduler UX for recurring snoozes shows incorrect summary (#214797) (#215463)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[ResponseOps] Snooze Scheduler UX for recurring snoozes shows
incorrect summary
(#214797)](https://github.com/elastic/kibana/pull/214797)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT
[{"author":{"name":"Julia","email":"iuliia.guskova@elastic.co"},"sourceCommit":{"committedDate":"2025-03-21T10:47:28Z","message":"[ResponseOps]
Snooze Scheduler UX for recurring snoozes shows incorrect summary
(#214797)\n\nSolves:
https://github.com/elastic/kibana/issues/210119\n\n## Summary\n\nHow to
test:\nReproduce bug from an issue. But create a rule in Stack
management.\nAction is not needed. You can test it on
main.\n![Screenshot 2025-03-19 at 20
43\n09](https://github.com/user-attachments/assets/2b311a28-c474-4883-8f75-34f9de87a493)\n\n![Screenshot
2025-03-19 at 20
46\n56](https://github.com/user-attachments/assets/894e26c6-b298-40c2-9d6a-c5fd460300d2)\n\nWhen
you add new schedule and save it, you should see proper date here\nas
well:\n\n![Screenshot 2025-03-19 at 20
59\n53](https://github.com/user-attachments/assets/28239de4-ee99-4e51-a88a-ca78e5248f5f)\n\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"fdd872ada18ce7255cfac396a26dab46d9282dcb","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Alerting","release_note:skip","Team:ResponseOps","backport:version","v9.1.0","v8.19.0","v8.18.1","v8.16.6","v8.17.4"],"title":"[ResponseOps]
Snooze Scheduler UX for recurring snoozes shows incorrect summary
","number":214797,"url":"https://github.com/elastic/kibana/pull/214797","mergeCommit":{"message":"[ResponseOps]
Snooze Scheduler UX for recurring snoozes shows incorrect summary
(#214797)\n\nSolves:
https://github.com/elastic/kibana/issues/210119\n\n## Summary\n\nHow to
test:\nReproduce bug from an issue. But create a rule in Stack
management.\nAction is not needed. You can test it on
main.\n![Screenshot 2025-03-19 at 20
43\n09](https://github.com/user-attachments/assets/2b311a28-c474-4883-8f75-34f9de87a493)\n\n![Screenshot
2025-03-19 at 20
46\n56](https://github.com/user-attachments/assets/894e26c6-b298-40c2-9d6a-c5fd460300d2)\n\nWhen
you add new schedule and save it, you should see proper date here\nas
well:\n\n![Screenshot 2025-03-19 at 20
59\n53](https://github.com/user-attachments/assets/28239de4-ee99-4e51-a88a-ca78e5248f5f)\n\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"fdd872ada18ce7255cfac396a26dab46d9282dcb"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","8.18","8.16","8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214797","number":214797,"mergeCommit":{"message":"[ResponseOps]
Snooze Scheduler UX for recurring snoozes shows incorrect summary
(#214797)\n\nSolves:
https://github.com/elastic/kibana/issues/210119\n\n## Summary\n\nHow to
test:\nReproduce bug from an issue. But create a rule in Stack
management.\nAction is not needed. You can test it on
main.\n![Screenshot 2025-03-19 at 20
43\n09](https://github.com/user-attachments/assets/2b311a28-c474-4883-8f75-34f9de87a493)\n\n![Screenshot
2025-03-19 at 20
46\n56](https://github.com/user-attachments/assets/894e26c6-b298-40c2-9d6a-c5fd460300d2)\n\nWhen
you add new schedule and save it, you should see proper date here\nas
well:\n\n![Screenshot 2025-03-19 at 20
59\n53](https://github.com/user-attachments/assets/28239de4-ee99-4e51-a88a-ca78e5248f5f)\n\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"fdd872ada18ce7255cfac396a26dab46d9282dcb"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Julia <iuliia.guskova@elastic.co>
This commit is contained in:
Kibana Machine 2025-03-21 13:47:44 +01:00 committed by GitHub
parent 17b586094b
commit 5c7faae742
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 3 deletions

View file

@ -71,5 +71,22 @@ describe('Snooze panel helpers', () => {
})
).toEqual('Every month on the 4th Tuesday for 5 occurrences');
});
test('should capitalize first letter and display correct month for yearly recurrence', () => {
expect(
scheduleSummary({
id: null,
duration: 864000,
rRule: {
dtstart: NOW,
tzid: 'UTC',
freq: RRuleFrequency.YEARLY,
interval: 1,
bymonth: [3],
bymonthday: [21],
},
})
).toEqual('Every year on March 21');
});
});
});

View file

@ -133,6 +133,17 @@ describe('Recurrence scheduler helper', () => {
).toEqual('every month on the 4th Tuesday');
});
test('should display correct month name for yearly recurrence', () => {
expect(
recurrenceSummary({
freq: RRuleFrequency.YEARLY,
interval: 1,
bymonth: [3],
bymonthday: [18],
})
).toEqual('every year on March 18');
});
test('should give a basic msg', () => {
expect(
recurrenceSummary({
@ -280,7 +291,7 @@ describe('Recurrence scheduler helper', () => {
startDate: moment('11/23/2021'),
})
).toEqual({
bymonth: [10],
bymonth: [11],
bymonthday: [23],
byweekday: [],
freq: 0,

View file

@ -109,7 +109,11 @@ export const recurrenceSummary = ({
? i18n.translate('xpack.triggersActionsUI.ruleSnoozeScheduler.bymonthSummary', {
defaultMessage: 'on {date}',
values: {
date: i18nMonthDayDate(moment().month(bymonth[0]).date(bymonthday[0])),
date: i18nMonthDayDate(
moment()
.month(bymonth[0] - 1)
.date(bymonthday[0])
),
},
})
: null;
@ -179,7 +183,7 @@ export const buildCustomRecurrenceSchedulerState = ({
: [];
const bymonthday = useByMonthDay ? [startDate.date()] : [];
const bymonth = startDate && frequency === RRuleFrequency.YEARLY ? [startDate.month()] : [];
const bymonth = startDate && frequency === RRuleFrequency.YEARLY ? [startDate.month() + 1] : [];
return {
freq: frequency,
interval,