Browse Source

ref(crons): Add test for processing error display (#71610)

Adds test and test-fixture
David Wang 9 months ago
parent
commit
58191847a3

+ 22 - 0
static/app/views/monitors/details.spec.tsx

@@ -1,3 +1,4 @@
+import {CheckinProcessingErrorFixture} from 'sentry-fixture/checkinProcessingError';
 import {MonitorFixture} from 'sentry-fixture/monitor';
 import {MonitorFixture} from 'sentry-fixture/monitor';
 
 
 import {initializeOrg} from 'sentry-test/initializeOrg';
 import {initializeOrg} from 'sentry-test/initializeOrg';
@@ -42,6 +43,13 @@ describe('Monitor Details', () => {
   it('renders', async function () {
   it('renders', async function () {
     render(<MonitorDetails {...routerProps} />);
     render(<MonitorDetails {...routerProps} />);
     expect(await screen.findByText(monitor.slug, {exact: false})).toBeInTheDocument();
     expect(await screen.findByText(monitor.slug, {exact: false})).toBeInTheDocument();
+
+    // Doesn't show processing errors
+    expect(
+      screen.queryByText(
+        'Errors were encountered while ingesting check-ins for this monitor'
+      )
+    ).not.toBeInTheDocument();
   });
   });
 
 
   it('renders error when monitor is not found', async function () {
   it('renders error when monitor is not found', async function () {
@@ -55,4 +63,18 @@ describe('Monitor Details', () => {
       await screen.findByText('The monitor you were looking for was not found.')
       await screen.findByText('The monitor you were looking for was not found.')
     ).toBeInTheDocument();
     ).toBeInTheDocument();
   });
   });
+
+  it('shows processing errors when they exist', async function () {
+    MockApiClient.addMockResponse({
+      url: `/projects/${organization.slug}/${project.slug}/monitors/${monitor.slug}/processing-errors/`,
+      body: [CheckinProcessingErrorFixture()],
+    });
+
+    render(<MonitorDetails {...routerProps} />);
+    expect(
+      await screen.findByText(
+        'Errors were encountered while ingesting check-ins for this monitor'
+      )
+    ).toBeInTheDocument();
+  });
 });
 });

+ 30 - 0
tests/js/fixtures/checkinProcessingError.ts

@@ -0,0 +1,30 @@
+import { CheckinProcessingError } from "sentry/views/monitors/types";
+
+export function CheckinProcessingErrorFixture(
+  params: Partial<CheckinProcessingError> = {}
+): CheckinProcessingError {
+  return {
+    id: '',
+    checkin: {
+      message: {
+        message_type: 'check_in',
+        payload: '',
+        project_id: 1,
+        retention_days: 90,
+        sdk: '',
+        start_time: 171659668,
+        type: 'check_in',
+      },
+      partition: 0,
+      payload: {
+        check_in_id: '',
+        environment: 'prod',
+        monitor_slug: '',
+        status: 'ok',
+      },
+      ts: '2024-05-25T00:24:29.739000',
+    },
+    errors: [{type: 1}],
+    ...params,
+  };
+}