[ML] AIOps: Enable event_generating_elements_should_be_instrumented eslint rule. (#167317)

Implements #153108.

This enables the
`@kbn/telemetry/event_generating_elements_should_be_instrumented` eslint
rule for the `aiops` plugin to enforce `data-test-subj` attributes on
actionable EUI components so they are auto-instrumented by telemetry.

The ids were first auto-created using `node scripts/eslint --fix
x-pack/plugins/aiops` and then adapted.
This commit is contained in:
Walter Rafelsberger 2023-09-28 11:49:13 +02:00 committed by GitHub
parent 8a2701cf21
commit adc9ab9c52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 3 deletions

View file

@ -908,6 +908,7 @@ module.exports = {
},
{
files: [
'x-pack/plugins/aiops/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/apm/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/exploratory_view/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/infra/**/*.{js,mjs,ts,tsx}',

View file

@ -356,6 +356,7 @@ const FieldPanel: FC<FieldPanelProps> = ({
<EuiSpacer size={'m'} />
<EuiButton
data-test-subj="aiopsChangePointDetectionSubmitDashboardAttachButton"
fill
type={'submit'}
fullWidth
@ -441,6 +442,7 @@ const FieldPanel: FC<FieldPanelProps> = ({
<EuiFlexGroup alignItems={'center'} gutterSize={'s'}>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="aiopsChangePointDetectionExpandConfigButton"
iconType={isExpanded ? 'arrowDown' : 'arrowRight'}
onClick={setIsExpanded.bind(null, (prevState) => !prevState)}
aria-label={i18n.translate('xpack.aiops.changePointDetection.expandConfigLabel', {
@ -480,6 +482,7 @@ const FieldPanel: FC<FieldPanelProps> = ({
id={`panelContextMenu_${panelIndex}`}
button={
<EuiButtonIcon
data-test-subj="aiopsChangePointDetectionContextMenuButton"
aria-label={i18n.translate(
'xpack.aiops.changePointDetection.configActionsLabel',
{

View file

@ -42,6 +42,7 @@ export const MaxSeriesControl: FC<{
label={inline ? undefined : label}
>
<EuiFieldNumber
data-test-subj="aiopsMaxSeriesControlFieldNumber"
disabled={disabled}
prepend={inline ? label : undefined}
append={

View file

@ -51,6 +51,7 @@ export const TableHeader: FC<Props> = ({
<>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
data-test-subj="aiopsLogPatternAnalysisOpenInDiscoverIncludeButton"
size="s"
onClick={() => openInDiscover(QUERY_MODE.INCLUDE)}
iconType="plusInCircle"
@ -61,6 +62,7 @@ export const TableHeader: FC<Props> = ({
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
data-test-subj="aiopsLogPatternAnalysisOpenInDiscoverExcludeButton"
size="s"
onClick={() => openInDiscover(QUERY_MODE.EXCLUDE)}
iconType="minusInCircle"

View file

@ -43,7 +43,12 @@ export const LoadingCategorization: FC<Props> = ({ onClose }) => (
<EuiFlexItem>
<EuiFlexGroup justifyContent="spaceAround">
<EuiFlexItem grow={false} css={{ textAlign: 'center' }}>
<EuiButton onClick={() => onClose()}>Cancel</EuiButton>
<EuiButton
data-test-subj="aiopsLoadingCategorizationCancelButton"
onClick={() => onClose()}
>
Cancel
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>

View file

@ -324,7 +324,12 @@ export const LogCategorizationPage: FC = () => {
/>
</EuiButton>
) : (
<EuiButton onClick={() => cancelRequest()}>Cancel</EuiButton>
<EuiButton
data-test-subj="aiopsLogCategorizationPageCancelButton"
onClick={() => cancelRequest()}
>
Cancel
</EuiButton>
)}
</EuiFlexItem>
<EuiFlexItem />

View file

@ -92,6 +92,7 @@ export const RandomSamplerRangeSlider = ({
data-test-subj="dvRandomSamplerProbabilityRange"
append={
<EuiButton
data-test-subj="aiopsRandomSamplerRangeSliderApplyButton"
disabled={isInvalidSamplingProbabilityInput}
onClick={() => {
if (setSamplingProbability && isDefined(samplingProbabilityInput)) {

View file

@ -118,6 +118,7 @@ export const SamplingMenu: FC<Props> = ({ randomSampler, reload }) => {
id="aiopsSamplingOptions"
button={
<EuiButtonEmpty
data-test-subj="aiopsLogPatternAnalysisShowSamplingOptionsButton"
onClick={() => setShowSamplingOptionsPopover(!showSamplingOptionsPopover)}
iconSide="right"
iconType="arrowDown"

View file

@ -409,7 +409,11 @@ export const LogRateAnalysisResults: FC<LogRateAnalysisResultsProps> = ({
)}
{overrides !== undefined ? (
<p>
<EuiButton size="s" onClick={() => startHandler(true)}>
<EuiButton
data-test-subj="aiopsLogRateAnalysisResultsTryToContinueAnalysisButton"
size="s"
onClick={() => startHandler(true)}
>
<FormattedMessage
id="xpack.aiops.logRateAnalysis.page.tryToContinueAnalysisButtonText"
defaultMessage="Try to continue analysis"