diff --git a/cypress/integration/2_rules.spec.js b/cypress/integration/2_rules.spec.js index 18b18f6ca..3e90ed212 100644 --- a/cypress/integration/2_rules.spec.js +++ b/cypress/integration/2_rules.spec.js @@ -330,13 +330,20 @@ describe('Rules', () => { it('...should validate selection map key field', () => { getSelectionPanelByIndex(0).within(() => { getMapKeyField().should('be.empty'); - getMapKeyField().focus().blur(); + getMapKeyField() + .focus() + .blur() + .parents('.euiFormRow__fieldWrapper') + .find('.euiFormErrorText') + .should('not.exist'); + + getMapKeyField().type('hello@'); getMapKeyField() .parentsUntil('.euiFormRow__fieldWrapper') .siblings() .contains('Invalid key name'); - getMapKeyField().type('FieldKey'); + getMapKeyField().focus().type('{selectall}').type('FieldKey'); getMapKeyField() .focus() .blur() @@ -446,7 +453,6 @@ describe('Rules', () => { getSelectionPanelByIndex(0).within(() => getMapKeyField().type('{selectall}').type('{backspace}') ); - toastShouldExist(); getSelectionPanelByIndex(0).within(() => getMapKeyField().type('FieldKey')); // selection map value field diff --git a/public/pages/Rules/components/RuleEditor/DetectionVisualEditor.tsx b/public/pages/Rules/components/RuleEditor/DetectionVisualEditor.tsx index bf63b5fa9..84390d5fe 100644 --- a/public/pages/Rules/components/RuleEditor/DetectionVisualEditor.tsx +++ b/public/pages/Rules/components/RuleEditor/DetectionVisualEditor.tsx @@ -275,7 +275,7 @@ export class DetectionVisualEditor extends React.Component< const fieldName = `field_${selIdx}_${idx}`; delete errors.fields[fieldName]; - if (!validateDetectionFieldName(data.field)) { + if (data.field && !validateDetectionFieldName(data.field)) { errors.fields[fieldName] = 'Invalid key name. Valid characters are a-z, A-Z, 0-9, hyphens, dots, and underscores'; }