index.spec.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {Organization} from 'sentry-fixture/organization';
  2. import RouterContextFixture from 'sentry-fixture/routerContextFixture';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import AlertsContainer from 'sentry/views/alerts';
  5. describe('AlertsContainer', function () {
  6. function SubView({hasMetricAlerts}: {hasMetricAlerts?: boolean}) {
  7. return <div>{hasMetricAlerts ? 'access' : 'no access'}</div>;
  8. }
  9. describe('no access without feature flag', function () {
  10. it('display no access message', function () {
  11. const organization = Organization();
  12. render(
  13. <AlertsContainer>
  14. <SubView />
  15. </AlertsContainer>,
  16. {
  17. context: RouterContextFixture([{organization}]),
  18. organization,
  19. }
  20. );
  21. expect(screen.getByText('no access')).toBeInTheDocument();
  22. });
  23. it('allows access', function () {
  24. const organization = Organization({
  25. features: ['incidents'],
  26. });
  27. render(
  28. <AlertsContainer>
  29. <SubView />
  30. </AlertsContainer>,
  31. {
  32. context: RouterContextFixture([{organization}]),
  33. organization,
  34. }
  35. );
  36. expect(screen.getByText('access')).toBeInTheDocument();
  37. });
  38. });
  39. });