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

Solves: https://github.com/elastic/kibana/issues/210119

## Summary

How to test:
Reproduce bug from an issue. But create a rule in Stack management.
Action is not needed. You can test it on main.
![Screenshot 2025-03-19 at 20 43
09](https://github.com/user-attachments/assets/2b311a28-c474-4883-8f75-34f9de87a493)

![Screenshot 2025-03-19 at 20 46
56](https://github.com/user-attachments/assets/894e26c6-b298-40c2-9d6a-c5fd460300d2)

When you add new schedule and save it, you should see proper date here
as well:

![Screenshot 2025-03-19 at 20 59
53](https://github.com/user-attachments/assets/28239de4-ee99-4e51-a88a-ca78e5248f5f)


### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [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
This commit is contained in:
Julia 2025-03-21 11:47:28 +01:00 committed by GitHub
parent 18aa055a6a
commit fdd872ada1
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,