@kylincloud/flamegraph 0.35.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/CHANGELOG.md +1211 -0
  2. package/LICENSE +202 -0
  3. package/README.md +251 -0
  4. package/dist/FlameGraph/FlameGraphComponent/CheckIcon.d.ts +2 -0
  5. package/dist/FlameGraph/FlameGraphComponent/CheckIcon.d.ts.map +1 -0
  6. package/dist/FlameGraph/FlameGraphComponent/ContextMenu.d.ts +17 -0
  7. package/dist/FlameGraph/FlameGraphComponent/ContextMenu.d.ts.map +1 -0
  8. package/dist/FlameGraph/FlameGraphComponent/ContextMenuHighlight.d.ts +14 -0
  9. package/dist/FlameGraph/FlameGraphComponent/ContextMenuHighlight.d.ts.map +1 -0
  10. package/dist/FlameGraph/FlameGraphComponent/DiffLegend.d.ts +9 -0
  11. package/dist/FlameGraph/FlameGraphComponent/DiffLegend.d.ts.map +1 -0
  12. package/dist/FlameGraph/FlameGraphComponent/DiffLegendPaletteDropdown.d.ts +8 -0
  13. package/dist/FlameGraph/FlameGraphComponent/DiffLegendPaletteDropdown.d.ts.map +1 -0
  14. package/dist/FlameGraph/FlameGraphComponent/Flamegraph.d.ts +96 -0
  15. package/dist/FlameGraph/FlameGraphComponent/Flamegraph.d.ts.map +1 -0
  16. package/dist/FlameGraph/FlameGraphComponent/Flamegraph_render.d.ts +27 -0
  17. package/dist/FlameGraph/FlameGraphComponent/Flamegraph_render.d.ts.map +1 -0
  18. package/dist/FlameGraph/FlameGraphComponent/GraphVizPane.d.ts +7 -0
  19. package/dist/FlameGraph/FlameGraphComponent/GraphVizPane.d.ts.map +1 -0
  20. package/dist/FlameGraph/FlameGraphComponent/Header.d.ts +12 -0
  21. package/dist/FlameGraph/FlameGraphComponent/Header.d.ts.map +1 -0
  22. package/dist/FlameGraph/FlameGraphComponent/Highlight.d.ts +18 -0
  23. package/dist/FlameGraph/FlameGraphComponent/Highlight.d.ts.map +1 -0
  24. package/dist/FlameGraph/FlameGraphComponent/LogoLink.d.ts +2 -0
  25. package/dist/FlameGraph/FlameGraphComponent/LogoLink.d.ts.map +1 -0
  26. package/dist/FlameGraph/FlameGraphComponent/color.d.ts +20 -0
  27. package/dist/FlameGraph/FlameGraphComponent/color.d.ts.map +1 -0
  28. package/dist/FlameGraph/FlameGraphComponent/colorPalette.d.ts +11 -0
  29. package/dist/FlameGraph/FlameGraphComponent/colorPalette.d.ts.map +1 -0
  30. package/dist/FlameGraph/FlameGraphComponent/constants.d.ts +6 -0
  31. package/dist/FlameGraph/FlameGraphComponent/constants.d.ts.map +1 -0
  32. package/dist/FlameGraph/FlameGraphComponent/index.d.ts +37 -0
  33. package/dist/FlameGraph/FlameGraphComponent/index.d.ts.map +1 -0
  34. package/dist/FlameGraph/FlameGraphComponent/murmur3.d.ts +2 -0
  35. package/dist/FlameGraph/FlameGraphComponent/murmur3.d.ts.map +1 -0
  36. package/dist/FlameGraph/FlameGraphComponent/testData.d.ts +53 -0
  37. package/dist/FlameGraph/FlameGraphComponent/testData.d.ts.map +1 -0
  38. package/dist/FlameGraph/FlameGraphComponent/utils.d.ts +6 -0
  39. package/dist/FlameGraph/FlameGraphComponent/utils.d.ts.map +1 -0
  40. package/dist/FlameGraph/FlameGraphComponent/viewTypes.d.ts +2 -0
  41. package/dist/FlameGraph/FlameGraphComponent/viewTypes.d.ts.map +1 -0
  42. package/dist/FlameGraph/FlameGraphRenderer.d.ts +86 -0
  43. package/dist/FlameGraph/FlameGraphRenderer.d.ts.map +1 -0
  44. package/dist/FlameGraph/decode.d.ts +27 -0
  45. package/dist/FlameGraph/decode.d.ts.map +1 -0
  46. package/dist/FlameGraph/normalize.d.ts +6 -0
  47. package/dist/FlameGraph/normalize.d.ts.map +1 -0
  48. package/dist/FlameGraph/uniqueness.d.ts +3 -0
  49. package/dist/FlameGraph/uniqueness.d.ts.map +1 -0
  50. package/dist/FlamegraphRenderer.d.ts +19 -0
  51. package/dist/FlamegraphRenderer.d.ts.map +1 -0
  52. package/dist/Icons.d.ts +9 -0
  53. package/dist/Icons.d.ts.map +1 -0
  54. package/dist/ProfilerTable.d.ts +21 -0
  55. package/dist/ProfilerTable.d.ts.map +1 -0
  56. package/dist/SharedQueryInput.d.ts +10 -0
  57. package/dist/SharedQueryInput.d.ts.map +1 -0
  58. package/dist/Toolbar.d.ts +31 -0
  59. package/dist/Toolbar.d.ts.map +1 -0
  60. package/dist/Tooltip/FlamegraphTooltip.d.ts +59 -0
  61. package/dist/Tooltip/FlamegraphTooltip.d.ts.map +1 -0
  62. package/dist/Tooltip/LeftClickIcon.d.ts +2 -0
  63. package/dist/Tooltip/LeftClickIcon.d.ts.map +1 -0
  64. package/dist/Tooltip/RightClickIcon.d.ts +2 -0
  65. package/dist/Tooltip/RightClickIcon.d.ts.map +1 -0
  66. package/dist/Tooltip/TableTooltip.d.ts +12 -0
  67. package/dist/Tooltip/TableTooltip.d.ts.map +1 -0
  68. package/dist/Tooltip/Tooltip.d.ts +29 -0
  69. package/dist/Tooltip/Tooltip.d.ts.map +1 -0
  70. package/dist/convert/convertJaegerTraceToProfile.d.ts +3 -0
  71. package/dist/convert/convertJaegerTraceToProfile.d.ts.map +1 -0
  72. package/dist/convert/diffTwoProfiles.d.ts +3 -0
  73. package/dist/convert/diffTwoProfiles.d.ts.map +1 -0
  74. package/dist/convert/flamebearersToTree.d.ts +11 -0
  75. package/dist/convert/flamebearersToTree.d.ts.map +1 -0
  76. package/dist/convert/sandwichViewProfiles.d.ts +14 -0
  77. package/dist/convert/sandwichViewProfiles.d.ts.map +1 -0
  78. package/dist/convert/subtract.d.ts +3 -0
  79. package/dist/convert/subtract.d.ts.map +1 -0
  80. package/dist/convert/testData.d.ts +50 -0
  81. package/dist/convert/testData.d.ts.map +1 -0
  82. package/dist/convert/toGraphviz.d.ts +3 -0
  83. package/dist/convert/toGraphviz.d.ts.map +1 -0
  84. package/dist/fitMode/fitMode.d.ts +42 -0
  85. package/dist/fitMode/fitMode.d.ts.map +1 -0
  86. package/dist/format/format.d.ts +42 -0
  87. package/dist/format/format.d.ts.map +1 -0
  88. package/dist/i18n.d.ts +55 -0
  89. package/dist/i18n.d.ts.map +1 -0
  90. package/dist/index.cjs.css +792 -0
  91. package/dist/index.cjs.js +5087 -0
  92. package/dist/index.d.ts +4 -0
  93. package/dist/index.d.ts.map +1 -0
  94. package/dist/index.esm.css +792 -0
  95. package/dist/index.esm.js +5079 -0
  96. package/dist/index.node.d.ts +9 -0
  97. package/dist/index.node.d.ts.map +1 -0
  98. package/dist/logo-v3-small-T5VXIMRR.svg +32 -0
  99. package/dist/models/decode.d.ts +3 -0
  100. package/dist/models/decode.d.ts.map +1 -0
  101. package/dist/models/flamebearer.d.ts +63 -0
  102. package/dist/models/flamebearer.d.ts.map +1 -0
  103. package/dist/models/groups.d.ts +37 -0
  104. package/dist/models/groups.d.ts.map +1 -0
  105. package/dist/models/index.d.ts +8 -0
  106. package/dist/models/index.d.ts.map +1 -0
  107. package/dist/models/profile.d.ts +152 -0
  108. package/dist/models/profile.d.ts.map +1 -0
  109. package/dist/models/spyName.d.ts +8 -0
  110. package/dist/models/spyName.d.ts.map +1 -0
  111. package/dist/models/trace.d.ts +357 -0
  112. package/dist/models/trace.d.ts.map +1 -0
  113. package/dist/models/units.d.ts +6 -0
  114. package/dist/models/units.d.ts.map +1 -0
  115. package/dist/search.d.ts +2 -0
  116. package/dist/search.d.ts.map +1 -0
  117. package/dist/shims/Box.d.ts +38 -0
  118. package/dist/shims/Box.d.ts.map +1 -0
  119. package/dist/shims/Button.d.ts +26 -0
  120. package/dist/shims/Button.d.ts.map +1 -0
  121. package/dist/shims/Dropdown.d.ts +30 -0
  122. package/dist/shims/Dropdown.d.ts.map +1 -0
  123. package/dist/shims/Input.d.ts +19 -0
  124. package/dist/shims/Input.d.ts.map +1 -0
  125. package/dist/shims/LoadingSpinner.d.ts +7 -0
  126. package/dist/shims/LoadingSpinner.d.ts.map +1 -0
  127. package/dist/shims/Menu.d.ts +4 -0
  128. package/dist/shims/Menu.d.ts.map +1 -0
  129. package/dist/shims/NoData.d.ts +2 -0
  130. package/dist/shims/NoData.d.ts.map +1 -0
  131. package/dist/shims/Table.d.ts +52 -0
  132. package/dist/shims/Table.d.ts.map +1 -0
  133. package/dist/shims/Tooltip.d.ts +9 -0
  134. package/dist/shims/Tooltip.d.ts.map +1 -0
  135. package/package.json +84 -0
  136. package/src/FlameGraph/FlameGraphComponent/CheckIcon.tsx +27 -0
  137. package/src/FlameGraph/FlameGraphComponent/ContextMenu.module.scss +10 -0
  138. package/src/FlameGraph/FlameGraphComponent/ContextMenu.spec.tsx +84 -0
  139. package/src/FlameGraph/FlameGraphComponent/ContextMenu.tsx +86 -0
  140. package/src/FlameGraph/FlameGraphComponent/ContextMenuHighlight.module.css +8 -0
  141. package/src/FlameGraph/FlameGraphComponent/ContextMenuHighlight.tsx +47 -0
  142. package/src/FlameGraph/FlameGraphComponent/DiffLegend.module.css +21 -0
  143. package/src/FlameGraph/FlameGraphComponent/DiffLegend.tsx +52 -0
  144. package/src/FlameGraph/FlameGraphComponent/DiffLegendPaletteDropdown.module.css +40 -0
  145. package/src/FlameGraph/FlameGraphComponent/DiffLegendPaletteDropdown.tsx +129 -0
  146. package/src/FlameGraph/FlameGraphComponent/Flamegraph.spec.ts +552 -0
  147. package/src/FlameGraph/FlameGraphComponent/Flamegraph.ts +446 -0
  148. package/src/FlameGraph/FlameGraphComponent/Flamegraph_render.spec.tsx +233 -0
  149. package/src/FlameGraph/FlameGraphComponent/Flamegraph_render.ts +478 -0
  150. package/src/FlameGraph/FlameGraphComponent/GraphVizPane.tsx +56 -0
  151. package/src/FlameGraph/FlameGraphComponent/GraphVizPanel.module.scss +55 -0
  152. package/src/FlameGraph/FlameGraphComponent/Header.module.css +27 -0
  153. package/src/FlameGraph/FlameGraphComponent/Header.tsx +71 -0
  154. package/src/FlameGraph/FlameGraphComponent/Highlight.module.css +7 -0
  155. package/src/FlameGraph/FlameGraphComponent/Highlight.spec.tsx +53 -0
  156. package/src/FlameGraph/FlameGraphComponent/Highlight.tsx +94 -0
  157. package/src/FlameGraph/FlameGraphComponent/LogoLink.module.scss +10 -0
  158. package/src/FlameGraph/FlameGraphComponent/LogoLink.tsx +101 -0
  159. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/canvas-renderer-spec-tsx-canvas-renderer-group-snapshot-collapses-small-blocks-into-one-1-snap.png +0 -0
  160. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/canvas-renderer-spec-tsx-canvas-renderer-group-snapshot-works-with-diff-mode-1-snap.png +0 -0
  161. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/canvas-renderer-spec-tsx-canvas-renderer-group-snapshot-works-with-highlighted-flamegraph-1-snap.png +0 -0
  162. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/canvas-renderer-spec-tsx-canvas-renderer-group-snapshot-works-with-normal-flamegraph-1-snap.png +0 -0
  163. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/canvas-renderer-spec-tsx-canvas-renderer-group-snapshot-works-with-selected-node-1-snap.png +0 -0
  164. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-focused-also-zooms-1-snap.png +0 -0
  165. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-focused-renders-a-focused-node-in-the-beginning-1-snap.png +0 -0
  166. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-focused-renders-a-focused-node-when-node-is-not-in-the-beginning-1-snap.png +0 -0
  167. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-focused-renders-a-focused-node-zoom-top-level-1-snap.png +0 -0
  168. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-complex-flamegraph-1-snap.png +0 -0
  169. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-double-diff-flamegraph-1-snap.png +0 -0
  170. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-highlighted-double-flamegraph-1-snap.png +0 -0
  171. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-highlighted-flamegraph-1-snap.png +0 -0
  172. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-simple-flamegraph-1-snap.png +0 -0
  173. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-simple-tree-1-snap.png +0 -0
  174. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-zoomed-flamegraph-1-snap.png +0 -0
  175. package/src/FlameGraph/FlameGraphComponent/__image_snapshots__/flamegraph-render-spec-tsx-render-group-snapshot-renders-a-zoomed-with-fit-mode-tail-1-snap.png +0 -0
  176. package/src/FlameGraph/FlameGraphComponent/canvas.module.css +6 -0
  177. package/src/FlameGraph/FlameGraphComponent/color.spec.ts +308 -0
  178. package/src/FlameGraph/FlameGraphComponent/color.ts +167 -0
  179. package/src/FlameGraph/FlameGraphComponent/colorPalette.ts +58 -0
  180. package/src/FlameGraph/FlameGraphComponent/constants.ts +5 -0
  181. package/src/FlameGraph/FlameGraphComponent/index.spec.tsx +291 -0
  182. package/src/FlameGraph/FlameGraphComponent/index.tsx +411 -0
  183. package/src/FlameGraph/FlameGraphComponent/murmur3.ts +97 -0
  184. package/src/FlameGraph/FlameGraphComponent/styles.module.scss +10 -0
  185. package/src/FlameGraph/FlameGraphComponent/testData.ts +427 -0
  186. package/src/FlameGraph/FlameGraphComponent/utils.ts +31 -0
  187. package/src/FlameGraph/FlameGraphComponent/viewTypes.ts +6 -0
  188. package/src/FlameGraph/FlameGraphRenderer.tsx +603 -0
  189. package/src/FlameGraph/FlamegraphRenderer.module.scss +93 -0
  190. package/src/FlameGraph/decode.ts +78 -0
  191. package/src/FlameGraph/normalize.spec.ts +76 -0
  192. package/src/FlameGraph/normalize.ts +60 -0
  193. package/src/FlameGraph/testData.json +423 -0
  194. package/src/FlameGraph/uniqueness.spec.ts +16 -0
  195. package/src/FlameGraph/uniqueness.ts +84 -0
  196. package/src/FlamegraphRenderer.tsx +61 -0
  197. package/src/Icons.tsx +74 -0
  198. package/src/ProfilerTable.tsx +527 -0
  199. package/src/SharedQueryInput.module.scss +82 -0
  200. package/src/SharedQueryInput.tsx +127 -0
  201. package/src/Toolbar.module.scss +117 -0
  202. package/src/Toolbar.spec.tsx +217 -0
  203. package/src/Toolbar.tsx +471 -0
  204. package/src/Tooltip/FlamegraphTooltip.spec.tsx +81 -0
  205. package/src/Tooltip/FlamegraphTooltip.tsx +257 -0
  206. package/src/Tooltip/LeftClickIcon.tsx +18 -0
  207. package/src/Tooltip/RightClickIcon.tsx +18 -0
  208. package/src/Tooltip/TableTooltip.spec.tsx +44 -0
  209. package/src/Tooltip/TableTooltip.tsx +145 -0
  210. package/src/Tooltip/Tooltip.module.scss +71 -0
  211. package/src/Tooltip/Tooltip.spec.tsx +395 -0
  212. package/src/Tooltip/Tooltip.tsx +336 -0
  213. package/src/__snapshots__/Toolbar.spec.tsx.snap +297 -0
  214. package/src/convert/convertJaegerTraceToProfile.ts +97 -0
  215. package/src/convert/diffTwoProfiles.ts +81 -0
  216. package/src/convert/flamebearersToTree.ts +78 -0
  217. package/src/convert/sandwichViewProfiles.spec.ts +65 -0
  218. package/src/convert/sandwichViewProfiles.ts +191 -0
  219. package/src/convert/subtract.ts +87 -0
  220. package/src/convert/testData.ts +145 -0
  221. package/src/convert/toGraphviz.ts +485 -0
  222. package/src/fitMode/fitMode.spec.ts +93 -0
  223. package/src/fitMode/fitMode.ts +122 -0
  224. package/src/format/format.spec.ts +291 -0
  225. package/src/format/format.ts +303 -0
  226. package/src/globals.d.ts +13 -0
  227. package/src/i18n.tsx +293 -0
  228. package/src/index.node.ts +19 -0
  229. package/src/index.spec.tsx +383 -0
  230. package/src/index.tsx +10 -0
  231. package/src/logo-v3-small.svg +32 -0
  232. package/src/models/decode.ts +45 -0
  233. package/src/models/flamebearer.ts +86 -0
  234. package/src/models/groups.ts +14 -0
  235. package/src/models/index.ts +7 -0
  236. package/src/models/profile.spec.ts +32 -0
  237. package/src/models/profile.ts +48 -0
  238. package/src/models/spyName.spec.ts +18 -0
  239. package/src/models/spyName.ts +32 -0
  240. package/src/models/trace.ts +45 -0
  241. package/src/models/units.spec.ts +21 -0
  242. package/src/models/units.ts +24 -0
  243. package/src/sass/_common.scss +206 -0
  244. package/src/sass/_css-variables.scss +201 -0
  245. package/src/sass/_mixins.scss +15 -0
  246. package/src/sass/_sanitize.scss +407 -0
  247. package/src/sass/_variables.scss +53 -0
  248. package/src/sass/flamegraph.scss +18 -0
  249. package/src/search.spec.ts +11 -0
  250. package/src/search.ts +4 -0
  251. package/src/shameful-any.d.ts +2 -0
  252. package/src/shims/Box.module.scss +57 -0
  253. package/src/shims/Box.tsx +105 -0
  254. package/src/shims/Button.module.scss +129 -0
  255. package/src/shims/Button.tsx +128 -0
  256. package/src/shims/Dropdown.module.scss +63 -0
  257. package/src/shims/Dropdown.tsx +96 -0
  258. package/src/shims/Input.module.scss +15 -0
  259. package/src/shims/Input.tsx +55 -0
  260. package/src/shims/LoadingSpinner.tsx +19 -0
  261. package/src/shims/Menu.tsx +9 -0
  262. package/src/shims/NoData.module.scss +6 -0
  263. package/src/shims/NoData.tsx +11 -0
  264. package/src/shims/Table.module.scss +82 -0
  265. package/src/shims/Table.spec.tsx +121 -0
  266. package/src/shims/Table.tsx +252 -0
  267. package/src/shims/Tooltip.tsx +51 -0
