index.spec.tsx 1.3 KB

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