@@ -1693,6 +1693,47 @@ def test_metric_alert_limit_unlimited_plan(self) -> None:
1693
1693
alert_rule = AlertRule .objects .get (id = resp .data ["id" ])
1694
1694
assert alert_rule .name == "JustAValidTestRule"
1695
1695
1696
+ def test_eap_alert_with_invalid_time_window (self ) -> None :
1697
+ data = deepcopy (self .alert_rule_dict )
1698
+ data ["dataset" ] = "events_analytics_platform"
1699
+ data ["alertType" ] = "eap_metrics"
1700
+ data ["timeWindow" ] = 1
1701
+ with self .feature (["organizations:incidents" , "organizations:performance-view" ]):
1702
+ resp = self .get_error_response (self .organization .slug , status_code = 400 , ** data )
1703
+ assert (
1704
+ resp .data ["nonFieldErrors" ][0 ]
1705
+ == "Invalid Time Window: Time window for this alert type must be at least 5 minutes."
1706
+ )
1707
+
1708
+ def test_transactions_dataset_deprecation_validation (self ) -> None :
1709
+ data = deepcopy (self .alert_rule_dict )
1710
+ data ["dataset" ] = "transactions"
1711
+ data ["alertType" ] = "performance"
1712
+
1713
+ with self .feature (
1714
+ ["organizations:incidents" , "organizations:discover-saved-queries-deprecation" ]
1715
+ ):
1716
+ resp = self .get_error_response (self .organization .slug , status_code = 400 , ** data )
1717
+ assert (
1718
+ resp .data ["dataset" ][0 ]
1719
+ == "The transactions dataset is being deprecated. Please use the 'events_analytics_platform' dataset with the `is_transaction:true` filter instead."
1720
+ )
1721
+
1722
+ def test_generic_metrics_dataset_deprecation_validation (self ) -> None :
1723
+ data = deepcopy (self .alert_rule_dict )
1724
+ data ["dataset" ] = "generic_metrics"
1725
+ data ["alertType" ] = "performance"
1726
+ data ["aggregate" ] = "p95(transaction.duration)"
1727
+
1728
+ with self .feature (
1729
+ ["organizations:incidents" , "organizations:discover-saved-queries-deprecation" ]
1730
+ ):
1731
+ resp = self .get_error_response (self .organization .slug , status_code = 400 , ** data )
1732
+ assert (
1733
+ resp .data ["dataset" ][0 ]
1734
+ == "The generic_metrics dataset is being deprecated. Please use the 'events_analytics_platform' dataset with the `is_transaction:true` filter instead."
1735
+ )
1736
+
1696
1737
1697
1738
@freeze_time ()
1698
1739
class AlertRuleCreateEndpointTestCrashRateAlert (AlertRuleIndexBase ):
@@ -1821,18 +1862,6 @@ def test_crash_rate_alerts_kicks_off_slack_async_job(
1821
1862
}
1822
1863
mock_find_channel_id_for_alert_rule .assert_called_once_with (kwargs = kwargs )
1823
1864
1824
- def test_eap_alert_with_invalid_time_window (self ) -> None :
1825
- data = deepcopy (self .alert_rule_dict )
1826
- data ["dataset" ] = "events_analytics_platform"
1827
- data ["alertType" ] = "eap_metrics"
1828
- data ["timeWindow" ] = 1
1829
- with self .feature (["organizations:incidents" , "organizations:performance-view" ]):
1830
- resp = self .get_error_response (self .organization .slug , status_code = 400 , ** data )
1831
- assert (
1832
- resp .data ["nonFieldErrors" ][0 ]
1833
- == "Invalid Time Window: Time window for this alert type must be at least 5 minutes."
1834
- )
1835
-
1836
1865
1837
1866
@freeze_time ()
1838
1867
class MetricsCrashRateAlertCreationTest (AlertRuleCreateEndpointTestCrashRateAlert ):
0 commit comments