Browse Source

fix(ui) Don't show system health banners in sentry.io v2 (#62938)

Mulligan on #62879 which caused tests to fail post merge because of
semantic conflicts with other changes to self-hosted installation.
Mark Story 1 year ago
parent
commit
e47cc8c81f

+ 0 - 7
static/app/components/modals/commandPalette.spec.tsx

@@ -68,13 +68,6 @@ function renderMockRequests() {
     body: [],
   });
 
-  MockApiClient.addMockResponse({
-    url: '/internal/health/',
-    body: {
-      problems: [],
-    },
-  });
-
   MockApiClient.addMockResponse({
     url: '/assistant/',
     body: [],

+ 0 - 7
static/app/components/modals/helpSearchModal.spec.tsx

@@ -41,13 +41,6 @@ describe('Docs Search Modal', function () {
       body: [],
     });
 
-    MockApiClient.addMockResponse({
-      url: '/internal/health/',
-      body: {
-        problems: [],
-      },
-    });
-
     MockApiClient.addMockResponse({
       url: '/assistant/',
       body: [],

+ 0 - 6
static/app/components/modals/sudoModal.spec.tsx

@@ -21,12 +21,6 @@ describe('Sudo Modal', function () {
     };
 
     MockApiClient.clearMockResponses();
-    MockApiClient.addMockResponse({
-      url: '/internal/health/',
-      body: {
-        problems: [],
-      },
-    });
     MockApiClient.addMockResponse({
       url: '/assistant/',
       body: [],

+ 31 - 7
static/app/views/app/index.spec.tsx

@@ -20,13 +20,6 @@ describe('App', function () {
       body: [OrganizationFixture({slug: 'billy-org', name: 'billy org'})],
     });
 
-    MockApiClient.addMockResponse({
-      url: '/internal/health/',
-      body: {
-        problems: [],
-      },
-    });
-
     MockApiClient.addMockResponse({
       url: '/assistant/',
       body: [],
@@ -107,6 +100,13 @@ describe('App', function () {
     ConfigStore.set('needsUpgrade', true);
     ConfigStore.set('isSelfHosted', true);
 
+    MockApiClient.addMockResponse({
+      url: '/internal/health/',
+      body: {
+        problems: [],
+      },
+    });
+
     render(
       <App {...routerProps}>
         <div>placeholder content</div>
@@ -147,4 +147,28 @@ describe('App', function () {
     expect(window.location.replace).toHaveBeenCalledWith('https://sentry.io');
     expect(window.location.replace).toHaveBeenCalledTimes(1);
   });
+
+  it('adds health issues to alertstore', async function () {
+    const getMock = MockApiClient.addMockResponse({
+      url: '/internal/health/',
+      body: {
+        healthy: false,
+        problems: [
+          {id: 'abc123', message: 'Celery workers have not checked in', severity: 'critical'},
+        ],
+      },
+    });
+    const restore = ConfigStore.get('isSelfHosted');
+    ConfigStore.set('isSelfHosted', true);
+
+    render(
+      <App {...routerProps}>
+        <div>placeholder content</div>
+      </App>
+    );
+    ConfigStore.config.isSelfHosted = restore;
+
+    expect(getMock).toHaveBeenCalled();
+    expect(await screen.findByText(/Celery workers have not checked in/)).toBeInTheDocument();
+  });
 });

+ 5 - 1
static/app/views/app/index.tsx

@@ -88,6 +88,10 @@ function App({children, params}: Props) {
    * Creates Alerts for any internal health problems
    */
   const checkInternalHealth = useCallback(async () => {
+    // For saas deployments we have more robust ways of checking application health.
+    if (!config.isSelfHosted) {
+      return;
+    }
     let data: any = null;
 
     try {
@@ -102,7 +106,7 @@ function App({children, params}: Props) {
 
       AlertStore.addAlert({id, message, type, url, opaque: true});
     });
-  }, [api]);
+  }, [api, config.isSelfHosted]);
 
   const {sentryUrl} = ConfigStore.get('links');
   const {orgId} = params;

+ 0 - 6
static/app/views/settings/components/settingsLayout.spec.tsx

@@ -11,12 +11,6 @@ describe('SettingsLayout', function () {
 
   beforeEach(function () {
     MockApiClient.clearMockResponses();
-    MockApiClient.addMockResponse({
-      url: '/internal/health/',
-      body: {
-        problems: [],
-      },
-    });
     MockApiClient.addMockResponse({
       url: '/organizations/',
       body: [OrganizationFixture()],

+ 0 - 4
static/app/views/settings/project/projectTeams.spec.tsx

@@ -281,10 +281,6 @@ describe('ProjectTeams', function () {
   });
 
   it('creates a new team adds it to current project using the "create team modal" in dropdown', async function () {
-    MockApiClient.addMockResponse({
-      url: '/internal/health/',
-      body: {},
-    });
     MockApiClient.addMockResponse({
       url: '/assistant/',
       body: {},