-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make HealthIcon size configurable * Add HealthIcon storybook * Add Pill storybook * Use the Pill component for the agent version in HostsList * Add semver library for frontend * Add conditional agent version warning banner on host view * Add agent version warning state in the hosts list view * Add tooltip message to warning agent version * Correct warning message text * Move agent version function to new agent lib library
- Loading branch information
Showing
15 changed files
with
2,062 additions
and
218 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
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,31 @@ | ||
import React from 'react'; | ||
import HealthIcon from '.'; | ||
|
||
export default { | ||
title: 'HealthIcon', | ||
component: HealthIcon, | ||
}; | ||
|
||
export function Passing() { | ||
return <HealthIcon health="passing" />; | ||
} | ||
|
||
export function Warning() { | ||
return <HealthIcon health="warning" />; | ||
} | ||
|
||
export function Critical() { | ||
return <HealthIcon health="critical" />; | ||
} | ||
|
||
export function Pending() { | ||
return <HealthIcon health="pending" />; | ||
} | ||
|
||
export function Default() { | ||
return <HealthIcon health="unknown" />; | ||
} | ||
|
||
export function ExtraLarge() { | ||
return <HealthIcon health="passing" size="xl" />; | ||
} |
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
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
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,69 @@ | ||
import React from 'react'; | ||
import { screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import MockAdapter from 'axios-mock-adapter'; | ||
|
||
import { | ||
withState, | ||
defaultInitialState, | ||
renderWithRouterMatch, | ||
} from '@lib/test-utils'; | ||
import { hostFactory } from '@lib/test-utils/factories'; | ||
import { networkClient } from '@lib/network'; | ||
|
||
import HostDetails from './HostDetails'; | ||
|
||
// delayResponse is need to avoid component updates on axios requests | ||
const axiosMock = new MockAdapter(networkClient, { delayResponse: 2000 }); | ||
|
||
describe('HostDetails component', () => { | ||
beforeEach(() => { | ||
axiosMock.reset(); | ||
}); | ||
|
||
it('should not show any warning message if the agent version is correct', () => { | ||
const hosts = hostFactory.buildList(1, { agent_version: '2.0.0' }); | ||
const { id: hostID } = hosts[0]; | ||
const state = { | ||
...defaultInitialState, | ||
hostsList: { | ||
hosts, | ||
}, | ||
}; | ||
const [StatefulHostDetails] = withState(<HostDetails />, state); | ||
|
||
renderWithRouterMatch(StatefulHostDetails, { | ||
path: '/hosts/:hostID', | ||
route: `/hosts/${hostID}`, | ||
}); | ||
|
||
expect( | ||
screen.queryByText( | ||
'Agent version 2.0.0 or greater is required for the new checks engine.' | ||
) | ||
).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should show 2.0.0 version required warning message', () => { | ||
const hosts = hostFactory.buildList(1, { agent_version: '1.0.0' }); | ||
const { id: hostID } = hosts[0]; | ||
const state = { | ||
...defaultInitialState, | ||
hostsList: { | ||
hosts, | ||
}, | ||
}; | ||
const [StatefulHostDetails] = withState(<HostDetails />, state); | ||
|
||
renderWithRouterMatch(StatefulHostDetails, { | ||
path: '/hosts/:hostID', | ||
route: `/hosts/${hostID}`, | ||
}); | ||
|
||
expect( | ||
screen.getByText( | ||
'Agent version 2.0.0 or greater is required for the new checks engine.' | ||
) | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
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
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
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
Oops, something went wrong.