textRule.spec.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import {render} from 'sentry-test/reactTestingLibrary';
  2. import {
  3. TextAction,
  4. TextCondition,
  5. } from 'sentry/views/alerts/rules/issue/details/textRule';
  6. describe('AlertRuleDetails', () => {
  7. it('displays EventFrequencyCondition percentage', () => {
  8. const wrapper = render(
  9. <TextCondition
  10. condition={{
  11. comparisonType: 'count',
  12. id: 'sentry.rules.conditions.event_frequency.EventFrequencyCondition',
  13. interval: '1h',
  14. name: 'The issue is seen more than 1000 times in 1h',
  15. value: 1000,
  16. // TODO(scttcper): label and prompt only exist in the type definition
  17. label: '',
  18. prompt: '',
  19. }}
  20. />
  21. );
  22. expect(wrapper.container).toHaveTextContent(
  23. 'Number of events in an issue is more than 1000 in 1h'
  24. );
  25. });
  26. it('displays EventFrequencyCondition count', () => {
  27. const wrapper = render(
  28. <TextCondition
  29. condition={{
  30. comparisonInterval: '1w',
  31. comparisonType: 'percent',
  32. id: 'sentry.rules.conditions.event_frequency.EventFrequencyCondition',
  33. interval: '1h',
  34. name: 'The issue is seen more than 150 times in 1h',
  35. value: 150,
  36. // TODO(scttcper): label and prompt only exist in the type definition
  37. label: '',
  38. prompt: '',
  39. }}
  40. />
  41. );
  42. expect(wrapper.container).toHaveTextContent(
  43. 'Number of events in an issue is 150% higher in 1h compared to 1w ago'
  44. );
  45. });
  46. it('displays EventFrequencyPercentCondition count', () => {
  47. const wrapper = render(
  48. <TextCondition
  49. condition={{
  50. comparisonInterval: '1d',
  51. comparisonType: 'percent',
  52. id: 'sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition',
  53. interval: '1h',
  54. name: 'Percent of sessions affected by an issue is 150% higher in 1h compared to 1w ago',
  55. value: 150,
  56. // TODO(scttcper): label and prompt only exist in the type definition
  57. label: '',
  58. prompt: '',
  59. }}
  60. />
  61. );
  62. expect(wrapper.container).toHaveTextContent(
  63. 'Percent of sessions affected by an issue is 150% higher in 1h compared to 1d ago'
  64. );
  65. });
  66. it('displays EventUniqueUserFrequencyCondition count', () => {
  67. const wrapper = render(
  68. <TextCondition
  69. condition={{
  70. id: 'sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition',
  71. comparisonType: 'count',
  72. interval: '1d',
  73. name: 'The issue is seen by more than 89 users in 1d',
  74. value: 89,
  75. }}
  76. />
  77. );
  78. expect(wrapper.container).toHaveTextContent(
  79. 'Number of users affected by an issue is more than 89 in 1d'
  80. );
  81. });
  82. it('hides slack id and empty tags', () => {
  83. const wrapper = render(
  84. <TextAction
  85. action={{
  86. id: 'sentry.integrations.slack.notify_action.SlackNotifyServiceAction',
  87. name: 'Send a notification to the Sentry Slack workspace to #my-channel (optionally, an ID: ) and show tags [] in notification',
  88. // TODO(scttcper): label and prompt only exist in the type definition
  89. label: '',
  90. prompt: '',
  91. }}
  92. memberList={[]}
  93. teams={[]}
  94. />
  95. );
  96. expect(wrapper.container).toHaveTextContent(
  97. 'Send a notification to the Sentry Slack workspace to #my-channel'
  98. );
  99. });
  100. it('shows slack tags', () => {
  101. const wrapper = render(
  102. <TextAction
  103. action={{
  104. id: 'sentry.integrations.slack.notify_action.SlackNotifyServiceAction',
  105. name: 'Send a notification to the Sentry Slack workspace to #my-channel (optionally, an ID: ) and show tags [tag1, tag2] in notification',
  106. // TODO(scttcper): label and prompt only exist in the type definition
  107. label: '',
  108. prompt: '',
  109. }}
  110. memberList={[]}
  111. teams={[]}
  112. />
  113. );
  114. expect(wrapper.container).toHaveTextContent(
  115. 'Send a notification to the Sentry Slack workspace to #my-channel and show tags [tag1, tag2] in notification'
  116. );
  117. });
  118. });