Skip to content

Commit

Permalink
Alerting: Fix UI inheriting mute timings from parent when calculating…
Browse files Browse the repository at this point in the history
… the polic… (grafana#79295)

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

* Add test for this use case
  • Loading branch information
soniaAguilarPeiron committed Dec 11, 2023
1 parent ce79bbb commit fdb4626
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MatcherOperator, Route, RouteWithID } from 'app/plugins/datasource/alertmanager/types';

import {
computeInheritedTree,
findMatchingRoutes,
normalizeRoute,
getInheritedProperties,
computeInheritedTree,
matchLabels,
normalizeRoute,
} from './notification-policies';

import 'core-js/stable/structured-clone';
Expand Down Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ function getInheritedProperties(
'group_wait',
'group_interval',
'repeat_interval',
'mute_time_intervals',
]);

// TODO how to solve this TypeScript mystery?
Expand Down

0 comments on commit fdb4626

Please sign in to comment.