Skip to content

Commit fdb4626

Browse files
Alerting: Fix UI inheriting mute timings from parent when calculating the polic… (grafana#79295)
* Fix UI inheriting mute timings from parent when calculating the policy tree properties * Add test for this use case
1 parent ce79bbb commit fdb4626

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

public/app/features/alerting/unified/components/notification-policies/Policy.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe('Policy', () => {
134134
expect(within(secondPolicy).getByTestId('label-matchers')).toHaveTextContent(/^region \= EMEA$/);
135135
expect(within(secondPolicy).queryByTestId('continue-matching')).not.toBeInTheDocument();
136136
expect(within(secondPolicy).queryByTestId('mute-timings')).not.toBeInTheDocument();
137-
expect(within(secondPolicy).getByTestId('inherited-properties')).toHaveTextContent('Inherited4 properties');
137+
expect(within(secondPolicy).getByTestId('inherited-properties')).toHaveTextContent('Inherited3 properties');
138138

139139
// third custom policy should be correct
140140
const thirdPolicy = customPolicies[2];

public/app/features/alerting/unified/utils/notification-policies.test.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { MatcherOperator, Route, RouteWithID } from 'app/plugins/datasource/alertmanager/types';
22

33
import {
4+
computeInheritedTree,
45
findMatchingRoutes,
5-
normalizeRoute,
66
getInheritedProperties,
7-
computeInheritedTree,
87
matchLabels,
8+
normalizeRoute,
99
} from './notification-policies';
1010

1111
import 'core-js/stable/structured-clone';
@@ -294,6 +294,21 @@ describe('getInheritedProperties()', () => {
294294
expect(childInherited).toHaveProperty('group_interval', '2m');
295295
});
296296
});
297+
it('should not inherit mute timings from parent route', () => {
298+
const parent: Route = {
299+
receiver: 'PARENT',
300+
group_by: ['parentLabel'],
301+
mute_time_intervals: ['Mon-Fri 09:00-17:00'],
302+
};
303+
304+
const child: Route = {
305+
receiver: 'CHILD',
306+
group_by: ['childLabel'],
307+
};
308+
309+
const childInherited = getInheritedProperties(parent, child);
310+
expect(childInherited).not.toHaveProperty('mute_time_intervals');
311+
});
297312
});
298313

299314
describe('computeInheritedTree', () => {

public/app/features/alerting/unified/utils/notification-policies.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ function getInheritedProperties(
169169
'group_wait',
170170
'group_interval',
171171
'repeat_interval',
172-
'mute_time_intervals',
173172
]);
174173

175174
// TODO how to solve this TypeScript mystery?

0 commit comments

Comments
 (0)