Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

chore: added test-ids to identify elements better in e2es (#10914)

Abhi kumar702a16f80d9f
diff --git a/frontend/src/components/QueryBuilderV2/QueryV2/MetricsSelect/MetricsSelect.tsx b/frontend/src/components/QueryBuilderV2/QueryV2/MetricsSelect/MetricsSelect.tsx
index 3e76ee4a2f..e9c7f54c49 100644
--- a/frontend/src/components/QueryBuilderV2/QueryV2/MetricsSelect/MetricsSelect.tsx
+++ b/frontend/src/components/QueryBuilderV2/QueryV2/MetricsSelect/MetricsSelect.tsx
@@ -150,6 +150,7 @@ export const MetricsSelect = memo(function MetricsSelect({
options={SOURCE_OPTIONS}
value={source}
defaultValue="metrics"
+ data-testid={`metrics-source-selector-${index}`}
onChange={handleSignalSourceChange}
/>
)}
@@ -157,6 +158,7 @@ export const MetricsSelect = memo(function MetricsSelect({
<MetricNameSelector
onChange={handleChangeAggregatorAttribute}
query={query}
+ data-testid={`metric-name-selector-${index}`}
signalSource={signalSource || ''}
/>
</div>
diff --git a/frontend/src/container/DashboardContainer/PanelTypeSelectionModal/index.tsx b/frontend/src/container/DashboardContainer/PanelTypeSelectionModal/index.tsx
index f7e2ac2de0..a1fc1f061f 100644
--- a/frontend/src/container/DashboardContainer/PanelTypeSelectionModal/index.tsx
+++ b/frontend/src/container/DashboardContainer/PanelTypeSelectionModal/index.tsx
@@ -55,7 +55,12 @@ function PanelTypeSelectionModal(): JSX.Element {
>
<div className="panel-selection">
{PanelTypesWithData.map(({ name, icon, display }) => (
- <Card onClick={(): void => handleCardClick(name)} id={name} key={name}>
+ <Card
+ onClick={(): void => handleCardClick(name)}
+ id={name}
+ key={name}
+ data-testid={`panel-type-${name}`}
+ >
{icon}
<Typography className="panel-type-text">{display}</Typography>
</Card>
diff --git a/frontend/src/container/ListOfDashboard/DashboardsList.tsx b/frontend/src/container/ListOfDashboard/DashboardsList.tsx
index 9448012c7e..8109ddcd6e 100644
--- a/frontend/src/container/ListOfDashboard/DashboardsList.tsx
+++ b/frontend/src/container/ListOfDashboard/DashboardsList.tsx
@@ -560,6 +560,7 @@ function DashboardsList(): JSX.Element {
label: (
<div
className="create-dashboard-menu-item"
+ data-testid="import-json-menu-cta"
onClick={(): void => onModalHandler(false)}
>
<Radius size={14} /> Import JSON
@@ -573,6 +574,7 @@ function DashboardsList(): JSX.Element {
href="https://signoz.io/docs/dashboards/dashboard-templates/overview/"
target="_blank"
rel="noopener noreferrer"
+ data-testid="view-templates-menu-cta"
>
<Flex
justify="space-between"
@@ -596,6 +598,7 @@ function DashboardsList(): JSX.Element {
label: (
<div
className="create-dashboard-menu-item"
+ data-testid="create-dashboard-menu-cta"
onClick={(): void => {
onNewDashboardHandler();
}}
@@ -759,6 +762,7 @@ function DashboardsList(): JSX.Element {
placeholder="Search by name, description, or tags..."
prefix={<Search size={12} color={Color.BG_VANILLA_400} />}
value={searchString}
+ data-testid="dashboards-list-search"
onChange={handleSearch}
/>
{createNewDashboard && (
@@ -772,6 +776,7 @@ function DashboardsList(): JSX.Element {
type="primary"
className="periscope-btn primary btn"
icon={<Plus size={14} />}
+ data-testid="new-dashboard-cta"
onClick={(): void => {
logEvent('Dashboard List: New dashboard clicked', {});
}}
diff --git a/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.tsx b/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.tsx
index 8d4bebde84..e0ed105226 100644
--- a/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.tsx
@@ -13,6 +13,7 @@ interface ColumnUnitSelectorProps {
columnUnits: ColumnUnit;
setColumnUnits: Dispatch<SetStateAction<ColumnUnit>>;
isNewDashboard: boolean;
+ 'data-testid'?: string;
}
export function ColumnUnitSelector(
@@ -83,6 +84,7 @@ export function ColumnUnitSelector(
}
fieldLabel={label}
key={value}
+ data-testid={props['data-testid']}
selectedQueryName={baseQueryName}
// Update the column unit value automatically only in create mode
shouldUpdateYAxisUnit={isNewDashboard}
diff --git a/frontend/src/container/NewWidget/RightContainer/ContextLinks/index.tsx b/frontend/src/container/NewWidget/RightContainer/ContextLinks/index.tsx
index 17d4e70af2..b3a0f42766 100644
--- a/frontend/src/container/NewWidget/RightContainer/ContextLinks/index.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/ContextLinks/index.tsx
@@ -138,6 +138,7 @@ function ContextLinks({
<Button
type="default"
className="add-context-link-button"
+ data-testid="add-context-link-cta"
icon={<Plus size={12} />}
style={{ width: '100%' }}
onClick={handleAddContextLink}
diff --git a/frontend/src/container/NewWidget/RightContainer/DashboardYAxisUnitSelectorWrapper.tsx b/frontend/src/container/NewWidget/RightContainer/DashboardYAxisUnitSelectorWrapper.tsx
index 25bbc5c37e..1473b5f890 100644
--- a/frontend/src/container/NewWidget/RightContainer/DashboardYAxisUnitSelectorWrapper.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/DashboardYAxisUnitSelectorWrapper.tsx
@@ -15,12 +15,14 @@ function DashboardYAxisUnitSelectorWrapper({
fieldLabel,
shouldUpdateYAxisUnit,
selectedQueryName,
+ 'data-testid': dataTestId,
}: {
value: string;
onSelect: OnSelectType;
fieldLabel: string;
shouldUpdateYAxisUnit: boolean;
selectedQueryName?: string;
+ 'data-testid'?: string;
}): JSX.Element {
const { yAxisUnit: initialYAxisUnit, isLoading } = useGetYAxisUnit(
selectedQueryName,
@@ -42,6 +44,7 @@ function DashboardYAxisUnitSelectorWrapper({
initialValue={initialYAxisUnit}
source={YAxisSource.DASHBOARDS}
loading={isLoading}
+ data-testid={dataTestId}
/>
</div>
);
diff --git a/frontend/src/container/NewWidget/RightContainer/SettingSections/FormattingUnitsSection/FormattingUnitsSection.tsx b/frontend/src/container/NewWidget/RightContainer/SettingSections/FormattingUnitsSection/FormattingUnitsSection.tsx
index 9945a2bba7..456f678a4d 100644
--- a/frontend/src/container/NewWidget/RightContainer/SettingSections/FormattingUnitsSection/FormattingUnitsSection.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/SettingSections/FormattingUnitsSection/FormattingUnitsSection.tsx
@@ -66,6 +66,7 @@ export default function FormattingUnitsSection({
options={decimapPrecisionOptions}
value={decimalPrecision}
className="panel-type-select"
+ data-testid="decimal-precision-selector"
defaultValue={decimapPrecisionOptions[0]?.value}
onChange={(val: PrecisionOption): void => setDecimalPrecision(val)}
/>
@@ -77,6 +78,7 @@ export default function FormattingUnitsSection({
columnUnits={columnUnits}
setColumnUnits={setColumnUnits}
isNewDashboard={isNewDashboard}
+ data-testid="column-unit-selector"
/>
)}
</SettingsSection>
diff --git a/frontend/src/container/NewWidget/RightContainer/SettingSections/GeneralSettingsSection/GeneralSettingsSection.tsx b/frontend/src/container/NewWidget/RightContainer/SettingSections/GeneralSettingsSection/GeneralSettingsSection.tsx
index 015b40037f..2ca4ccdc93 100644
--- a/frontend/src/container/NewWidget/RightContainer/SettingSections/GeneralSettingsSection/GeneralSettingsSection.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/SettingSections/GeneralSettingsSection/GeneralSettingsSection.tsx
@@ -135,6 +135,7 @@ export default function GeneralSettingsSection({
rootClassName="general-settings__name-input"
ref={inputRef}
onSelect={handleInputCursor}
+ data-testid="panel-name-input"
onClick={handleInputCursor}
onBlur={(): void => setAutoCompleteOpen(false)}
/>
@@ -145,6 +146,7 @@ export default function GeneralSettingsSection({
bordered
allowClear
value={description}
+ data-testid="panel-description-input"
onChange={(event): void =>
onChangeHandler(setDescription, event.target.value)
}
diff --git a/frontend/src/container/NewWidget/RightContainer/Threshold/Threshold.tsx b/frontend/src/container/NewWidget/RightContainer/Threshold/Threshold.tsx
index d3c2370556..30e6fca0db 100644
--- a/frontend/src/container/NewWidget/RightContainer/Threshold/Threshold.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/Threshold/Threshold.tsx
@@ -249,6 +249,7 @@ function Threshold({
<Input
defaultValue={label}
onChange={handleLabelChange}
+ data-testid="threshold-label-input"
bordered={!isDarkMode}
className="label-input"
/>
@@ -275,6 +276,7 @@ function Threshold({
onChange={handleTableOptionsChange}
rootClassName="operator-input-root"
className="operator-input"
+ data-testid="table-operator-input-selector"
/>
<Typography.Text className="typography">is</Typography.Text>
</Space>
@@ -287,6 +289,7 @@ function Threshold({
style={{ marginLeft: '10px' }}
rootClassName="operator-input-root"
className="operator-input"
+ data-testid="operator-input-selector"
/>
</div>
) : (
@@ -321,6 +324,7 @@ function Threshold({
defaultValue={value}
onChange={handleValueChange}
className="unit-input"
+ data-testid="threshold-value-input"
/>
) : (
<ShowCaseValue value={value} className="unit-input" />
@@ -332,6 +336,7 @@ function Threshold({
placeholder="Select unit"
source={YAxisSource.DASHBOARDS}
initialValue={unit}
+ data-testid="threshold-unit-input"
categoriesOverride={unitSelectCategories}
containerClassName="unit-selection"
/>
@@ -349,6 +354,7 @@ function Threshold({
defaultValue={format}
options={showAsOptions}
onChange={handlerFormatChange}
+ data-testid="threshold-color-selector"
rootClassName="color-format"
/>
</>
diff --git a/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.tsx b/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.tsx
index 483be7c9e3..358e9fb5b4 100644
--- a/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.tsx
@@ -72,6 +72,7 @@ function ThresholdSelector({
type="default"
icon={<Plus size={14} />}
style={{ width: '100%' }}
+ data-testid="add-threshold-cta"
onClick={addThresholdHandler}
>
Add Threshold
diff --git a/frontend/src/container/QueryBuilder/components/DataSourceDropdown/DataSourceDropdown.interfaces.ts b/frontend/src/container/QueryBuilder/components/DataSourceDropdown/DataSourceDropdown.interfaces.ts
index acbe586220..a0d602c39c 100644
--- a/frontend/src/container/QueryBuilder/components/DataSourceDropdown/DataSourceDropdown.interfaces.ts
+++ b/frontend/src/container/QueryBuilder/components/DataSourceDropdown/DataSourceDropdown.interfaces.ts
@@ -4,4 +4,5 @@ import { DataSource } from 'types/common/queryBuilder';
export type QueryLabelProps = {
onChange: (value: DataSource) => void;
isListViewPanel?: boolean;
+ 'data-testid'?: string;
} & Omit<SelectProps, 'onChange'>;
diff --git a/frontend/src/container/QueryBuilder/components/DataSourceDropdown/DataSourceDropdown.tsx b/frontend/src/container/QueryBuilder/components/DataSourceDropdown/DataSourceDropdown.tsx
index 7a2fc07332..515b6952c1 100644
--- a/frontend/src/container/QueryBuilder/components/DataSourceDropdown/DataSourceDropdown.tsx
+++ b/frontend/src/container/QueryBuilder/components/DataSourceDropdown/DataSourceDropdown.tsx
@@ -32,6 +32,7 @@ export const DataSourceDropdown = memo(function DataSourceDropdown(
defaultValue={dataSourceOptions[0].value}
options={dataSourceOptions}
onChange={onChange}
+ data-testid={props['data-testid']}
value={value}
style={style}
/>
diff --git a/frontend/src/container/QueryBuilder/components/QBEntityOptions/QBEntityOptions.tsx b/frontend/src/container/QueryBuilder/components/QBEntityOptions/QBEntityOptions.tsx
index 7163537f82..55a7d97e26 100644
--- a/frontend/src/container/QueryBuilder/components/QBEntityOptions/QBEntityOptions.tsx
+++ b/frontend/src/container/QueryBuilder/components/QBEntityOptions/QBEntityOptions.tsx
@@ -136,6 +136,7 @@ export default function QBEntityOptions({
onChangeDataSource(value);
}
}}
+ data-testid={`query-data-source-selector-${index}`}
value={query?.dataSource || DataSource.METRICS}
isListViewPanel={isListViewPanel}
className="query-data-source-dropdown"
diff --git a/frontend/src/container/QueryBuilder/filters/MetricNameSelector/MetricNameSelector.tsx b/frontend/src/container/QueryBuilder/filters/MetricNameSelector/MetricNameSelector.tsx
index 002debb2ad..ba0665f1d2 100644
--- a/frontend/src/container/QueryBuilder/filters/MetricNameSelector/MetricNameSelector.tsx
+++ b/frontend/src/container/QueryBuilder/filters/MetricNameSelector/MetricNameSelector.tsx
@@ -27,6 +27,7 @@ export type MetricNameSelectorProps = {
defaultValue?: string;
onSelect?: (value: BaseAutocompleteData) => void;
signalSource?: 'meter' | '';
+ 'data-testid'?: string;
};
function getAttributeType(
@@ -81,6 +82,7 @@ export const MetricNameSelector = memo(function MetricNameSelector({
defaultValue,
onSelect,
signalSource,
+ 'data-testid': dataTestId,
}: MetricNameSelectorProps): JSX.Element {
const currentMetricName =
(query.aggregations?.[0] as MetricAggregation)?.metricName ||
@@ -279,6 +281,7 @@ export const MetricNameSelector = memo(function MetricNameSelector({
</Typography.Text>
) : null
}
+ data-testid={dataTestId}
options={optionsData}
value={inputValue}
onBlur={handleBlur}