From 4ea85b7feb77cffd436ad2cf0353dc86672b2e92 Mon Sep 17 00:00:00 2001 From: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com> Date: Fri, 26 Sep 2025 08:28:33 +0200 Subject: [PATCH] Alerting: Fix threshold params (#111645) * fix threshold params * update tests --- .../components/__snapshots__/hysteresis.test.ts.snap | 2 -- public/app/features/expressions/components/hysteresis.test.ts | 2 +- public/app/features/expressions/components/thresholdReducer.ts | 3 +++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/app/features/expressions/components/__snapshots__/hysteresis.test.ts.snap b/public/app/features/expressions/components/__snapshots__/hysteresis.test.ts.snap index 452fcd7305a..6af902b384d 100644 --- a/public/app/features/expressions/components/__snapshots__/hysteresis.test.ts.snap +++ b/public/app/features/expressions/components/__snapshots__/hysteresis.test.ts.snap @@ -72,7 +72,6 @@ exports[`thresholdReducer should update Threshold Type, and unloadEvaluator para { "evaluator": { "params": [ - 10, 0, ], "type": "lt", @@ -90,7 +89,6 @@ exports[`thresholdReducer should update Threshold Type, and unloadEvaluator para "type": "query", "unloadEvaluator": { "params": [ - 10, 0, ], "type": "gt", diff --git a/public/app/features/expressions/components/hysteresis.test.ts b/public/app/features/expressions/components/hysteresis.test.ts index 7f802aa13f7..13a87d022e3 100644 --- a/public/app/features/expressions/components/hysteresis.test.ts +++ b/public/app/features/expressions/components/hysteresis.test.ts @@ -159,7 +159,7 @@ describe('thresholdReducer', () => { expect(newState.conditions[0].evaluator.type).toEqual(EvalFunction.IsBelow); expect(newState.conditions[0].unloadEvaluator?.type).toEqual(EvalFunction.IsAbove); expect(onError).toHaveBeenCalledWith(undefined); - expect(newState.conditions[0].unloadEvaluator?.params[0]).toEqual(10); + expect(newState.conditions[0].unloadEvaluator?.params[0]).toEqual(0); }); it('Should update unlooadEvaluator when checking hysteresis', () => { const initialState: ThresholdExpressionQuery = { diff --git a/public/app/features/expressions/components/thresholdReducer.ts b/public/app/features/expressions/components/thresholdReducer.ts index 503baa3e727..17ccf5d233b 100644 --- a/public/app/features/expressions/components/thresholdReducer.ts +++ b/public/app/features/expressions/components/thresholdReducer.ts @@ -33,6 +33,9 @@ export const thresholdReducer = createReducer( //set new type in evaluator state.conditions[0].evaluator.type = typeInPayload; + //reset params + state.conditions[0].evaluator.params = [0]; + // check if hysteresis is checked const hsyteresisIsChecked = Boolean(state.conditions[0].unloadEvaluator);