siblingAutogroupNode.spec.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import {
  2. makeNodeMetadata,
  3. makeSiblingAutogroup,
  4. makeSpan,
  5. } from 'sentry/views/performance/newTraceDetails/traceModels/traceTreeTestUtils';
  6. import {SiblingAutogroupNode} from './siblingAutogroupNode';
  7. import {TraceTreeNode} from './traceTreeNode';
  8. const start = new Date('2024-02-29T00:00:00Z').getTime() / 1e3;
  9. describe('SiblingAutogroupNode', () => {
  10. it('not expanded by default', () => {
  11. const node = new SiblingAutogroupNode(
  12. null,
  13. makeSiblingAutogroup({autogrouped_by: {op: 'op', description: 'description'}}),
  14. makeNodeMetadata()
  15. );
  16. expect(node.expanded).toBe(false);
  17. });
  18. it('segments', () => {
  19. const node = new SiblingAutogroupNode(
  20. null,
  21. makeSiblingAutogroup({autogrouped_by: {op: 'op', description: 'description'}}),
  22. makeNodeMetadata()
  23. );
  24. for (let i = 0; i < 5; i++) {
  25. node.children.push(
  26. new TraceTreeNode(
  27. node,
  28. makeSpan({
  29. description: 'span',
  30. op: 'db',
  31. start_timestamp: start + i,
  32. timestamp: start + i + 1,
  33. span_id: `span-${i}`,
  34. parent_span_id: node.value.span_id,
  35. }),
  36. makeNodeMetadata()
  37. )
  38. );
  39. }
  40. expect(node.autogroupedSegments).toEqual([[start * 1e3, 5000]]);
  41. });
  42. it('segments with gap', () => {
  43. const node = new SiblingAutogroupNode(
  44. null,
  45. makeSiblingAutogroup({autogrouped_by: {op: 'op', description: 'description'}}),
  46. makeNodeMetadata()
  47. );
  48. node.children.push(
  49. new TraceTreeNode(
  50. node,
  51. makeSpan({
  52. start_timestamp: start,
  53. timestamp: start + 1,
  54. }),
  55. makeNodeMetadata()
  56. )
  57. );
  58. node.children.push(
  59. new TraceTreeNode(
  60. node,
  61. makeSpan({
  62. start_timestamp: start + 2,
  63. timestamp: start + 3,
  64. }),
  65. makeNodeMetadata()
  66. )
  67. );
  68. expect(node.autogroupedSegments).toEqual([
  69. [start * 1e3, 1000],
  70. [start * 1e3 + 2000, 1000],
  71. ]);
  72. });
  73. });