traceTree.shape.spec.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import {TraceShape, TraceTree} from './traceTree';
  2. import {makeTrace, makeTraceError, makeTransaction} from './traceTreeTestUtils';
  3. describe('TraceTree', () => {
  4. it('empty trace', () => {
  5. const tree = TraceTree.FromTrace(
  6. makeTrace({
  7. transactions: [],
  8. orphan_errors: [],
  9. }),
  10. {replay: null, meta: null}
  11. );
  12. expect(tree.shape).toBe(TraceShape.EMPTY_TRACE);
  13. });
  14. it('no root', () => {
  15. const tree = TraceTree.FromTrace(
  16. makeTrace({
  17. transactions: [
  18. makeTransaction({
  19. children: [],
  20. }),
  21. makeTransaction({
  22. children: [],
  23. }),
  24. ],
  25. orphan_errors: [],
  26. }),
  27. {replay: null, meta: null}
  28. );
  29. expect(tree.shape).toBe(TraceShape.NO_ROOT);
  30. });
  31. it('one root', () => {
  32. const tree = TraceTree.FromTrace(
  33. makeTrace({
  34. transactions: [
  35. makeTransaction({
  36. parent_span_id: null,
  37. children: [],
  38. }),
  39. ],
  40. orphan_errors: [],
  41. }),
  42. {replay: null, meta: null}
  43. );
  44. expect(tree.shape).toBe(TraceShape.ONE_ROOT);
  45. });
  46. it('broken subtrees', () => {
  47. const tree = TraceTree.FromTrace(
  48. makeTrace({
  49. transactions: [
  50. makeTransaction({
  51. parent_span_id: null,
  52. children: [],
  53. }),
  54. makeTransaction({
  55. children: [],
  56. }),
  57. ],
  58. orphan_errors: [],
  59. }),
  60. {replay: null, meta: null}
  61. );
  62. expect(tree.shape).toBe(TraceShape.BROKEN_SUBTRACES);
  63. });
  64. it('browser multiple roots shape', () => {
  65. const tree = TraceTree.FromTrace(
  66. makeTrace({
  67. transactions: [
  68. makeTransaction({sdk_name: 'javascript', parent_span_id: null}),
  69. makeTransaction({sdk_name: 'javascript', parent_span_id: null}),
  70. ],
  71. orphan_errors: [],
  72. }),
  73. {replay: null, meta: null}
  74. );
  75. expect(tree.shape).toBe(TraceShape.BROWSER_MULTIPLE_ROOTS);
  76. });
  77. it('multiple roots', () => {
  78. const tree = TraceTree.FromTrace(
  79. makeTrace({
  80. transactions: [
  81. makeTransaction({
  82. parent_span_id: null,
  83. children: [],
  84. }),
  85. makeTransaction({
  86. parent_span_id: null,
  87. children: [],
  88. }),
  89. ],
  90. orphan_errors: [],
  91. }),
  92. {replay: null, meta: null}
  93. );
  94. expect(tree.shape).toBe(TraceShape.MULTIPLE_ROOTS);
  95. });
  96. it('only errors', () => {
  97. const tree = TraceTree.FromTrace(
  98. makeTrace({
  99. transactions: [],
  100. orphan_errors: [makeTraceError()],
  101. }),
  102. {replay: null, meta: null}
  103. );
  104. expect(tree.shape).toBe(TraceShape.ONLY_ERRORS);
  105. });
  106. });