-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix anomaly alert selection text (#80746)
Was using the incorrect value. Add a case to leave out "and above" when on "critical." Add a test and rename files to snake case. Fixes #80441.
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...mponents/alerting/TransactionDurationAnomalyAlertTrigger/select_anomaly_severity.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { render } from '@testing-library/react'; | ||
import React, { ReactNode } from 'react'; | ||
import { IntlProvider } from 'react-intl'; | ||
import { ANOMALY_SEVERITY } from '../../../../../ml/common'; | ||
import { SelectAnomalySeverity } from './select_anomaly_severity'; | ||
|
||
function Wrapper({ children }: { children?: ReactNode }) { | ||
return <IntlProvider locale="en">{children}</IntlProvider>; | ||
} | ||
|
||
describe('SelectAnomalySeverity', () => { | ||
it('shows the correct text for each item', async () => { | ||
const result = render( | ||
<SelectAnomalySeverity | ||
onChange={() => {}} | ||
value={ANOMALY_SEVERITY.CRITICAL} | ||
/>, | ||
{ wrapper: Wrapper } | ||
); | ||
const button = (await result.findAllByText('critical'))[1]; | ||
|
||
button.click(); | ||
|
||
const options = await result.findAllByTestId( | ||
'SelectAnomalySeverity option text' | ||
); | ||
|
||
expect( | ||
options.map((option) => (option.firstChild as HTMLElement)?.innerHTML) | ||
).toEqual([ | ||
'score critical ', // Trailing space is intentional here, to keep the i18n simple | ||
'score major and above', | ||
'score minor and above', | ||
'score warning and above', | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters