parentAutogroupNode.spec.tsx 1.9 KB

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