Skip to content

Commit

Permalink
fix(anomaly detection): fix comparison type bug on edit (#76640)
Browse files Browse the repository at this point in the history
Previously, anomaly detection alerts would default to "Static" when
going to the edit page. Fix this so that the selected checkbox is
"Anomaly". Also fix the relevant test.
  • Loading branch information
mifu67 authored Aug 27, 2024
1 parent faeb0ee commit 5121c5b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 0 additions & 5 deletions static/app/views/alerts/rules/metric/ruleForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ describe('Incident Rules Form', () => {
it('creates an anomaly detection rule', async () => {
organization.features = [...organization.features, 'anomaly-detection-alerts'];
const rule = MetricRuleFixture({
detectionType: AlertRuleComparisonType.PERCENT,
sensitivity: AlertRuleSensitivity.MEDIUM,
seasonality: AlertRuleSeasonality.AUTO,
});
Expand All @@ -372,10 +371,6 @@ describe('Incident Rules Form', () => {
dataset: 'events',
},
});
await userEvent.click(
screen.getByText('Anomaly: whenever values are outside of expected bounds')
);

expect(
await screen.findByLabelText(
'Anomaly: whenever values are outside of expected bounds'
Expand Down
7 changes: 5 additions & 2 deletions static/app/views/alerts/rules/metric/ruleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,16 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
metricExtractionRules: null,
triggers: triggersClone,
resolveThreshold: rule.resolveThreshold,
sensitivity: null,
sensitivity: rule.sensitivity ?? undefined,
seasonality: rule.seasonality ?? undefined,
thresholdType: rule.thresholdType,
thresholdPeriod: rule.thresholdPeriod ?? 1,
comparisonDelta: rule.comparisonDelta ?? undefined,
comparisonType: rule.comparisonDelta
? AlertRuleComparisonType.CHANGE
: AlertRuleComparisonType.COUNT,
: rule.sensitivity
? AlertRuleComparisonType.DYNAMIC
: AlertRuleComparisonType.COUNT,
project: this.props.project,
owner: rule.owner,
alertType: getAlertTypeFromAggregateDataset({aggregate, dataset}),
Expand Down

0 comments on commit 5121c5b

Please sign in to comment.