Browse Source

fix(alerts): Fix message for percent of sessions issue alert (#42750)

WOR-2490
Snigdha Sharma 2 years ago
parent
commit
be5e79951b

+ 22 - 0
static/app/views/alerts/rules/issue/details/textRule.spec.tsx

@@ -44,4 +44,26 @@ describe('AlertRuleDetails', () => {
       'Number of events in an issue is 150% higher in 1h compared to 1h ago'
     );
   });
+
+  it('displays EventFrequencyPercentCondition count', () => {
+    const wrapper = render(
+      <TextCondition
+        condition={{
+          comparisonInterval: '1h',
+          comparisonType: 'percent',
+          id: 'sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition',
+          interval: '1h',
+          name: 'Percent of sessions affected by an issue is 150% higher in 1h compared to 1h ago',
+          value: 150,
+
+          // TODO(scttcper): label and prompt only exist in the type definition
+          label: '',
+          prompt: '',
+        }}
+      />
+    );
+    expect(wrapper.container).toHaveTextContent(
+      'Percent of sessions affected by an issue is 150% higher in 1h compared to 1h ago'
+    );
+  });
 });

+ 15 - 0
static/app/views/alerts/rules/issue/details/textRule.tsx

@@ -5,6 +5,7 @@ import type {Member, Team} from 'sentry/types';
 import type {IssueAlertRule} from 'sentry/types/alerts';
 import {AlertRuleComparisonType} from 'sentry/views/alerts/rules/metric/types';
 import {CHANGE_ALERT_CONDITION_IDS} from 'sentry/views/alerts/utils/constants';
+import {EVENT_FREQUENCY_PERCENT_CONDITION} from 'sentry/views/projectInstall/issueAlertOptions';
 
 /**
  * Translate Issue Alert Conditions to text
@@ -16,6 +17,20 @@ export function TextCondition({
 }) {
   if (CHANGE_ALERT_CONDITION_IDS.includes(condition.id)) {
     if (condition.comparisonType === AlertRuleComparisonType.PERCENT) {
+      if (condition.id === EVENT_FREQUENCY_PERCENT_CONDITION) {
+        return (
+          <Fragment>
+            {t(
+              // Double %% escapes
+              'Percent of sessions affected by an issue is %s%% higher in %s compared to %s ago',
+              condition.value,
+              condition.comparisonInterval,
+              condition.interval
+            )}
+          </Fragment>
+        );
+      }
+
       return (
         <Fragment>
           {t(