@@ -0,0 +1,395 @@
1
+ /* eslint-disable react/jsx-props-no-spreading */
2
+ import React from 'react';
3
+ import { render, screen } from '@testing-library/react';
4
+ import userEvent from '@testing-library/user-event';
5
+
6
+ import { Tooltip, TooltipProps } from './Tooltip';
7
+
8
+ function TestCanvas(props: Omit<TooltipProps, 'dataSourceRef'>) {
9
+ const canvasRef = React.useRef<HTMLCanvasElement>(null);
10
+
11
+ return (
12
+ <>
13
+ <canvas data-testid="canvas" ref={canvasRef} />
14
+ <Tooltip
15
+ data-testid="tooltip"
16
+ {...(props as TooltipProps)}
17
+ dataSourceRef={canvasRef}
18
+ />
19
+ </>
20
+ );
21
+ }
22
+
23
+ function TestTable(props: Omit<TooltipProps, 'dataSourceRef'>) {
24
+ const tableBodyRef = React.useRef<HTMLTableSectionElement>(null);
25
+
26
+ return (
27
+ <>
28
+ <table>
29
+ <tbody data-testid="table-body" ref={tableBodyRef}>
30
+ <tr>
31
+ <td>text</td>
32
+ </tr>
33
+ </tbody>
34
+ </table>
35
+ <Tooltip
36
+ data-testid="tooltip"
37
+ {...(props as TooltipProps)}
38
+ dataSourceRef={tableBodyRef}
39
+ />
40
+ </>
41
+ );
42
+ }
43
+
44
+ describe('Tooltip', () => {
45
+ describe('flamegraph tooltip', () => {
46
+ it("'single' mode with default settings renders correctly", () => {
47
+ render(
48
+ <TestCanvas
49
+ clickInfoSide="right"
50
+ setTooltipContent={(setContent) => {
51
+ setContent({
52
+ title: {
53
+ text: 'function_title',
54
+ diff: {
55
+ text: '',
56
+ color: '',
57
+ },
58
+ },
59
+ tooltipData: [
60
+ {
61
+ units: 'samples',
62
+ percent: 100,
63
+ samples: '100',
64
+ formattedValue: '1 second',
65
+ tooltipType: 'flamegraph',
66
+ },
67
+ ],
68
+ });
69
+ }}
70
+ />
71
+ );
72
+
73
+ expect(screen.getByTestId('tooltip')).toBeInTheDocument();
74
+
75
+ userEvent.hover(screen.getByTestId('canvas'));
76
+
77
+ expect(screen.getByTestId('tooltip-title')).toHaveTextContent(
78
+ 'function_title'
79
+ );
80
+ expect(screen.getByTestId('tooltip-function-name')).toHaveTextContent(
81
+ 'function_title'
82
+ );
83
+ expect(screen.getByTestId('tooltip-table')).toHaveTextContent(
84
+ 'Share of CPU:100CPU Time:1 secondSamples:100'
85
+ );
86
+ expect(screen.getByTestId('tooltip-footer')).toHaveTextContent(
87
+ 'Right click for more node viewing options'
88
+ );
89
+ });
90
+
91
+ describe("'double' mode with default settings", () => {
92
+ it("works with a function that hasn't changed", () => {
93
+ render(
94
+ <TestCanvas
95
+ clickInfoSide="right"
96
+ setTooltipContent={(setContent) => {
97
+ setContent({
98
+ title: {
99
+ text: 'function_title',
100
+ diff: {
101
+ text: '(+99900.00%)',
102
+ color: 'rgb(200, 0, 0)',
103
+ },
104
+ },
105
+ tooltipData: [
106
+ {
107
+ percent: '0.1%',
108
+ samples: '100',
109
+ units: 'samples',
110
+ formattedValue: '1.00 second',
111
+ tooltipType: 'flamegraph',
112
+ },
113
+ {
114
+ percent: '100%',
115
+ samples: '100',
116
+ units: 'samples',
117
+ formattedValue: '1.00 second',
118
+ tooltipType: 'flamegraph',
119
+ },
120
+ ],
121
+ });
122
+ }}
123
+ />
124
+ );
125
+
126
+ expect(screen.getByTestId('tooltip')).toBeInTheDocument();
127
+
128
+ userEvent.hover(screen.getByTestId('canvas'));
129
+
130
+ expect(screen.getByTestId('tooltip-title')).toHaveTextContent(
131
+ 'function_title'
132
+ );
133
+ expect(screen.getByTestId('tooltip-function-name')).toHaveTextContent(
134
+ 'function_title'
135
+ );
136
+ expect(screen.getByTestId('tooltip-table')).toHaveTextContent(
137
+ 'BaselineComparisonDiffShare of CPU:0.1%100%(+99900.00%)CPU Time:1.00 second1.00 secondSamples:100100'
138
+ );
139
+ expect(screen.getByTestId('tooltip-footer')).toHaveTextContent(
140
+ 'Right click for more node viewing options'
141
+ );
142
+ });
143
+
144
+ it('works with a function that has been added', () => {
145
+ render(
146
+ <TestCanvas
147
+ clickInfoSide="right"
148
+ setTooltipContent={(setContent) => {
149
+ setContent({
150
+ title: {
151
+ text: 'function_title',
152
+ diff: {
153
+ text: '(new)',
154
+ color: 'rgb(200, 0, 0)',
155
+ },
156
+ },
157
+ tooltipData: [
158
+ {
159
+ percent: '0%',
160
+ samples: '0',
161
+ units: 'samples',
162
+ formattedValue: '< 0.01 seconds',
163
+ tooltipType: 'flamegraph',
164
+ },
165
+ {
166
+ percent: '10%',
167
+ samples: '100',
168
+ units: 'samples',
169
+ formattedValue: '1.00 second',
170
+ tooltipType: 'flamegraph',
171
+ },
172
+ ],
173
+ });
174
+ }}
175
+ />
176
+ );
177
+
178
+ expect(screen.getByTestId('tooltip')).toBeInTheDocument();
179
+
180
+ userEvent.hover(screen.getByTestId('canvas'));
181
+
182
+ expect(screen.getByTestId('tooltip-title')).toHaveTextContent(
183
+ 'function_title'
184
+ );
185
+ expect(screen.getByTestId('tooltip-function-name')).toHaveTextContent(
186
+ 'function_title'
187
+ );
188
+ expect(screen.getByTestId('tooltip-table')).toHaveTextContent(
189
+ 'BaselineComparisonDiffShare of CPU:0%10%(new)CPU Time:< 0.01 seconds1.00 secondSamples:0100'
190
+ );
191
+ expect(screen.getByTestId('tooltip-footer')).toHaveTextContent(
192
+ 'Right click for more node viewing options'
193
+ );
194
+ });
195
+
196
+ it('works with a function that has been removed', () => {
197
+ render(
198
+ <TestCanvas
199
+ clickInfoSide="right"
200
+ setTooltipContent={(setContent) => {
201
+ setContent({
202
+ title: {
203
+ text: 'function_title',
204
+ diff: {
205
+ text: '(removed)',
206
+ color: 'rgb(0, 170, 0)',
207
+ },
208
+ },
209
+ tooltipData: [
210
+ {
211
+ percent: '10%',
212
+ samples: '100',
213
+ units: 'samples',
214
+ formattedValue: '1.00 second',
215
+ tooltipType: 'flamegraph',
216
+ },
217
+ {
218
+ percent: '0%',
219
+ samples: '0',
220
+ units: 'samples',
221
+ formattedValue: '< 0.01 seconds',
222
+ tooltipType: 'flamegraph',
223
+ },
224
+ ],
225
+ });
226
+ }}
227
+ />
228
+ );
229
+
230
+ expect(screen.getByTestId('tooltip')).toBeInTheDocument();
231
+
232
+ userEvent.hover(screen.getByTestId('canvas'));
233
+
234
+ expect(screen.getByTestId('tooltip-title')).toHaveTextContent(
235
+ 'function_title'
236
+ );
237
+ expect(screen.getByTestId('tooltip-function-name')).toHaveTextContent(
238
+ 'function_title'
239
+ );
240
+ expect(screen.getByTestId('tooltip-table')).toHaveTextContent(
241
+ 'BaselineComparisonDiffShare of CPU:10%0%(removed)CPU Time:1.00 second< 0.01 secondsSamples:1000'
242
+ );
243
+ expect(screen.getByTestId('tooltip-footer')).toHaveTextContent(
244
+ 'Right click for more node viewing options'
245
+ );
246
+ });
247
+
248
+ it('works with a function that became slower', () => {
249
+ render(
250
+ <TestCanvas
251
+ clickInfoSide="right"
252
+ setTooltipContent={(setContent) => {
253
+ setContent({
254
+ title: {
255
+ text: 'function_title',
256
+ diff: {
257
+ text: '(+100.00%)',
258
+ color: 'rgb(200, 0, 0)',
259
+ },
260
+ },
261
+ tooltipData: [
262
+ {
263
+ percent: '10%',
264
+ samples: '100',
265
+ units: 'samples',
266
+ formattedValue: '1.00 second',
267
+ tooltipType: 'flamegraph',
268
+ },
269
+ {
270
+ percent: '20%',
271
+ samples: '200',
272
+ units: 'samples',
273
+ formattedValue: '2.00 seconds',
274
+ tooltipType: 'flamegraph',
275
+ },
276
+ ],
277
+ });
278
+ }}
279
+ />
280
+ );
281
+
282
+ expect(screen.getByTestId('tooltip')).toBeInTheDocument();
283
+
284
+ userEvent.hover(screen.getByTestId('canvas'));
285
+
286
+ expect(screen.getByTestId('tooltip-title')).toHaveTextContent(
287
+ 'function_title'
288
+ );
289
+ expect(screen.getByTestId('tooltip-function-name')).toHaveTextContent(
290
+ 'function_title'
291
+ );
292
+ expect(screen.getByTestId('tooltip-table')).toHaveTextContent(
293
+ 'BaselineComparisonDiffShare of CPU:10%20%(+100.00%)CPU Time:1.00 second2.00 secondsSamples:100200'
294
+ );
295
+ expect(screen.getByTestId('tooltip-footer')).toHaveTextContent(
296
+ 'Right click for more node viewing options'
297
+ );
298
+ });
299
+
300
+ it('works with a function that became faster', () => {
301
+ render(
302
+ <TestCanvas
303
+ clickInfoSide="right"
304
+ setTooltipContent={(setContent) => {
305
+ setContent({
306
+ title: {
307
+ text: 'function_title',
308
+ diff: {
309
+ text: '(-50.00%)',
310
+ color: 'rgb(0, 170, 0)',
311
+ },
312
+ },
313
+ tooltipData: [
314
+ {
315
+ percent: '20%',
316
+ samples: '200',
317
+ units: 'samples',
318
+ formattedValue: '2.00 second',
319
+ tooltipType: 'flamegraph',
320
+ },
321
+ {
322
+ percent: '10%',
323
+ samples: '100',
324
+ units: 'samples',
325
+ formattedValue: '1.00 seconds',
326
+ tooltipType: 'flamegraph',
327
+ },
328
+ ],
329
+ });
330
+ }}
331
+ />
332
+ );
333
+
334
+ expect(screen.getByTestId('tooltip')).toBeInTheDocument();
335
+
336
+ userEvent.hover(screen.getByTestId('canvas'));
337
+
338
+ expect(screen.getByTestId('tooltip-title')).toHaveTextContent(
339
+ 'function_title'
340
+ );
341
+ expect(screen.getByTestId('tooltip-function-name')).toHaveTextContent(
342
+ 'function_title'
343
+ );
344
+ expect(screen.getByTestId('tooltip-table')).toHaveTextContent(
345
+ 'BaselineComparisonDiffShare of CPU:20%10%(-50.00%)CPU Time:2.00 second1.00 secondsSamples:200100'
346
+ );
347
+ expect(screen.getByTestId('tooltip-footer')).toHaveTextContent(
348
+ 'Right click for more node viewing options'
349
+ );
350
+ });
351
+ });
352
+ });
353
+
354
+ describe('table tooltip', () => {
355
+ it("'single' mode with custom settings renders correctly", () => {
356
+ render(
357
+ <TestTable
358
+ clickInfoSide="left"
359
+ shouldShowFooter={false}
360
+ shouldShowTitle={false}
361
+ setTooltipContent={(setContent) => {
362
+ setContent({
363
+ title: {
364
+ text: 'function_title',
365
+ diff: {
366
+ text: '',
367
+ color: '',
368
+ },
369
+ },
370
+ tooltipData: [
371
+ {
372
+ total: '2 seconds (100%)',
373
+ self: '1 second (50%)',
374
+ tooltipType: 'table',
375
+ units: 'samples',
376
+ },
377
+ ],
378
+ });
379
+ }}
380
+ />
381
+ );
382
+
383
+ expect(screen.getByTestId('tooltip')).toBeInTheDocument();
384
+
385
+ userEvent.hover(screen.getByTestId('table-body'));
386
+
387
+ expect(screen.getByTestId('tooltip-function-name')).toHaveTextContent(
388
+ 'function_title'
389
+ );
390
+ expect(screen.getByTestId('tooltip-table')).toHaveTextContent(
391
+ 'Self (% of total CPU)Total (% of total CPU)CPU Time:1 second (50%)2 seconds (100%)'
392
+ );
393
+ });
394
+ });
395
+ });