Skip to content

Commit

Permalink
[Ingest Node Pipelines] Remove default value for error_distance param (
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth authored Jun 21, 2021
1 parent 7765fc7 commit 863e709
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ describe('Processor: Circle', () => {
// Click submit button with only the type defined
await saveNewProcessor();

// Expect form error as "field" and "shape_type" are required parameters
// Expect form error as "field", "shape_type" and "error_distance" are required parameters
expect(form.getErrorsMessages()).toEqual([
'A field value is required.',
'An error distance value is required.',
'A shape type value is required.',
]);
});
Expand Down Expand Up @@ -91,15 +92,15 @@ describe('Processor: Circle', () => {
form,
} = testBed;

// Add "field" value (required)
// Set required parameters
form.setInputValue('fieldNameField.input', 'field_1');
// Select the shape
form.setSelectValue('shapeSelectorField', 'geo_shape');
// Add "target_field" value
form.setInputValue('targetField.input', 'target_field');

form.setInputValue('errorDistanceField.input', '10');

// Set optional parameters
form.setInputValue('targetField.input', 'target_field');
form.toggleEuiSwitch('ignoreMissingSwitch.input');

// Save the field with new changes
await saveNewProcessor();

Expand All @@ -109,6 +110,7 @@ describe('Processor: Circle', () => {
error_distance: 10,
shape_type: 'geo_shape',
target_field: 'target_field',
ignore_missing: true,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { EuiCode } from '@elastic/eui';
import {
FIELD_TYPES,
fieldValidators,
fieldFormatters,
UseField,
SelectField,
NumericField,
Expand All @@ -24,13 +25,13 @@ import { FieldNameField } from './common_fields/field_name_field';
import { TargetField } from './common_fields/target_field';

const { emptyField } = fieldValidators;
const { toInt } = fieldFormatters;

const fieldsConfig: FieldsConfig = {
/* Required fields config */
error_distance: {
type: FIELD_TYPES.NUMBER,
deserializer: (v) => (typeof v === 'number' && !isNaN(v) ? v : 1.0),
serializer: Number,
formatters: [toInt],
label: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.errorDistanceFieldLabel',
{
Expand All @@ -49,18 +50,11 @@ const fieldsConfig: FieldsConfig = {
),
validations: [
{
validator: ({ value }) => {
return isNaN(Number(value))
? {
message: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.errorDistanceError',
{
defaultMessage: 'An error distance value is required.',
}
),
}
: undefined;
},
validator: emptyField(
i18n.translate('xpack.ingestPipelines.pipelineEditor.circleForm.errorDistanceError', {
defaultMessage: 'An error distance value is required.',
})
),
},
],
},
Expand Down Expand Up @@ -110,14 +104,14 @@ export const Circle: FunctionComponent = () => {
options: [
{
value: 'shape',
label: i18n.translate(
text: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.shapeTypeShape',
{ defaultMessage: 'Shape' }
),
},
{
value: 'geo_shape',
label: i18n.translate(
text: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.shapeTypeGeoShape',
{ defaultMessage: 'Geo-shape' }
),
Expand Down

0 comments on commit 863e709

Please sign in to comment.