Skip to content

Commit

Permalink
Allow empty field name for supporting timeframe and keywords when val…
Browse files Browse the repository at this point in the history
…idating rule during creation/update (opensearch-project#823)

* allow empty field name for supporting timeframe and keywords

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* fixed cypress test

Signed-off-by: Amardeepsingh Siglani <[email protected]>

---------

Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan committed Feb 14, 2024
1 parent d6c5af0 commit ceb7800
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions cypress/integration/2_rules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down

0 comments on commit ceb7800

Please sign in to comment.