Skip to content

Commit

Permalink
Fix navigation to a running execution detail (#1457)
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonkopliku authored May 25, 2023
1 parent 556456f commit 6ee9aa2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion assets/js/state/selectors/lastExecutions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const addHostnameToAgentsCheckResults = (
...executionData,
data: {
...data,
check_results: check_results.map((checkResult) => ({
check_results: check_results?.map((checkResult) => ({
...checkResult,
agents_check_results: checkResult?.agents_check_results.map(
(target) => ({
Expand Down
31 changes: 31 additions & 0 deletions assets/js/state/selectors/lastExecutions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
clusterFactory,
catalogCheckFactory,
checksExecutionCompletedForTargetsFactory,
checksExecutionRunningFactory,
} from '@lib/test-utils/factories';
import { getLastExecution, getLastExecutionData } from './lastExecutions';

Expand Down Expand Up @@ -100,4 +101,34 @@ describe('lastExecutions selector', () => {
lastExecution.data.check_results[0].agents_check_results[1].hostname
).toEqual(hostname2);
});

it('should properly handle running executions', () => {
const { id: clusterID } = clusterFactory.build();
const runningExecution = checksExecutionRunningFactory.build({
group_id: clusterID,
});

const state = {
clustersList: {
clusters: [],
},
hostsList: {
hosts: [],
},
catalog: {},
lastExecutions: {
[clusterID]: {
loading: false,
data: runningExecution,
error: null,
},
},
};

const { lastExecution } = getLastExecutionData(clusterID)(state);

expect(lastExecution.data.result).toBeNull();
expect(lastExecution.data.check_results).toBeUndefined();
expect(lastExecution.data.status).toEqual('running');
});
});

0 comments on commit 6ee9aa2

Please sign in to comment.