groupingVariant.spec.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import {render, screen, within} from 'sentry-test/reactTestingLibrary';
  2. import {EventGroupVariantType} from 'sentry/types';
  3. import GroupingVariant from './groupingVariant';
  4. describe('Grouping Variant', () => {
  5. const event = {
  6. ...TestStubs.Event(),
  7. entries: [
  8. {
  9. type: 'spans',
  10. data: [
  11. {
  12. span_id: '1',
  13. hash: 'hash1',
  14. },
  15. {
  16. span_id: '2',
  17. hash: 'hash2',
  18. },
  19. ],
  20. },
  21. ],
  22. };
  23. const occurrenceEvent = {
  24. ...event,
  25. occurrence: {
  26. fingerprint: ['test-fingerprint'],
  27. evidenceData: {
  28. op: 'db',
  29. offenderSpanIds: ['2'],
  30. causeSpanIds: ['1'],
  31. parentSpanIds: [],
  32. },
  33. },
  34. };
  35. const performanceIssueVariant = {
  36. type: EventGroupVariantType.PERFORMANCE_PROBLEM,
  37. description: 'performance issue',
  38. hash: 'hash3',
  39. hashMismatch: false,
  40. key: 'perf-issue',
  41. evidence: {
  42. desc: 'performance issue',
  43. fingerprint: 'a',
  44. cause_span_ids: ['1'],
  45. offender_span_ids: ['2'],
  46. parent_span_ids: [],
  47. },
  48. };
  49. it('renders the span hashes for performance issues from event data', () => {
  50. render(
  51. <GroupingVariant
  52. showGroupingConfig={false}
  53. variant={performanceIssueVariant}
  54. event={event}
  55. />
  56. );
  57. expect(
  58. within(screen.getByText('Parent Span Hashes').closest('tr') as HTMLElement)
  59. .getByText('[')
  60. .closest('td')
  61. ).toHaveTextContent('[]');
  62. expect(
  63. within(
  64. screen.getByText('Source Span Hashes').closest('tr') as HTMLElement
  65. ).getByText('hash1')
  66. ).toBeInTheDocument();
  67. expect(
  68. within(
  69. screen.getByText('Offender Span Hashes').closest('tr') as HTMLElement
  70. ).getByText('hash2')
  71. ).toBeInTheDocument();
  72. });
  73. it('renders grouping details for occurrence-backed performance issues', () => {
  74. render(
  75. <GroupingVariant
  76. showGroupingConfig={false}
  77. variant={performanceIssueVariant}
  78. event={occurrenceEvent}
  79. />
  80. );
  81. expect(
  82. within(screen.getByText('Parent Span Hashes').closest('tr') as HTMLElement)
  83. .getByText('[')
  84. .closest('td')
  85. ).toHaveTextContent('[]');
  86. expect(
  87. within(
  88. screen.getByText('Source Span Hashes').closest('tr') as HTMLElement
  89. ).getByText('hash1')
  90. ).toBeInTheDocument();
  91. expect(
  92. within(
  93. screen.getByText('Offender Span Hashes').closest('tr') as HTMLElement
  94. ).getByText('hash2')
  95. ).toBeInTheDocument();
  96. });
  97. });