combinedAlertBadge.spec.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import {MetricRuleFixture} from 'sentry-fixture/metricRule';
  2. import {ProjectAlertRuleFixture} from 'sentry-fixture/projectAlertRule';
  3. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  4. import CombinedAlertBadge from 'sentry/views/alerts/list/rules/combinedAlertBadge';
  5. import {CombinedAlertType} from 'sentry/views/alerts/types';
  6. describe('CombinedAlertBadge', function () {
  7. it('Renders correctly for metric alert rules', async function () {
  8. const rule = {
  9. ...MetricRuleFixture(),
  10. type: CombinedAlertType.METRIC as CombinedAlertType.METRIC,
  11. };
  12. render(<CombinedAlertBadge rule={rule} />);
  13. await userEvent.hover(screen.getByTestId('alert-badge'));
  14. // Renders tooltip with correct text
  15. expect(await screen.findByText('Metric Alert Status: Resolved')).toBeInTheDocument();
  16. });
  17. it('Renders correctly for issue alert rules', async function () {
  18. const rule = {
  19. ...ProjectAlertRuleFixture(),
  20. type: CombinedAlertType.ISSUE as CombinedAlertType.ISSUE,
  21. };
  22. render(<CombinedAlertBadge rule={rule} />);
  23. await userEvent.hover(screen.getByTestId('alert-badge'));
  24. // Renders tooltip with correct text
  25. expect(await screen.findByText('Issue Alert')).toBeInTheDocument();
  26. });
  27. });