combinedAlertBadge.spec.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {MetricRuleFixture} from 'sentry-fixture/metricRule';
  2. import {MetricRuleActivationFixture} from 'sentry-fixture/metricRuleActivation';
  3. import {ProjectAlertRuleFixture} from 'sentry-fixture/projectAlertRule';
  4. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  5. import {MonitorType} from 'sentry/types/alerts';
  6. import CombinedAlertBadge from 'sentry/views/alerts/list/rules/combinedAlertBadge';
  7. import {CombinedAlertType} from 'sentry/views/alerts/types';
  8. describe('CombinedAlertBadge', function () {
  9. it('Renders correctly for waiting metric alert rules', async function () {
  10. const rule = {
  11. ...MetricRuleFixture({monitorType: MonitorType.ACTIVATED}),
  12. // Cast here to inform typescript that this will always be a metric type rule
  13. type: CombinedAlertType.METRIC as CombinedAlertType.METRIC,
  14. };
  15. render(<CombinedAlertBadge rule={rule} />);
  16. await userEvent.hover(screen.getByTestId('alert-badge'));
  17. // Renders tooltip with correct text
  18. expect(
  19. await screen.findByText('Metric Alert Status: Ready to monitor')
  20. ).toBeInTheDocument();
  21. });
  22. it('Renders correctly for monitoring metric alert rules', async function () {
  23. const rule = {
  24. ...MetricRuleFixture({monitorType: MonitorType.ACTIVATED}),
  25. activations: [MetricRuleActivationFixture()],
  26. type: CombinedAlertType.METRIC as CombinedAlertType.METRIC,
  27. };
  28. render(<CombinedAlertBadge rule={rule} />);
  29. await userEvent.hover(screen.getByTestId('alert-badge'));
  30. // Renders tooltip with correct text
  31. expect(
  32. await screen.findByText('Metric Alert Status: Monitoring')
  33. ).toBeInTheDocument();
  34. });
  35. it('Renders correctly for metric alert rules', async function () {
  36. const rule = {
  37. ...MetricRuleFixture(),
  38. type: CombinedAlertType.METRIC as CombinedAlertType.METRIC,
  39. };
  40. render(<CombinedAlertBadge rule={rule} />);
  41. await userEvent.hover(screen.getByTestId('alert-badge'));
  42. // Renders tooltip with correct text
  43. expect(await screen.findByText('Metric Alert Status: Resolved')).toBeInTheDocument();
  44. });
  45. it('Renders correctly for issue alert rules', async function () {
  46. const rule = {
  47. ...ProjectAlertRuleFixture(),
  48. type: CombinedAlertType.ISSUE as CombinedAlertType.ISSUE,
  49. };
  50. render(<CombinedAlertBadge rule={rule} />);
  51. await userEvent.hover(screen.getByTestId('alert-badge'));
  52. // Renders tooltip with correct text
  53. expect(await screen.findByText('Issue Alert')).toBeInTheDocument();
  54. });
  55. });