traceTreeNode.spec.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import {
  2. makeSpan,
  3. makeTraceError,
  4. makeTracePerformanceIssue,
  5. makeTransaction,
  6. } from 'sentry/views/performance/newTraceDetails/traceModels/traceTreeTestUtils';
  7. import type {TraceTree} from '../traceModels/traceTree';
  8. import {TraceTreeNode} from './traceTreeNode';
  9. const metadata: TraceTree.Metadata = {
  10. event_id: '1',
  11. project_slug: 'node',
  12. };
  13. describe('TraceTreeNode', () => {
  14. it('infers space from timestamp and start_timestamp', () => {
  15. const node = new TraceTreeNode(null, makeTraceError({timestamp: 1}), metadata);
  16. expect(node.space).toEqual([1 * 1e3, 0]);
  17. });
  18. it('infers start_timestamp and timestamp when not provided', () => {
  19. const node = new TraceTreeNode(
  20. null,
  21. makeSpan({start_timestamp: 1, timestamp: 3}),
  22. metadata
  23. );
  24. expect(node.space).toEqual([1 * 1e3, 2 * 1e3]);
  25. });
  26. it('stores performance issue on node', () => {
  27. const issue = makeTracePerformanceIssue({issue_short_id: 'issue1'});
  28. const node = new TraceTreeNode(
  29. null,
  30. makeTransaction({
  31. start_timestamp: 1,
  32. timestamp: 3,
  33. performance_issues: [issue],
  34. }),
  35. metadata
  36. );
  37. expect(node.performance_issues.has(issue)).toBe(true);
  38. });
  39. it('stores error on node', () => {
  40. const issue = makeTraceError();
  41. const node = new TraceTreeNode(
  42. null,
  43. makeTransaction({
  44. start_timestamp: 1,
  45. timestamp: 3,
  46. errors: [issue],
  47. }),
  48. metadata
  49. );
  50. expect(node.errors.has(issue)).toBe(true);
  51. });
  52. it('a trace error is stored on node', () => {
  53. const node = new TraceTreeNode(null, makeTraceError(), metadata);
  54. expect(node.errors.size).toBe(1);
  55. });
  56. it('stores profile on node', () => {
  57. const node = new TraceTreeNode(
  58. null,
  59. makeTransaction({
  60. start_timestamp: 1,
  61. timestamp: 3,
  62. profile_id: 'profile',
  63. }),
  64. metadata
  65. );
  66. const profile = node.profiles[0] as {profile_id: string};
  67. expect(profile.profile_id).toBe('profile');
  68. });
  69. it('stores profiler_id on node', () => {
  70. const node = new TraceTreeNode(
  71. null,
  72. makeTransaction({
  73. start_timestamp: 1,
  74. timestamp: 3,
  75. profiler_id: 'profile',
  76. }),
  77. metadata
  78. );
  79. const profile = node.profiles[0] as {profiler_id: string};
  80. expect(profile.profiler_id).toBe('profile');
  81. });
  82. it('stores parent reference', () => {
  83. const parent = new TraceTreeNode(null, makeTransaction(), metadata);
  84. const child = new TraceTreeNode(parent, makeTransaction(), metadata);
  85. expect(child.parent).toBe(parent);
  86. });
  87. describe('maxSeverity', () => {
  88. it('fatal > info', () => {
  89. const node = new TraceTreeNode(
  90. null,
  91. makeTransaction({
  92. errors: [makeTraceError({level: 'fatal'})],
  93. performance_issues: [makeTracePerformanceIssue({level: 'info'})],
  94. }),
  95. metadata
  96. );
  97. expect(node.maxIssueSeverity).toBe('fatal');
  98. });
  99. });
  100. describe('expanding and collapsing', () => {
  101. it('default is expanded', () => {
  102. const node = new TraceTreeNode(null, makeTransaction(), metadata);
  103. expect(node.expanded).toBe(true);
  104. });
  105. it('android tcp connections are not expanded by default', () => {
  106. const node = new TraceTreeNode(
  107. null,
  108. makeSpan({op: 'http.client', origin: 'auto.http.okhttp'}),
  109. metadata
  110. );
  111. expect(node.expanded).toBe(false);
  112. });
  113. });
  114. });