index.spec.tsx 1.1 KB

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