Skip to content

Commit 34f85a7

Browse files
ui: Metrics graph related test-ids (#5938)
* Metrics graph related test-ids * [pre-commit.ci lite] apply automatic fixes * Linter fix * Revert the tooltip changes * [pre-commit.ci lite] apply automatic fixes * reverting the tooltip changes * [pre-commit.ci lite] apply automatic fixes * reverting the tooltip changes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 5c190e0 commit 34f85a7

5 files changed

Lines changed: 34 additions & 3 deletions

File tree

ui/packages/shared/profile/src/MetricsGraph/MetricsContextMenu/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {Icon} from '@iconify/react';
1515
import {Item, Menu, Submenu} from 'react-contexify';
1616

1717
import {useParcaContext} from '@parca/components';
18+
import {testId} from '@parca/test-utils';
1819

1920
import {Series, SeriesPoint} from '../';
2021

@@ -110,7 +111,12 @@ const MetricsContextMenu = ({
110111
};
111112

112113
return (
113-
<Menu id={menuId} onVisibilityChange={trackVisibility} theme={isDarkMode ? 'dark' : ''}>
114+
<Menu
115+
id={menuId}
116+
onVisibilityChange={trackVisibility}
117+
theme={isDarkMode ? 'dark' : ''}
118+
{...testId('METRICS_GRAPH_CONTEXT_MENU')}
119+
>
114120
{menuItems.map(renderMenuItem)}
115121
</Menu>
116122
);

ui/packages/shared/profile/src/MetricsGraph/MetricsTooltip/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {useEffect, useMemo, useState} from 'react';
1515

1616
import {usePopper} from 'react-popper';
1717

18+
import {testId} from '@parca/test-utils';
19+
1820
interface VirtualElement {
1921
getBoundingClientRect: () => DOMRect;
2022
}
@@ -107,7 +109,13 @@ const MetricsTooltip = ({x, y, contextElement, content}: Props): JSX.Element =>
107109
}
108110

109111
return (
110-
<div ref={setPopperElement} style={styles.popper} {...attributes.popper} className="z-50">
112+
<div
113+
ref={setPopperElement}
114+
style={styles.popper}
115+
{...attributes.popper}
116+
{...testId('METRICS_GRAPH_TOOLTIP')}
117+
className="z-50"
118+
>
111119
<div className="flex max-w-lg">
112120
<div className="m-auto">
113121
<div className="border border-gray-300 bg-gray-50 dark:border-gray-500 dark:bg-gray-900 rounded-lg shadow-lg px-3 py-2">

ui/packages/shared/profile/src/MetricsGraph/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import throttle from 'lodash.throttle';
1919
import {useContextMenu} from 'react-contexify';
2020

2121
import {DateTimeRange, useParcaContext} from '@parca/components';
22+
import {testId} from '@parca/test-utils';
2223
import {formatDate, formatForTimespan, getPrecision, valueFormatter} from '@parca/utilities';
2324

2425
import MetricsCircle from '../MetricsCircle';
@@ -81,7 +82,11 @@ const MetricsGraph = ({
8182
}: Props): JSX.Element => {
8283
const [isInfoPanelOpen, setIsInfoPanelOpen] = useState<boolean>(false);
8384
return (
84-
<div className="relative" onClick={() => isInfoPanelOpen && setIsInfoPanelOpen(false)}>
85+
<div
86+
className="relative"
87+
{...testId('METRICS_GRAPH')}
88+
onClick={() => isInfoPanelOpen && setIsInfoPanelOpen(false)}
89+
>
8590
<div className="absolute right-0 top-0">
8691
<MetricsInfoPanel
8792
isInfoPanelOpen={isInfoPanelOpen}

ui/packages/shared/profile/src/ProfileMetricsGraph/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
useParcaContext,
3030
} from '@parca/components';
3131
import {Query} from '@parca/parser';
32+
import {testId} from '@parca/test-utils';
3233
import {capitalizeOnlyFirstLetter, formatDate, timePattern, valueFormatter} from '@parca/utilities';
3334

3435
import {MergedProfileSelection, ProfileSelection} from '..';
@@ -490,6 +491,7 @@ const ProfileMetricsGraph = ({
490491
<div
491492
key={name}
492493
className="mr-3 inline-block rounded-lg bg-gray-200 px-2 py-1 text-xs font-bold text-gray-700 dark:bg-gray-700 dark:text-gray-400"
494+
{...testId('TOOLTIP_LABEL')}
493495
>
494496
<TextWithTooltip
495497
text={`${name.replace('attributes.', '')}="${
@@ -511,6 +513,7 @@ const ProfileMetricsGraph = ({
511513
<div
512514
key={name}
513515
className="mr-3 inline-block rounded-lg bg-gray-200 px-2 py-1 text-xs font-bold text-gray-700 dark:bg-gray-700 dark:text-gray-400"
516+
{...testId('TOOLTIP_LABEL')}
514517
>
515518
<TextWithTooltip
516519
text={`${name.replace('attributes.', '')}="${
@@ -531,6 +534,7 @@ const ProfileMetricsGraph = ({
531534
<div
532535
key={label.name}
533536
className="mr-3 inline-block rounded-lg bg-gray-200 px-2 py-1 text-xs font-bold text-gray-700 dark:bg-gray-700 dark:text-gray-400"
537+
{...testId('TOOLTIP_LABEL')}
534538
>
535539
<TextWithTooltip
536540
text={`${label.name}="${label.value}"`}

ui/packages/shared/test-utils/src/test-ids.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ export const TEST_IDS = {
8787
FLAMEGRAPH_CONTAINER: 'flamegraph-container',
8888
FLAMEGRAPH_RESET_BUTTON: 'flamegraph-reset-button',
8989

90+
// Metrics Graph
91+
METRICS_GRAPH: 'metrics-graph',
92+
METRICS_GRAPH_TOOLTIP: 'metrics-graph-tooltip',
93+
TOOLTIP_LABEL: 'tooltip-label',
94+
TOOLTIP_LABEL_KEY: 'tooltip-label-key',
95+
TOOLTIP_LABEL_VALUE: 'tooltip-label-value',
96+
METRICS_GRAPH_CONTEXT_MENU: 'metrics-graph-context-menu',
97+
9098
// Profile Filters
9199
PROFILE_FILTERS_CONTAINER: 'profile-filters-container',
92100
FILTER_TYPE_SELECT: 'filter-type-select',

0 commit comments

Comments
 (0)