From 5fbca0962ea3acf2dd5fb91c7a0d8e4f1dcbade9 Mon Sep 17 00:00:00 2001 From: Tom Ratcliffe Date: Tue, 26 Mar 2024 15:58:42 +0000 Subject: [PATCH] Fix import/export messing with Policy tests --- public/app/features/alerting/unified/RuleList.tsx | 2 +- .../unified/components/rules/RuleActionsButtons.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/public/app/features/alerting/unified/RuleList.tsx b/public/app/features/alerting/unified/RuleList.tsx index 77b2391a5dd..d30b8936b06 100644 --- a/public/app/features/alerting/unified/RuleList.tsx +++ b/public/app/features/alerting/unified/RuleList.tsx @@ -33,7 +33,7 @@ const VIEWS = { }; // make sure we ask for 1 more so we show the "show x more" button -export const LIMIT_ALERTS = INSTANCES_DISPLAY_LIMIT + 1; +const LIMIT_ALERTS = INSTANCES_DISPLAY_LIMIT + 1; const RuleList = withErrorBoundary( () => { diff --git a/public/app/features/alerting/unified/components/rules/RuleActionsButtons.tsx b/public/app/features/alerting/unified/components/rules/RuleActionsButtons.tsx index 7b643cbd415..1c42aa0bd18 100644 --- a/public/app/features/alerting/unified/components/rules/RuleActionsButtons.tsx +++ b/public/app/features/alerting/unified/components/rules/RuleActionsButtons.tsx @@ -17,8 +17,8 @@ import { Stack, } from '@grafana/ui'; import { useAppNotification } from 'app/core/copy/appNotification'; -import { LIMIT_ALERTS } from 'app/features/alerting/unified/RuleList'; import { alertRuleApi } from 'app/features/alerting/unified/api/alertRuleApi'; +import { INSTANCES_DISPLAY_LIMIT } from 'app/features/alerting/unified/components/rules/RuleDetails'; import { useRulesFilter } from 'app/features/alerting/unified/hooks/useFilteredRules'; import { useDispatch } from 'app/types'; import { CombinedRule, RuleIdentifier, RulesSource } from 'app/types/unified-alerting'; @@ -107,7 +107,9 @@ export const RuleActionsButtons = ({ rule, rulesSource }: Props) => { await updateRule({ nameSpaceUID: rule.namespace.uid!, payload }).unwrap(); - const limitAlerts = hasActiveFilters ? undefined : LIMIT_ALERTS; + // Uses INSTANCES_DISPLAY_LIMIT + 1 here as exporting LIMIT_ALERTS from RuleList has the side effect + // of breaking some unrelated tests in Policy.test.tsx due to mocking approach + const limitAlerts = hasActiveFilters ? undefined : INSTANCES_DISPLAY_LIMIT + 1; // Trigger a re-fetch of the rules table // TODO: Migrate rules table functionality to RTK Query, so we instead rely // on tag invalidation (or optimistic cache updates) for this