Alerting: Fix invalid duration that causes Grafana to crash (#63753)
* Alerting: fix invalid alert duration * Return empty string from intervalToAbbreviatedDurationString * Alerting: add tests for invalid duration * tests intervalToAbbreviatedDurationString * Alerting: add missing isAfter import * durationutils.ts
This commit is contained in:
@@ -13,6 +13,12 @@ describe('Duration util', () => {
|
||||
const endDate = addDurationToDate(startDate, { months: 1, weeks: 1, days: 1, hours: 1, minutes: 1, seconds: 1 });
|
||||
expect(intervalToAbbreviatedDurationString({ start: startDate, end: endDate })).toEqual('1M 8d 1h 1m 1s');
|
||||
});
|
||||
|
||||
it('should return an empty string if start date is after end date', () => {
|
||||
const endDate = new Date();
|
||||
const startDate = addDurationToDate(endDate, { minutes: 1 });
|
||||
expect(intervalToAbbreviatedDurationString({ start: startDate, end: endDate })).toEqual('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseDuration', () => {
|
||||
|
||||
Reference in New Issue
Block a user