alertLastIncidentActivationInfo.spec.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import {IncidentFixture} from 'sentry-fixture/incident';
  2. import {MetricRuleFixture} from 'sentry-fixture/metricRule';
  3. import {ProjectAlertRuleFixture} from 'sentry-fixture/projectAlertRule';
  4. import {UptimeRuleFixture} from 'sentry-fixture/uptimeRule';
  5. import {render, screen} from 'sentry-test/reactTestingLibrary';
  6. import AlertLastIncidentActivationInfo from 'sentry/views/alerts/list/rules/alertLastIncidentActivationInfo';
  7. import {CombinedAlertType, IncidentStatus} from 'sentry/views/alerts/types';
  8. describe('AlertLastIncidentActivationInfo', function () {
  9. it('Renders non-triggered issue alert correctly', function () {
  10. const rule = {
  11. ...ProjectAlertRuleFixture(),
  12. type: CombinedAlertType.ISSUE,
  13. } as const;
  14. render(<AlertLastIncidentActivationInfo rule={rule} />);
  15. expect(screen.getByText('Alert not triggered yet')).toBeInTheDocument();
  16. });
  17. it('Renders triggered issue alert correctly', function () {
  18. const rule = {
  19. ...ProjectAlertRuleFixture({
  20. lastTriggered: '2017-10-17T00:00:00.000Z',
  21. }),
  22. type: CombinedAlertType.ISSUE,
  23. } as const;
  24. const {container} = render(<AlertLastIncidentActivationInfo rule={rule} />);
  25. expect(container).toHaveTextContent('Triggered 3 hours ago');
  26. });
  27. it('Renders non-triggered metric alerts', function () {
  28. const rule = {
  29. ...MetricRuleFixture(),
  30. type: CombinedAlertType.METRIC,
  31. } as const;
  32. render(<AlertLastIncidentActivationInfo rule={rule} />);
  33. expect(screen.getByText('Alert not triggered yet')).toBeInTheDocument();
  34. });
  35. it('Renders triggered metric alert incidents', function () {
  36. const rule = {
  37. ...MetricRuleFixture({
  38. latestIncident: IncidentFixture({
  39. status: IncidentStatus.CRITICAL,
  40. dateCreated: '2017-10-17T00:00:00.000Z',
  41. }),
  42. }),
  43. type: CombinedAlertType.METRIC,
  44. } as const;
  45. const {container} = render(<AlertLastIncidentActivationInfo rule={rule} />);
  46. expect(container).toHaveTextContent('Triggered 3 hours ago');
  47. });
  48. it('Renders uptime alerts', function () {
  49. const rule = {
  50. ...UptimeRuleFixture(),
  51. type: CombinedAlertType.UPTIME,
  52. } as const;
  53. render(<AlertLastIncidentActivationInfo rule={rule} />);
  54. expect(screen.getByText('Actively monitoring every 1 minute')).toBeInTheDocument();
  55. });
  56. });