textRule.spec.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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: '1h',
  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 1h ago'
  44. );
  45. });
  46. it('displays EventFrequencyPercentCondition count', () => {
  47. const wrapper = render(
  48. <TextCondition
  49. condition={{
  50. comparisonInterval: '1h',
  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 1h 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 1h ago'
  64. );
  65. });
  66. it('hides slack id and empty tags', () => {
  67. const wrapper = render(
  68. <TextAction
  69. action={{
  70. id: 'sentry.integrations.slack.notify_action.SlackNotifyServiceAction',
  71. name: 'Send a notification to the Sentry Slack workspace to #my-channel (optionally, an ID: ) and show tags [] in notification',
  72. // TODO(scttcper): label and prompt only exist in the type definition
  73. label: '',
  74. prompt: '',
  75. }}
  76. memberList={[]}
  77. teams={[]}
  78. />
  79. );
  80. expect(wrapper.container).toHaveTextContent(
  81. 'Send a notification to the Sentry Slack workspace to #my-channel'
  82. );
  83. });
  84. it('shows slack tags', () => {
  85. const wrapper = render(
  86. <TextAction
  87. action={{
  88. id: 'sentry.integrations.slack.notify_action.SlackNotifyServiceAction',
  89. name: 'Send a notification to the Sentry Slack workspace to #my-channel (optionally, an ID: ) and show tags [tag1, tag2] in notification',
  90. // TODO(scttcper): label and prompt only exist in the type definition
  91. label: '',
  92. prompt: '',
  93. }}
  94. memberList={[]}
  95. teams={[]}
  96. />
  97. );
  98. expect(wrapper.container).toHaveTextContent(
  99. 'Send a notification to the Sentry Slack workspace to #my-channel and show tags [tag1, tag2] in notification'
  100. );
  101. });
  102. });