mirror of
https://github.com/Graylog2/graylog2-server.git
synced 2026-03-13 09:32:21 +08:00
Showing neutral trend when delta is zero. (#25138)
* Showing neutral trend when delta is zero. * Adding changelog snippet. * Unnecessary data attribute.
This commit is contained in:
4
changelog/unreleased/pr-25138.toml
Normal file
4
changelog/unreleased/pr-25138.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
type = "f"
|
||||
message = "Showing neutral trend in number widget when delta is zero."
|
||||
|
||||
pulls = ["25138"]
|
||||
@@ -94,13 +94,21 @@ describe('Trend', () => {
|
||||
});
|
||||
|
||||
describe('renders background according to values and trend preference', () => {
|
||||
it('shows neutral background if values are equal', async () => {
|
||||
renderTrend();
|
||||
it.each`
|
||||
trendPreference
|
||||
${'NEUTRAL'}
|
||||
${'HIGHER'}
|
||||
${'LOWER'}
|
||||
`(
|
||||
'shows neutral background if values are equal and trend preference is $trendPreference',
|
||||
async ({ trendPreference }: { trendPreference: 'NEUTRAL' | 'LOWER' | 'HIGHER' }) => {
|
||||
renderTrend({ trendPreference });
|
||||
|
||||
const background = await screen.findByTestId('trend-background');
|
||||
const background = await screen.findByTestId('trend-background');
|
||||
|
||||
expect(background).toHaveStyleRule('background-color', '#fff!important');
|
||||
});
|
||||
expect(background).toHaveStyleRule('background-color', '#fff!important');
|
||||
},
|
||||
);
|
||||
|
||||
it('shows good background if current value and preference are higher', async () => {
|
||||
renderTrend({ current: 43, trendPreference: 'HIGHER' });
|
||||
|
||||
@@ -71,6 +71,9 @@ const StyledIcon = styled(Icon)<{ $trend: TrendDirection | undefined }>(({ theme
|
||||
});
|
||||
|
||||
const _trendDirection = (delta: number, trendPreference: TrendPreference): TrendDirection => {
|
||||
if (delta === 0) {
|
||||
return 'neutral';
|
||||
}
|
||||
switch (trendPreference) {
|
||||
case 'LOWER':
|
||||
return delta > 0 ? 'bad' : 'good';
|
||||
|
||||
Reference in New Issue
Block a user