index.spec.tsx 1.2 KB

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