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: add data test ids for alerts e2e tests (#9384)

Amlan Kumar Nandy0d1131e99f7d
diff --git a/frontend/src/components/QueryBuilderV2/QueryV2/QueryAddOns/QueryAddOns.tsx b/frontend/src/components/QueryBuilderV2/QueryV2/QueryAddOns/QueryAddOns.tsx
index f0fecfea2c..2193486419 100644
--- a/frontend/src/components/QueryBuilderV2/QueryV2/QueryAddOns/QueryAddOns.tsx
+++ b/frontend/src/components/QueryBuilderV2/QueryV2/QueryAddOns/QueryAddOns.tsx
@@ -500,7 +500,10 @@ function QueryAddOns({
}
value={addOn}
>
- <div className="add-on-tab-title">
+ <div
+ className="add-on-tab-title"
+ data-testid={`query-add-on-${addOn.key}`}
+ >
{addOn.icon}
{addOn.label}
</div>
diff --git a/frontend/src/container/CreateAlertV2/AlertCondition/AlertThreshold.tsx b/frontend/src/container/CreateAlertV2/AlertCondition/AlertThreshold.tsx
index 95663daa51..bad143029f 100644
--- a/frontend/src/container/CreateAlertV2/AlertCondition/AlertThreshold.tsx
+++ b/frontend/src/container/CreateAlertV2/AlertCondition/AlertThreshold.tsx
@@ -183,6 +183,7 @@ function AlertThreshold({
}}
style={{ width: 80 }}
options={queryNames}
+ data-testid="alert-threshold-query-select"
/>
<Typography.Text className="sentence-text">is</Typography.Text>
<Select
@@ -195,6 +196,7 @@ function AlertThreshold({
}}
style={{ width: 180 }}
options={THRESHOLD_OPERATOR_OPTIONS}
+ data-testid="alert-threshold-operator-select"
/>
<Typography.Text className="sentence-text">
the threshold(s)
@@ -209,6 +211,7 @@ function AlertThreshold({
}}
style={{ width: 180 }}
options={matchTypeOptionsWithTooltips}
+ data-testid="alert-threshold-match-type-select"
/>
<Typography.Text className="sentence-text">
during the <EvaluationSettings />
@@ -236,6 +239,7 @@ function AlertThreshold({
icon={<Plus size={16} />}
onClick={addThreshold}
className="add-threshold-btn"
+ data-testid="add-threshold-button"
>
Add Threshold
</Button>
diff --git a/frontend/src/container/CreateAlertV2/AlertCondition/ThresholdItem.tsx b/frontend/src/container/CreateAlertV2/AlertCondition/ThresholdItem.tsx
index 836c4761d8..6723348112 100644
--- a/frontend/src/container/CreateAlertV2/AlertCondition/ThresholdItem.tsx
+++ b/frontend/src/container/CreateAlertV2/AlertCondition/ThresholdItem.tsx
@@ -32,6 +32,7 @@ function ThresholdItem({
style={{ width: 150 }}
options={units}
disabled={units.length === 0}
+ data-testid="threshold-unit-select"
/>
);
if (units.length === 0) {
@@ -47,6 +48,7 @@ function ThresholdItem({
style={{ width: 150 }}
options={units}
disabled={units.length === 0}
+ data-testid="threshold-unit-select"
/>
</Tooltip>
);
@@ -96,6 +98,7 @@ function ThresholdItem({
updateThreshold(threshold.id, 'label', e.target.value)
}
style={{ width: 200 }}
+ data-testid="threshold-name-input"
/>
<Typography.Text className="sentence-text">on value</Typography.Text>
<Typography.Text className="sentence-text highlighted-text">
@@ -109,6 +112,7 @@ function ThresholdItem({
}
style={{ width: 100 }}
type="number"
+ data-testid="threshold-value-input"
/>
{yAxisUnitSelect}
{!notificationSettings.routingPolicies && (
@@ -119,10 +123,12 @@ function ThresholdItem({
onChange={(value): void =>
updateThreshold(threshold.id, 'channels', value)
}
+ data-testid="threshold-notification-channel-select"
style={{ width: 350 }}
options={channels.map((channel) => ({
value: channel.name,
label: channel.name,
+ 'data-testid': `threshold-notification-channel-option-${threshold.label}`,
}))}
mode="multiple"
placeholder="Select notification channels"
@@ -157,6 +163,7 @@ function ThresholdItem({
}
style={{ width: 100 }}
type="number"
+ data-testid="recovery-threshold-value-input"
/>
<Tooltip title="Remove recovery threshold">
<Button
@@ -164,6 +171,7 @@ function ThresholdItem({
icon={<Trash size={16} />}
onClick={removeRecoveryThreshold}
className="icon-btn"
+ data-testid="remove-recovery-threshold-button"
/>
</Tooltip>
</>
@@ -187,6 +195,7 @@ function ThresholdItem({
icon={<CircleX size={16} />}
onClick={(): void => removeThreshold(threshold.id)}
className="icon-btn"
+ data-testid="remove-threshold-button"
/>
</Tooltip>
)}
diff --git a/frontend/src/container/CreateAlertV2/AlertCondition/utils.tsx b/frontend/src/container/CreateAlertV2/AlertCondition/utils.tsx
index 51e4a591e9..e334b99df9 100644
--- a/frontend/src/container/CreateAlertV2/AlertCondition/utils.tsx
+++ b/frontend/src/container/CreateAlertV2/AlertCondition/utils.tsx
@@ -50,6 +50,7 @@ export function getCategorySelectOptionByName(
(unit) => ({
label: unit.name,
value: unit.id,
+ 'data-testid': `threshold-unit-select-option-${unit.id}`,
}),
) || []
);
@@ -401,6 +402,7 @@ export function RoutingPolicyBanner({
</Typography.Text>
<Switch
checked={notificationSettings.routingPolicies}
+ data-testid="routing-policies-switch"
onChange={(value): void => {
setNotificationSettings({
type: 'SET_ROUTING_POLICIES',
diff --git a/frontend/src/container/CreateAlertV2/CreateAlertHeader/CreateAlertHeader.tsx b/frontend/src/container/CreateAlertV2/CreateAlertHeader/CreateAlertHeader.tsx
index e076f23e19..611c89a724 100644
--- a/frontend/src/container/CreateAlertV2/CreateAlertHeader/CreateAlertHeader.tsx
+++ b/frontend/src/container/CreateAlertV2/CreateAlertHeader/CreateAlertHeader.tsx
@@ -52,6 +52,7 @@ function CreateAlertHeader(): JSX.Element {
}
className="alert-header__input title"
placeholder="Enter alert rule name"
+ data-testid="alert-name-input"
/>
<LabelsInput
labels={alertState.labels}
diff --git a/frontend/src/container/CreateAlertV2/CreateAlertHeader/LabelsInput.tsx b/frontend/src/container/CreateAlertV2/CreateAlertHeader/LabelsInput.tsx
index 31c72eca7d..55c5bd862b 100644
--- a/frontend/src/container/CreateAlertV2/CreateAlertHeader/LabelsInput.tsx
+++ b/frontend/src/container/CreateAlertV2/CreateAlertHeader/LabelsInput.tsx
@@ -124,7 +124,11 @@ function LabelsInput({
{Object.keys(labels).length > 0 && (
<div className="labels-input__existing-labels">
{Object.entries(labels).map(([key, value]) => (
- <span key={key} className="labels-input__label-pill">
+ <span
+ key={key}
+ className="labels-input__label-pill"
+ data-testid={`label-pill-${key}-${value}`}
+ >
{key}: {value}
<button
type="button"
@@ -143,6 +147,7 @@ function LabelsInput({
className="labels-input__add-button"
type="button"
onClick={handleAddLabelsClick}
+ data-testid="alert-add-label-button"
>
+ Add labels
</button>
@@ -158,6 +163,7 @@ function LabelsInput({
placeholder={inputState.isKeyInput ? 'Enter key' : 'Enter value'}
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus
+ data-testid="alert-add-label-input"
/>
</div>
)}
diff --git a/frontend/src/container/CreateAlertV2/EvaluationSettings/AdvancedOptionItem/AdvancedOptionItem.tsx b/frontend/src/container/CreateAlertV2/EvaluationSettings/AdvancedOptionItem/AdvancedOptionItem.tsx
index 89dc56e3b8..a5b4d624b4 100644
--- a/frontend/src/container/CreateAlertV2/EvaluationSettings/AdvancedOptionItem/AdvancedOptionItem.tsx
+++ b/frontend/src/container/CreateAlertV2/EvaluationSettings/AdvancedOptionItem/AdvancedOptionItem.tsx
@@ -13,6 +13,7 @@ function AdvancedOptionItem({
tooltipText,
onToggle,
defaultShowInput,
+ 'data-testid': dataTestId,
}: IAdvancedOptionItemProps): JSX.Element {
const [showInput, setShowInput] = useState<boolean>(false);
@@ -26,7 +27,7 @@ function AdvancedOptionItem({
};
return (
- <div className="advanced-option-item">
+ <div className="advanced-option-item" data-testid={dataTestId}>
<div className="advanced-option-item-left-content">
<Typography.Text className="advanced-option-item-title">
{title}
diff --git a/frontend/src/container/CreateAlertV2/EvaluationSettings/AdvancedOptions.tsx b/frontend/src/container/CreateAlertV2/EvaluationSettings/AdvancedOptions.tsx
index a02ff1881a..1aa196330f 100644
--- a/frontend/src/container/CreateAlertV2/EvaluationSettings/AdvancedOptions.tsx
+++ b/frontend/src/container/CreateAlertV2/EvaluationSettings/AdvancedOptions.tsx
@@ -43,6 +43,7 @@ function AdvancedOptions(): JSX.Element {
})
}
defaultShowInput={advancedOptions.sendNotificationIfDataIsMissing.enabled}
+ data-testid="send-notification-if-data-is-missing-container"
/>
<AdvancedOptionItem
title="Minimum data required"
@@ -74,6 +75,7 @@ function AdvancedOptions(): JSX.Element {
})
}
defaultShowInput={advancedOptions.enforceMinimumDatapoints.enabled}
+ data-testid="enforce-minimum-datapoints-container"
/>
{/* TODO: Add back when the functionality is implemented */}
{/* <AdvancedOptionItem
diff --git a/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationCadence/EvaluationCadence.tsx b/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationCadence/EvaluationCadence.tsx
index b8473da150..f949851a91 100644
--- a/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationCadence/EvaluationCadence.tsx
+++ b/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationCadence/EvaluationCadence.tsx
@@ -78,6 +78,7 @@ function EvaluationCadence(): JSX.Element {
},
})
}
+ data-testid="evaluation-cadence-duration-input"
/>
<Select
options={ADVANCED_OPTIONS_TIME_UNIT_OPTIONS}
@@ -96,6 +97,7 @@ function EvaluationCadence(): JSX.Element {
},
})
}
+ data-testid="evaluation-cadence-unit-select"
/>
</Input.Group>
{/* TODO: Add custom schedule back once the functionality is implemented */}
diff --git a/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationSettings.tsx b/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationSettings.tsx
index b0e0da59ff..24cc163ded 100644
--- a/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationSettings.tsx
+++ b/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationSettings.tsx
@@ -30,7 +30,7 @@ function EvaluationSettings(): JSX.Element {
trigger="click"
showArrow={false}
>
- <Button>
+ <Button data-testid="evaluation-settings-button">
<div className="evaluate-alert-conditions-button-left">
{getTimeframeText(evaluationWindow)}
</div>
diff --git a/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationWindowPopover/EvaluationWindowDetails.tsx b/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationWindowPopover/EvaluationWindowDetails.tsx
index 090865e595..c207853bc0 100644
--- a/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationWindowPopover/EvaluationWindowDetails.tsx
+++ b/frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationWindowPopover/EvaluationWindowDetails.tsx
@@ -127,6 +127,7 @@ function EvaluationWindowDetails({
value={evaluationWindow.startingAt.number || null}
onChange={handleNumberChange}
placeholder="Select starting at"
+ data-testid="evaluation-window-details-starting-at-select"
/>
</div>
</div>
@@ -154,6 +155,7 @@ function EvaluationWindowDetails({
value={evaluationWindow.startingAt.timezone || null}
onChange={handleTimezoneChange}
placeholder="Select timezone"
+ data-testid="evaluation-window-details-timezone-select"
/>
</div>
</div>
@@ -174,6 +176,7 @@ function EvaluationWindowDetails({
value={evaluationWindow.startingAt.number || null}
onChange={handleNumberChange}
placeholder="Select starting at"
+ data-testid="evaluation-window-details-starting-at-select"
/>
</div>
<div className="select-group time-select-group">
@@ -190,6 +193,7 @@ function EvaluationWindowDetails({
value={evaluationWindow.startingAt.timezone || null}
onChange={handleTimezoneChange}
placeholder="Select timezone"
+ data-testid="evaluation-window-details-timezone-select"
/>
</div>
</div>
@@ -211,6 +215,7 @@ function EvaluationWindowDetails({
value={evaluationWindow.startingAt.number}
onChange={(e): void => handleNumberChange(e.target.value)}
placeholder="Enter value"
+ data-testid="evaluation-window-details-custom-rolling-window-duration-input"
/>
</div>
<div className="select-group time-select-group">
@@ -220,6 +225,7 @@ function EvaluationWindowDetails({
value={evaluationWindow.startingAt.unit || null}
onChange={handleUnitChange}
placeholder="Select unit"
+ data-testid="evaluation-window-details-custom-rolling-window-unit-select"
/>
</div>
</div>
diff --git a/frontend/src/container/CreateAlertV2/EvaluationSettings/TimeInput/TimeInput.tsx b/frontend/src/container/CreateAlertV2/EvaluationSettings/TimeInput/TimeInput.tsx
index a8609642df..23b9b0f515 100644
--- a/frontend/src/container/CreateAlertV2/EvaluationSettings/TimeInput/TimeInput.tsx
+++ b/frontend/src/container/CreateAlertV2/EvaluationSettings/TimeInput/TimeInput.tsx
@@ -145,7 +145,7 @@ function TimeInput({
};
return (
- <div className={`time-input-container ${className}`}>
+ <div data-testid="time-input" className={`time-input-container ${className}`}>
<Input
data-field="hours"
value={hours}
@@ -156,6 +156,7 @@ function TimeInput({
maxLength={2}
className="time-input-field"
placeholder="00"
+ data-testid="time-input-hours"
/>
<span className="time-input-separator">:</span>
<Input
@@ -168,6 +169,7 @@ function TimeInput({
maxLength={2}
className="time-input-field"
placeholder="00"
+ data-testid="time-input-minutes"
/>
<span className="time-input-separator">:</span>
<Input
@@ -180,6 +182,7 @@ function TimeInput({
maxLength={2}
className="time-input-field"
placeholder="00"
+ data-testid="time-input-seconds"
/>
</div>
);
diff --git a/frontend/src/container/CreateAlertV2/EvaluationSettings/types.ts b/frontend/src/container/CreateAlertV2/EvaluationSettings/types.ts
index 1372163f6c..a252143e28 100644
--- a/frontend/src/container/CreateAlertV2/EvaluationSettings/types.ts
+++ b/frontend/src/container/CreateAlertV2/EvaluationSettings/types.ts
@@ -12,6 +12,7 @@ export interface IAdvancedOptionItemProps {
tooltipText?: string;
onToggle?: () => void;
defaultShowInput: boolean;
+ 'data-testid'?: string;
}
export enum RollingWindowTimeframes {
diff --git a/frontend/src/container/CreateAlertV2/NotificationSettings/MultipleNotifications.tsx b/frontend/src/container/CreateAlertV2/NotificationSettings/MultipleNotifications.tsx
index 21274cc6a9..b2016e2d7a 100644
--- a/frontend/src/container/CreateAlertV2/NotificationSettings/MultipleNotifications.tsx
+++ b/frontend/src/container/CreateAlertV2/NotificationSettings/MultipleNotifications.tsx
@@ -24,6 +24,7 @@ function MultipleNotifications(): JSX.Element {
return uniqueGroupBys.map((key) => ({
label: key,
value: key,
+ 'data-testid': 'multiple-notifications-select-option',
}));
}, [currentQuery.builder.queryData]);
@@ -49,6 +50,7 @@ function MultipleNotifications(): JSX.Element {
disabled={!isMultipleNotificationsEnabled}
aria-disabled={!isMultipleNotificationsEnabled}
maxTagCount={3}
+ data-testid="multiple-notifications-select"
/>
{isMultipleNotificationsEnabled && (
<Typography.Paragraph className="multiple-notifications-select-description">
diff --git a/frontend/src/container/CreateAlertV2/NotificationSettings/NotificationSettings.tsx b/frontend/src/container/CreateAlertV2/NotificationSettings/NotificationSettings.tsx
index 640d2b17bb..e35920adc8 100644
--- a/frontend/src/container/CreateAlertV2/NotificationSettings/NotificationSettings.tsx
+++ b/frontend/src/container/CreateAlertV2/NotificationSettings/NotificationSettings.tsx
@@ -37,6 +37,7 @@ function NotificationSettings(): JSX.Element {
},
});
}}
+ data-testid="repeat-notifications-time-input"
/>
<Select
value={notificationSettings.reNotification.unit || null}
@@ -54,6 +55,7 @@ function NotificationSettings(): JSX.Element {
},
});
}}
+ data-testid="repeat-notifications-unit-select"
/>
<Typography.Text>while</Typography.Text>
<Select
@@ -73,6 +75,7 @@ function NotificationSettings(): JSX.Element {
},
});
}}
+ data-testid="repeat-notifications-conditions-select"
/>
</div>
);
@@ -98,6 +101,7 @@ function NotificationSettings(): JSX.Element {
});
}}
defaultShowInput={notificationSettings.reNotification.enabled}
+ data-testid="repeat-notifications-container"
/>
</div>
</div>
diff --git a/frontend/src/container/ListAlertRules/ListAlert.tsx b/frontend/src/container/ListAlertRules/ListAlert.tsx
index 438e955c24..5743efcbff 100644
--- a/frontend/src/container/ListAlertRules/ListAlert.tsx
+++ b/frontend/src/container/ListAlertRules/ListAlert.tsx
@@ -350,47 +350,51 @@ function ListAlert({ allAlertRules, refetch }: ListAlertProps): JSX.Element {
key: 'action',
width: 10,
render: (id: GettableAlert['id'], record): JSX.Element => (
- <DropDown
- onDropDownItemClick={(item): void => alertActionLogEvent(item.key, record)}
- element={[
- <ToggleAlertState
- key="1"
- disabled={record.disabled}
- setData={setData}
- id={id}
- />,
- <ColumnButton
- key="2"
- onClick={(): void => onEditHandler(record, false)}
- type="link"
- loading={editLoader}
- >
- Edit
- </ColumnButton>,
- <ColumnButton
- key="3"
- onClick={(): void => onEditHandler(record, true)}
- type="link"
- loading={editLoader}
- >
- Edit in New Tab
- </ColumnButton>,
- <ColumnButton
- key="3"
- onClick={onCloneHandler(record)}
- type="link"
- loading={cloneLoader}
- >
- Clone
- </ColumnButton>,
- <DeleteAlert
- key="4"
- notifications={notificationsApi}
- setData={setData}
- id={id}
- />,
- ]}
- />
+ <div data-testid="alert-actions">
+ <DropDown
+ onDropDownItemClick={(item): void =>
+ alertActionLogEvent(item.key, record)
+ }
+ element={[
+ <ToggleAlertState
+ key="1"
+ disabled={record.disabled}
+ setData={setData}
+ id={id}
+ />,
+ <ColumnButton
+ key="2"
+ onClick={(): void => onEditHandler(record, false)}
+ type="link"
+ loading={editLoader}
+ >
+ Edit
+ </ColumnButton>,
+ <ColumnButton
+ key="3"
+ onClick={(): void => onEditHandler(record, true)}
+ type="link"
+ loading={editLoader}
+ >
+ Edit in New Tab
+ </ColumnButton>,
+ <ColumnButton
+ key="3"
+ onClick={onCloneHandler(record)}
+ type="link"
+ loading={cloneLoader}
+ >
+ Clone
+ </ColumnButton>,
+ <DeleteAlert
+ key="4"
+ notifications={notificationsApi}
+ setData={setData}
+ id={id}
+ />,
+ ]}
+ />
+ </div>
),
});
}
diff --git a/frontend/src/container/NewWidget/LeftContainer/QuerySection/QueryBuilder/promQL/query.tsx b/frontend/src/container/NewWidget/LeftContainer/QuerySection/QueryBuilder/promQL/query.tsx
index 8bfa2daff7..15a449bab3 100644
--- a/frontend/src/container/NewWidget/LeftContainer/QuerySection/QueryBuilder/promQL/query.tsx
+++ b/frontend/src/container/NewWidget/LeftContainer/QuerySection/QueryBuilder/promQL/query.tsx
@@ -66,6 +66,7 @@ function PromQLQueryBuilder({
defaultValue={queryData?.query}
addonBefore="PromQL Query"
style={{ marginBottom: '0.5rem' }}
+ data-testid="promql-query-input"
/>
<Input
@@ -75,6 +76,7 @@ function PromQLQueryBuilder({
defaultValue={queryData?.legend}
addonBefore="Legend Format"
style={{ marginBottom: '0.5rem' }}
+ data-testid="promql-legend-input"
/>
</QueryHeader>
);