Skip to content

Commit

Permalink
updates rules tests (#1171) (#1172)
Browse files Browse the repository at this point in the history
related to:
opensearch-project/security-analytics-dashboards-plugin#963

Signed-off-by: Amardeepsingh Siglani <[email protected]>
(cherry picked from commit 506c38f)

Co-authored-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and amsiglan authored Mar 26, 2024
1 parent 65f58ef commit 392c062
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const SAMPLE_RULE = {
detectionLine: [
'condition: Selection_1',
'Selection_1:',
'FieldKey|contains:',
'FieldKey|all:',
'- FieldValue',
],
severity: 'Critical',
Expand Down Expand Up @@ -269,17 +269,16 @@ describe('Rules', () => {
});

it('...should validate rule description field', () => {
const longDescriptionText =
'This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text.';
const invalidDescriptionText = 'This is a invalid % description.';

getDescriptionField().should('be.empty');
getDescriptionField().type(longDescriptionText).focus().blur();
getDescriptionField().type(invalidDescriptionText).focus().blur();

getDescriptionField()
.parents('.euiFormRow__fieldWrapper')
.find('.euiFormErrorText')
.contains(
'Description should only consist of upper and lowercase letters, numbers 0-9, commas, hyphens, periods, spaces, and underscores. Max limit of 500 characters.'
'Description should only consist of upper and lowercase letters, numbers 0-9, commas, hyphens, periods, spaces, and underscores. Max limit of 65,535 characters.'
);

getDescriptionField()
Expand Down Expand Up @@ -308,13 +307,11 @@ describe('Rules', () => {
getAuthorField().should('be.empty');
getAuthorField().focus().blur();
getAuthorField().sa_containsError('Author name is required');
getAuthorField().type('text').focus().blur();
getAuthorField().sa_containsError('Invalid author.');

getAuthorField()
.type('{selectall}')
.type('{backspace}')
.type('tex&')
.type('tex%')
.focus()
.blur();
getAuthorField().sa_containsError('Invalid author.');
Expand Down

0 comments on commit 392c062

Please sign in to comment.