Alerting: Fix UI inheriting mute timings from parent when calculating the polic… (#79295)

* Fix UI inheriting mute timings from parent when calculating the policy tree properties

* Add test for this use case
This commit is contained in:
Sonia Aguilar 2023-12-11 15:49:35 +01:00 committed by GitHub
parent ce79bbba87
commit fdb4626847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View File

@ -134,7 +134,7 @@ describe('Policy', () => {
expect(within(secondPolicy).getByTestId('label-matchers')).toHaveTextContent(/^region \= EMEA$/);
expect(within(secondPolicy).queryByTestId('continue-matching')).not.toBeInTheDocument();
expect(within(secondPolicy).queryByTestId('mute-timings')).not.toBeInTheDocument();
expect(within(secondPolicy).getByTestId('inherited-properties')).toHaveTextContent('Inherited4 properties');
expect(within(secondPolicy).getByTestId('inherited-properties')).toHaveTextContent('Inherited3 properties');
// third custom policy should be correct
const thirdPolicy = customPolicies[2];

View File

@ -1,11 +1,11 @@
import { MatcherOperator, Route, RouteWithID } from 'app/plugins/datasource/alertmanager/types';
import {
findMatchingRoutes,
normalizeRoute,
getInheritedProperties,
computeInheritedTree,
findMatchingRoutes,
getInheritedProperties,
matchLabels,
normalizeRoute,
} from './notification-policies';
import 'core-js/stable/structured-clone';
@ -294,6 +294,21 @@ describe('getInheritedProperties()', () => {
expect(childInherited).toHaveProperty('group_interval', '2m');
});
});
it('should not inherit mute timings from parent route', () => {
const parent: Route = {
receiver: 'PARENT',
group_by: ['parentLabel'],
mute_time_intervals: ['Mon-Fri 09:00-17:00'],
};
const child: Route = {
receiver: 'CHILD',
group_by: ['childLabel'],
};
const childInherited = getInheritedProperties(parent, child);
expect(childInherited).not.toHaveProperty('mute_time_intervals');
});
});
describe('computeInheritedTree', () => {

View File

@ -169,7 +169,6 @@ function getInheritedProperties(
'group_wait',
'group_interval',
'repeat_interval',
'mute_time_intervals',
]);
// TODO how to solve this TypeScript mystery?