Skip to content

Commit

Permalink
Re-add checks filtering (#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
dottorblaster authored and nelsonkopliku committed Apr 26, 2023
1 parent b4b1ad0 commit 9903c7d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
43 changes: 27 additions & 16 deletions assets/js/components/ExecutionResults/ExecutionResults.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import Table from '@components/Table';

import ReactMarkdown from 'react-markdown';
Expand Down Expand Up @@ -90,6 +90,8 @@ function ExecutionResults({
onLastExecutionUpdate = () => {},
onStartExecution = () => {},
}) {
const [predicates, setPredicates] = useState([]);

const hosts = hostnames.map((item) => item.id);

if (catalogLoading) {
Expand Down Expand Up @@ -122,22 +124,30 @@ function ExecutionResults({
);
}

const tableData = getCheckResults(executionData).map(
({
check_id: checkID,
result,
expectation_results: expectationResults,
agents_check_results: agentsCheckResults,
}) => ({
checkID,
result,
clusterName,
executionState: executionData?.status,
description: getCheckDescription(catalog, checkID),
expectationResults,
agentsCheckResults: addHostnameToTargets(agentsCheckResults, hostnames),
const tableData = getCheckResults(executionData)
.filter((check) => {
if (predicates.length === 0) {
return true;
}

return predicates.some((predicate) => predicate(check));
})
);
.map(
({
check_id: checkID,
result,
expectation_results: expectationResults,
agents_check_results: agentsCheckResults,
}) => ({
checkID,
result,
clusterName,
executionState: executionData?.status,
description: getCheckDescription(catalog, checkID),
expectationResults,
agentsCheckResults: addHostnameToTargets(agentsCheckResults, hostnames),
})
);

return (
<>
Expand All @@ -146,6 +156,7 @@ function ExecutionResults({
clusterName={clusterName}
cloudProvider={cloudProvider}
clusterScenario={clusterScenario}
onFilterChange={(newPredicates) => setPredicates(newPredicates)}
/>
<ResultsContainer
catalogError={false}
Expand Down
19 changes: 8 additions & 11 deletions assets/js/components/ExecutionResults/ExecutionResults.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,16 @@ describe('ExecutionResults', () => {
{ route: `/clusters/${clusterID}/executions/last?health=passing` }
);

expect(screen.getByText('test-cluster')).toBeTruthy();
expect(screen.getAllByText('test-cluster')).toHaveLength(2);
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(checkID1)).toHaveLength(1);
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 () => {
it("should render ExecutionResults with successfully filtered 'passing' and 'critical' results", async () => {
const {
clusterID,
hostnames,
Expand Down Expand Up @@ -330,15 +329,13 @@ describe('ExecutionResults', () => {
}
);

expect(screen.getByText('test-cluster')).toBeTruthy();
expect(screen.getAllByText('test-cluster')).toHaveLength(2);
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();
expect(screen.getAllByText(hostnames[0].hostname)).toHaveLength(2);
expect(screen.getAllByText(hostnames[1].hostname)).toHaveLength(2);
expect(screen.getAllByText(checkID1)).toHaveLength(1);
expect(screen.getAllByText(checkID2)).toHaveLength(1);
});

it('given provider is VMware, should render ExecutionResults with warning banner', async () => {
Expand Down

0 comments on commit 9903c7d

Please sign in to comment.