Browse Source

test(js): Fix alerts/index.spec tests (#52015)

This test was simply wrong
Evan Purkhiser 1 year ago
parent
commit
b7773294bd
2 changed files with 43 additions and 16 deletions
  1. 0 16
      static/app/views/alerts/index.spec.jsx
  2. 43 0
      static/app/views/alerts/index.spec.tsx

+ 0 - 16
static/app/views/alerts/index.spec.jsx

@@ -1,16 +0,0 @@
-import {render} from 'sentry-test/reactTestingLibrary';
-
-import AlertsContainer from 'sentry/views/alerts';
-
-describe('AlertsContainer', function () {
-  describe('no access without feature flag', function () {
-    it('display no access message', function () {
-      const organization = TestStubs.Organization({projects: [TestStubs.Project()]});
-      const {container} = render(<AlertsContainer />, {
-        context: TestStubs.routerContext([{organization}]),
-        organization,
-      });
-      expect(container).toBeEmptyDOMElement();
-    });
-  });
-});

+ 43 - 0
static/app/views/alerts/index.spec.tsx

@@ -0,0 +1,43 @@
+import {render, screen} from 'sentry-test/reactTestingLibrary';
+
+import AlertsContainer from 'sentry/views/alerts';
+
+describe('AlertsContainer', function () {
+  function SubView({hasMetricAlerts}: {hasMetricAlerts?: boolean}) {
+    return <div>{hasMetricAlerts ? 'access' : 'no access'}</div>;
+  }
+
+  describe('no access without feature flag', function () {
+    it('display no access message', function () {
+      const organization = TestStubs.Organization();
+
+      render(
+        <AlertsContainer>
+          <SubView />
+        </AlertsContainer>,
+        {
+          context: TestStubs.routerContext([{organization}]),
+          organization,
+        }
+      );
+      expect(screen.getByText('no access')).toBeInTheDocument();
+    });
+
+    it('allows access', function () {
+      const organization = TestStubs.Organization({
+        features: ['incidents'],
+      });
+
+      render(
+        <AlertsContainer>
+          <SubView />
+        </AlertsContainer>,
+        {
+          context: TestStubs.routerContext([{organization}]),
+          organization,
+        }
+      );
+      expect(screen.getByText('access')).toBeInTheDocument();
+    });
+  });
+});