header.spec.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import PageFiltersStore from 'sentry/stores/pageFiltersStore';
  4. import ProjectsStore from 'sentry/stores/projectsStore';
  5. import AlertHeader from 'sentry/views/alerts/list/header';
  6. describe('AlertHeader', () => {
  7. const project = TestStubs.Project();
  8. const {routerContext, organization} = initializeOrg();
  9. beforeEach(() => {
  10. PageFiltersStore.init();
  11. PageFiltersStore.onInitializeUrlState(
  12. {
  13. projects: [project.id],
  14. environments: [],
  15. datetime: {
  16. period: '7d',
  17. start: null,
  18. end: null,
  19. utc: null,
  20. },
  21. },
  22. new Set()
  23. );
  24. ProjectsStore.init();
  25. ProjectsStore.loadInitialData([project]);
  26. });
  27. it('should pass global selection project to create alert button', () => {
  28. render(<AlertHeader activeTab="stream" router={TestStubs.router()} />, {
  29. context: routerContext,
  30. organization,
  31. });
  32. expect(screen.getByRole('button', {name: 'Create Alert'})).toHaveAttribute(
  33. 'href',
  34. '/organizations/org-slug/alerts/wizard/?referrer=alert_stream&project=project-slug'
  35. );
  36. });
  37. });