diff --git a/assets/js/components/Health/HealthIcon.jsx b/assets/js/components/Health/HealthIcon.jsx index 097f353434..75c7c8f1bc 100644 --- a/assets/js/components/Health/HealthIcon.jsx +++ b/assets/js/components/Health/HealthIcon.jsx @@ -1,7 +1,12 @@ import React from 'react'; import { computedIconCssClass } from '@lib/icon'; -import { EOS_LENS_FILLED } from 'eos-icons-react'; +import { + EOS_CHECK_CIRCLE_OUTLINED, + EOS_ERROR_OUTLINED, + EOS_WARNING_OUTLINED, + EOS_LENS_FILLED, +} from 'eos-icons-react'; import Spinner from '@components/Spinner'; @@ -9,19 +14,19 @@ const HealthIcon = ({ health = undefined, centered = false }) => { switch (health) { case 'passing': return ( - ); case 'warning': return ( - ); case 'critical': return ( - ); diff --git a/assets/js/components/Health/HealthIcon.test.jsx b/assets/js/components/Health/HealthIcon.test.jsx new file mode 100644 index 0000000000..69c19fb248 --- /dev/null +++ b/assets/js/components/Health/HealthIcon.test.jsx @@ -0,0 +1,28 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import '@testing-library/jest-dom'; + +import HealthIcon from './'; + +describe('HealthIcon', () => { + it('should display a green svg when the health is passing', () => { + const { container } = render(); + const svgEl = container.querySelector("[data-testid='eos-svg-component']"); + expect(svgEl.classList.toString()).toContain('fill-jungle-green-500'); + }); + it('should display a yellow svg when the health is warning', () => { + const { container } = render(); + const svgEl = container.querySelector("[data-testid='eos-svg-component']"); + expect(svgEl.classList.toString()).toContain('fill-yellow-500'); + }); + it('should display a red svg when the health is critical', () => { + const { container } = render(); + const svgEl = container.querySelector("[data-testid='eos-svg-component']"); + expect(svgEl.classList.toString()).toContain('fill-red-500'); + }); + it('should display a grey circle when the health is unknown', () => { + const { container } = render(); + const svgEl = container.querySelector("[data-testid='eos-svg-component']"); + expect(svgEl.classList.toString()).toContain('fill-gray-500'); + }); +}); diff --git a/assets/js/components/HostsList.jsx b/assets/js/components/HostsList.jsx index d9ee1d7f03..252f580509 100644 --- a/assets/js/components/HostsList.jsx +++ b/assets/js/components/HostsList.jsx @@ -1,5 +1,6 @@ import React, { Fragment } from 'react'; import Table from './Table'; +import HealthIcon from '@components/Health/HealthIcon'; import Tags from './Tags'; import { addTagToHost, removeTagFromHost } from '@state/hosts'; import HostLink from '@components/HostLink'; @@ -7,22 +8,9 @@ import ClusterLink from '@components/ClusterLink'; import SapSystemLink from '@components/SapSystemLink'; import { useSelector, useDispatch } from 'react-redux'; -import { EOS_LENS_FILLED } from 'eos-icons-react'; - import { post, del } from '@lib/network'; import { ComponentHealthSummary } from '@components/HealthSummary'; -const getHeartbeatIcon = ({ heartbeat }) => { - switch (heartbeat) { - case 'passing': - return ; - case 'critical': - return ; - default: - return ; - } -}; - const getInstancesByHost = ( applicationInstances, databaseInstances, @@ -66,9 +54,9 @@ const HostsList = () => { title: 'Health', key: 'heartbeat', filter: true, - render: (_content, item) => ( -
{getHeartbeatIcon(item)}
- ), + render: (_content, item) => { + return ; + }, }, { title: 'Hostname', diff --git a/test/e2e/cypress/integration/hosts_overview.js b/test/e2e/cypress/integration/hosts_overview.js index b6f5dc5154..b5ffb8fcfe 100644 --- a/test/e2e/cypress/integration/hosts_overview.js +++ b/test/e2e/cypress/integration/hosts_overview.js @@ -147,9 +147,7 @@ context('Hosts Overview', () => { }); it('should show a passing health on the hosts when the agents are sending the heartbeat', () => { - cy.get('.tn-healthicon > svg.fill-jungle-green-500') - .its('length') - .should('eq', 10); + cy.get('svg.fill-jungle-green-500').its('length').should('eq', 10); }); }); describe('Health is changed to critical when the heartbeat is not sent', () => { @@ -163,9 +161,7 @@ context('Hosts Overview', () => { }); it('should show a critical health on the hosts when the agents are not sending the heartbeat', () => { - cy.get('.tn-healthicon > svg.fill-red-500') - .its('length') - .should('eq', 10); + cy.get('svg.fill-red-500').its('length').should('eq', 10); }); }); });