header.spec.tsx 1.3 KB

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