diff --git a/assets/js/components/ClusterDetails/ClusterDetailsNew.jsx b/assets/js/components/ClusterDetails/ClusterDetailsNew.jsx index 07ee28b68a..9411cc2a7a 100644 --- a/assets/js/components/ClusterDetails/ClusterDetailsNew.jsx +++ b/assets/js/components/ClusterDetails/ClusterDetailsNew.jsx @@ -214,7 +214,9 @@ export function ClusterDetailsNew() { - navigate(`/clusters/${clusterID}/checks/results?health=${health}`) + navigate( + `/clusters_new/${clusterID}/executions/last?health=${health}` + ) } /> diff --git a/assets/js/components/ExecutionResults/ExecutionResults.jsx b/assets/js/components/ExecutionResults/ExecutionResults.jsx index 37d63f67ba..207ed0854a 100644 --- a/assets/js/components/ExecutionResults/ExecutionResults.jsx +++ b/assets/js/components/ExecutionResults/ExecutionResults.jsx @@ -17,9 +17,7 @@ import { getCheckResults, getCheckDescription, } from '@components/ChecksResults'; -import ChecksResultFilters, { - filterChecks, -} from '@components/ChecksResults/ChecksResultFilters'; +import ChecksResultFilters from '@components/ChecksResults/ChecksResultFilters'; import { UNKNOWN_PROVIDER } from '@components/ClusterDetails/ClusterSettings'; import { ClusterInfoBox } from '@components/ClusterDetails'; import NotificationBox from '@components/NotificationBox'; @@ -138,32 +136,57 @@ function ExecutionResults({ key={hostID} hostname={hostnames.find(({ id }) => hostID === id)?.hostname} > - {filterChecks(checks, predicates).map((checkID) => { - const { health, error, expectations, failedExpectations } = - getCheckHealthByAgent(checkResults, checkID, hostID); + {checks + .map((checkID) => { + const { health, error, expectations, failedExpectations } = + getCheckHealthByAgent(checkResults, checkID, hostID); - const label = getLabel( - executionData?.status, - health, - error, - expectations, - failedExpectations - ); - return ( - { - setModalOpen(true); - setSelectedCheck(checkID); - }} - /> - ); - })} + return { + checkID, + error, + expectations, + failedExpectations, + result: health, + }; + }) + .filter((check) => { + if (predicates.length === 0) { + return true; + } + + return predicates.some((predicate) => predicate(check)); + }) + .map( + ({ + checkID, + result, + error, + expectations, + failedExpectations, + }) => { + const label = getLabel( + executionData?.status, + result, + error, + expectations, + failedExpectations + ); + return ( + { + setModalOpen(true); + setSelectedCheck(checkID); + }} + /> + ); + } + )} ))} diff --git a/assets/js/components/ExecutionResults/ExecutionResults.test.jsx b/assets/js/components/ExecutionResults/ExecutionResults.test.jsx index 1a27998280..99e700642a 100644 --- a/assets/js/components/ExecutionResults/ExecutionResults.test.jsx +++ b/assets/js/components/ExecutionResults/ExecutionResults.test.jsx @@ -206,4 +206,88 @@ describe('ExecutionResults', () => { const svgText = screen.getByText('Select Checks now!'); expect(svgText).toBeInTheDocument(); }); + + it("should render ExecutionResults with successfully filtered 'passing' results", async () => { + const { + clusterID, + hostnames, + checks: [checkID1, checkID2], + loading, + catalog, + error, + executionLoading, + executionData, + executionError, + } = prepareStateData('passing'); + + renderWithRouter( + , + { route: `/clusters_new/${clusterID}/executions/last?health=passing` } + ); + + expect(screen.getByText('test-cluster')).toBeTruthy(); + expect(screen.getByText('HANA scale-up')).toBeTruthy(); + expect(screen.getByText('Azure')).toBeTruthy(); + expect(screen.getByText(hostnames[0].hostname)).toBeTruthy(); + expect(screen.getByText(hostnames[1].hostname)).toBeTruthy(); + expect(screen.getAllByText(checkID1)).toHaveLength(2); + expect(screen.queryByText(checkID2)).toBeNull(); + expect(screen.getAllByText('2/2 expectations passed')).toBeTruthy(); + }); + + it("should render ExecutionResults with successfully filtered 'passing' and 'ciritcal' results", async () => { + const { + clusterID, + hostnames, + checks: [checkID1, checkID2], + loading, + catalog, + error, + executionLoading, + executionData, + executionError, + } = prepareStateData('passing'); + + renderWithRouter( + , + { + route: `/clusters_new/${clusterID}/executions/last?health=passing&health=critical + `, + } + ); + + expect(screen.getByText('test-cluster')).toBeTruthy(); + expect(screen.getByText('HANA scale-up')).toBeTruthy(); + expect(screen.getByText('Azure')).toBeTruthy(); + expect(screen.getByText(hostnames[0].hostname)).toBeTruthy(); + expect(screen.getByText(hostnames[1].hostname)).toBeTruthy(); + expect(screen.getAllByText(checkID1)).toHaveLength(2); + expect(screen.getAllByText(checkID2)).toHaveLength(2); + expect(screen.getAllByText('2/2 expectations passed')).toBeTruthy(); + expect(screen.getAllByText('1/2 expectations failed')).toBeTruthy(); + }); });