Browse Source

ref(ts): Remove usage of `TestStubs.Incident` (#62327)

2EZ.

- Replace `TestStubs.Incident` with import
- Use full `MetricRule` fixture

getsentry/frontend-tsc#49
George Gritsouk 1 year ago
parent
commit
2a85b7454a
1 changed files with 10 additions and 8 deletions
  1. 10 8
      static/app/views/alerts/rules/metric/details/utils.spec.tsx

+ 10 - 8
static/app/views/alerts/rules/metric/details/utils.spec.tsx

@@ -1,5 +1,7 @@
 import MockDate from 'mockdate';
 import moment from 'moment';
+import {Incident as IncidentFixture} from 'sentry-fixture/incident';
+import {MetricRule as MetricRuleFixture} from 'sentry-fixture/metricRule';
 
 import {buildMetricGraphDateRange} from 'sentry/views/alerts/rules/metric/details/utils';
 
@@ -14,10 +16,10 @@ describe('buildMetricGraphDateRange', () => {
   });
 
   it('should use current date for an active alert', () => {
-    const incident = TestStubs.Incident({
+    const incident = IncidentFixture({
       dateStarted: '2022-05-16T18:55:00Z',
       dateClosed: null,
-      alertRule: {timeWindow: 1},
+      alertRule: MetricRuleFixture({timeWindow: 1}),
     });
     const result = buildMetricGraphDateRange(incident);
     expect(result).toEqual({start: '2022-05-16T17:40:00', end: now});
@@ -25,10 +27,10 @@ describe('buildMetricGraphDateRange', () => {
   });
 
   it('should use current date for a recently closed alert', () => {
-    const incident = TestStubs.Incident({
+    const incident = IncidentFixture({
       dateStarted: '2022-05-16T18:55:00Z',
       dateClosed: '2022-05-16T18:57:00Z',
-      alertRule: {timeWindow: 1},
+      alertRule: MetricRuleFixture({timeWindow: 1}),
     });
     const result = buildMetricGraphDateRange(incident);
     expect(result).toEqual({start: '2022-05-16T17:40:00', end: now});
@@ -37,10 +39,10 @@ describe('buildMetricGraphDateRange', () => {
 
   it('should use a past date for an older alert', () => {
     // Incident is from over a week ago
-    const incident = TestStubs.Incident({
+    const incident = IncidentFixture({
       dateStarted: '2022-05-04T18:55:00Z',
       dateClosed: '2022-05-04T18:57:00Z',
-      alertRule: {timeWindow: 1},
+      alertRule: MetricRuleFixture({timeWindow: 1}),
     });
     const result = buildMetricGraphDateRange(incident);
     expect(result).toEqual({end: '2022-05-04T20:12:00', start: '2022-05-04T17:40:00'});
@@ -48,11 +50,11 @@ describe('buildMetricGraphDateRange', () => {
   });
 
   it('should handle large time windows', () => {
-    const incident = TestStubs.Incident({
+    const incident = IncidentFixture({
       dateStarted: '2022-04-20T20:28:00Z',
       dateClosed: null,
       // 1 day time window
-      alertRule: {timeWindow: 1440},
+      alertRule: MetricRuleFixture({timeWindow: 1440}),
     });
     const result = buildMetricGraphDateRange(incident);
     expect(result).toEqual({start: '2022-02-04T20:28:00', end: now});