Skip to content

Commit

Permalink
Fixed unit tests.
Browse files Browse the repository at this point in the history
Signed-off-by: AWSHurneyt <[email protected]>
  • Loading branch information
AWSHurneyt committed Apr 19, 2022
1 parent 2ec1ba3 commit 034171b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export default class AlertsDashboardFlyoutComponent extends Component {
? `${bucketValue} ${bucketUnitOfTime}`
: '-';

const displayTableTabs = monitor.monitor_type === MONITOR_TYPE.DOC_LEVEL;
const displayTableTabs = monitorType === MONITOR_TYPE.DOC_LEVEL;
return (
<div>
<EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import _ from 'lodash';
import monitorToFormik from './monitorToFormik';

import { FORMIK_INITIAL_VALUES, MATCH_ALL_QUERY } from './constants';
import { MONITOR_TYPE, SEARCH_TYPE } from '../../../../../utils/constants';

const exampleMonitor = {
name: 'Example Monitor',
Expand Down Expand Up @@ -156,7 +157,8 @@ describe('monitorToFormik', () => {
describe('can build ClusterMetricsMonitor', () => {
test('with path params', () => {
const clusterMetricsMonitor = _.cloneDeep(exampleMonitor);
clusterMetricsMonitor.ui_metadata.search.searchType = 'clusterMetrics';
clusterMetricsMonitor.monitor_type = MONITOR_TYPE.CLUSTER_METRICS;
clusterMetricsMonitor.ui_metadata.search.searchType = SEARCH_TYPE.CLUSTER_METRICS;
clusterMetricsMonitor.inputs = [
{
uri: {
Expand All @@ -171,7 +173,8 @@ describe('monitorToFormik', () => {
});
test('without path params', () => {
const clusterMetricsMonitor = _.cloneDeep(exampleMonitor);
clusterMetricsMonitor.ui_metadata.search.searchType = 'clusterMetrics';
clusterMetricsMonitor.monitor_type = MONITOR_TYPE.CLUSTER_METRICS;
clusterMetricsMonitor.ui_metadata.search.searchType = SEARCH_TYPE.CLUSTER_METRICS;
clusterMetricsMonitor.inputs = [
{
uri: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export const getExecuteMessage = (response) => {
if (!triggerResults) return 'No trigger results';
const triggerId = Object.keys(triggerResults)[0];
if (!triggerId) return 'No trigger results';
const executeResults = _.get(triggerResults, `${triggerId}`);
const executeResults = _.get(triggerResults, triggerId);
if (!executeResults) return 'No execute results';
const { error, triggered, triggeredDocs } = executeResults;
if (!_.isNull(error) && !_.isEmpty(error)) return error;
if (!_.isNull(triggered) && !_.isEmpty(triggered)) return `${triggered}`;
if (!_.isNull(triggeredDocs) && !_.isEmpty(triggeredDocs))
if (!_.isNull(error) && !_.isUndefined(error)) return error;
if (!_.isNull(triggered) && !_.isUndefined(triggered)) return `${triggered}`;
if (!_.isNull(triggeredDocs) && !_.isUndefined(triggeredDocs))
return JSON.stringify(triggeredDocs, null, 4);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function triggerDefinitionToFormik(trigger, monitor) {
case MONITOR_TYPE.DOC_LEVEL:
return documentLevelTriggerToFormik(trigger, monitor);
default:
queryLevelTriggerToFormik(trigger, monitor);
return queryLevelTriggerToFormik(trigger, monitor);
}
}

Expand Down
3 changes: 2 additions & 1 deletion public/pages/Dashboard/utils/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,8 @@ describe('Dashboard/utils/helpers', () => {
});
});
describe('when perAlertView is true', () => {
const perAlertView = test('when defaultSize is undefined', () => {
const perAlertView = true;
test('when defaultSize is undefined', () => {
const defaultSize = undefined;
expect(getInitialSize(perAlertView, defaultSize)).toEqual(
DEFAULT_GET_ALERTS_QUERY_PARAMS.size
Expand Down

0 comments on commit 034171b

Please sign in to comment.