From 58fc39f1b3fce0698a61441bb407a51b30561dde Mon Sep 17 00:00:00 2001 From: Amardeepsingh Siglani Date: Mon, 9 Sep 2024 19:08:42 -0500 Subject: [PATCH] uncommented tests (#1157) Signed-off-by: Amardeepsingh Siglani --- cypress/integration/1_detectors.spec.js | 262 ++++++++++++------------ 1 file changed, 131 insertions(+), 131 deletions(-) diff --git a/cypress/integration/1_detectors.spec.js b/cypress/integration/1_detectors.spec.js index 87b36c88..8a18db2c 100644 --- a/cypress/integration/1_detectors.spec.js +++ b/cypress/integration/1_detectors.spec.js @@ -224,137 +224,137 @@ describe('Detectors', () => { cy.createRule(dns_type_rule_data); }); - // describe('...should validate form fields', () => { - // beforeEach(() => { - // setupIntercept(cy, '/_plugins/_security_analytics/detectors/_search', 'detectorsSearch'); - - // // Visit Detectors page before any test - // cy.visit(`${OPENSEARCH_DASHBOARDS_URL}/detectors`); - // cy.wait('@detectorsSearch').should('have.property', 'state', 'Complete'); - - // openCreateForm(); - // }); - - // it('...should validate name field', () => { - // getNameField().should('be.empty'); - // getNameField().focus().blur(); - // getNameField().parentsUntil('.euiFormRow__fieldWrapper').siblings().contains('Enter a name.'); - - // getNameField().type('text').focus().blur(); - - // getNameField() - // .parents('.euiFormRow__fieldWrapper') - // .find('.euiFormErrorText') - // .contains( - // 'Name should only consist of upper and lowercase letters, numbers 0-9, hyphens, spaces, and underscores. Use between 5 and 50 characters.' - // ); - - // getNameField().type('{selectall}').type('{backspace}').type('tex&').focus().blur(); - - // getNameField() - // .parents('.euiFormRow__fieldWrapper') - // .find('.euiFormErrorText') - // .contains( - // 'Name should only consist of upper and lowercase letters, numbers 0-9, hyphens, spaces, and underscores. Use between 5 and 50 characters.' - // ); - - // getNameField() - // .type('{selectall}') - // .type('{backspace}') - // .type('Detector name') - // .focus() - // .blur() - // .parents('.euiFormRow__fieldWrapper') - // .find('.euiFormErrorText') - // .should('not.exist'); - // }); - - // it('...should validate 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.'; - - // getDescriptionField().should('be.empty'); - - // getDescriptionField().type(longDescriptionText).focus().blur(); - - // getDescriptionField() - // .parents('.euiFormRow__fieldWrapper') - // .find('.euiFormErrorText') - // .contains(descriptionError); - - // getDescriptionField() - // .type('{selectall}') - // .type('{backspace}') - // .type('Detector description...') - // .focus() - // .blur(); - - // getDescriptionField() - // .type('{selectall}') - // .type('{backspace}') - // .type('Detector name') - // .focus() - // .blur() - // .parents('.euiFormRow__fieldWrapper') - // .find('.euiFormErrorText') - // .should('not.exist'); - // }); - - // it('...should validate data source field', () => { - // getDataSourceField() - // .focus() - // .blur() - // .parentsUntil('.euiFormRow__fieldWrapper') - // .siblings() - // .contains('Select an input source.'); - - // getDataSourceField().selectComboboxItem(cypressIndexDns); - // getDataSourceField() - // .focus() - // .blur() - // .parentsUntil('.euiFormRow__fieldWrapper') - // .find('.euiFormErrorText') - // .should('not.exist'); - // }); - - // it('...should validate next button', () => { - // getNextButton().should('be.disabled'); - - // fillDetailsForm(detectorName, cypressIndexDns); - // getNextButton().should('be.enabled'); - // }); - - // it('...should validate alerts page', () => { - // fillDetailsForm(detectorName, cypressIndexDns); - // getNextButton().click({ force: true }); - // // Open the trigger details accordion - // cy.get('[data-test-subj="trigger-details-btn"]').click({ force: true }); - // getTriggerNameField().should('have.value', 'Trigger 1'); - // getTriggerNameField() - // .parents('.euiFormRow__fieldWrapper') - // .find('.euiFormErrorText') - // .should('not.exist'); - - // getTriggerNameField().type('{selectall}').type('{backspace}').focus().blur(); - // getCreateDetectorButton().should('be.disabled'); - - // cy.getButtonByText('Remove').click({ force: true }); - // getCreateDetectorButton().should('be.enabled'); - // }); - - // it('...should show mappings warning', () => { - // fillDetailsForm(detectorName, cypressIndexDns); - - // getDataSourceField().selectComboboxItem(cypressIndexWindows); - // getDataSourceField().focus().blur(); - - // cy.get('[data-test-subj="define-detector-diff-log-types-warning"]') - // .should('be.visible') - // .contains( - // 'To avoid issues with field mappings, we recommend creating separate detectors for different log types.' - // ); - // }); - // }); + describe('...should validate form fields', () => { + beforeEach(() => { + setupIntercept(cy, '/_plugins/_security_analytics/detectors/_search', 'detectorsSearch'); + + // Visit Detectors page before any test + cy.visit(`${OPENSEARCH_DASHBOARDS_URL}/detectors`); + cy.wait('@detectorsSearch').should('have.property', 'state', 'Complete'); + + openCreateForm(); + }); + + it('...should validate name field', () => { + getNameField().should('be.empty'); + getNameField().focus().blur(); + getNameField().parentsUntil('.euiFormRow__fieldWrapper').siblings().contains('Enter a name.'); + + getNameField().type('text').focus().blur(); + + getNameField() + .parents('.euiFormRow__fieldWrapper') + .find('.euiFormErrorText') + .contains( + 'Name should only consist of upper and lowercase letters, numbers 0-9, hyphens, spaces, and underscores. Use between 5 and 50 characters.' + ); + + getNameField().type('{selectall}').type('{backspace}').type('tex&').focus().blur(); + + getNameField() + .parents('.euiFormRow__fieldWrapper') + .find('.euiFormErrorText') + .contains( + 'Name should only consist of upper and lowercase letters, numbers 0-9, hyphens, spaces, and underscores. Use between 5 and 50 characters.' + ); + + getNameField() + .type('{selectall}') + .type('{backspace}') + .type('Detector name') + .focus() + .blur() + .parents('.euiFormRow__fieldWrapper') + .find('.euiFormErrorText') + .should('not.exist'); + }); + + it('...should validate 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.'; + + getDescriptionField().should('be.empty'); + + getDescriptionField().type(longDescriptionText).focus().blur(); + + getDescriptionField() + .parents('.euiFormRow__fieldWrapper') + .find('.euiFormErrorText') + .contains(descriptionError); + + getDescriptionField() + .type('{selectall}') + .type('{backspace}') + .type('Detector description...') + .focus() + .blur(); + + getDescriptionField() + .type('{selectall}') + .type('{backspace}') + .type('Detector name') + .focus() + .blur() + .parents('.euiFormRow__fieldWrapper') + .find('.euiFormErrorText') + .should('not.exist'); + }); + + it('...should validate data source field', () => { + getDataSourceField() + .focus() + .blur() + .parentsUntil('.euiFormRow__fieldWrapper') + .siblings() + .contains('Select an input source.'); + + getDataSourceField().selectComboboxItem(cypressIndexDns); + getDataSourceField() + .focus() + .blur() + .parentsUntil('.euiFormRow__fieldWrapper') + .find('.euiFormErrorText') + .should('not.exist'); + }); + + it('...should validate next button', () => { + getNextButton().should('be.disabled'); + + fillDetailsForm(detectorName, cypressIndexDns); + getNextButton().should('be.enabled'); + }); + + it('...should validate alerts page', () => { + fillDetailsForm(detectorName, cypressIndexDns); + getNextButton().click({ force: true }); + // Open the trigger details accordion + cy.get('[data-test-subj="trigger-details-btn"]').click({ force: true }); + getTriggerNameField().should('have.value', 'Trigger 1'); + getTriggerNameField() + .parents('.euiFormRow__fieldWrapper') + .find('.euiFormErrorText') + .should('not.exist'); + + getTriggerNameField().type('{selectall}').type('{backspace}').focus().blur(); + getCreateDetectorButton().should('be.disabled'); + + cy.getButtonByText('Remove').click({ force: true }); + getCreateDetectorButton().should('be.enabled'); + }); + + it('...should show mappings warning', () => { + fillDetailsForm(detectorName, cypressIndexDns); + + getDataSourceField().selectComboboxItem(cypressIndexWindows); + getDataSourceField().focus().blur(); + + cy.get('[data-test-subj="define-detector-diff-log-types-warning"]') + .should('be.visible') + .contains( + 'To avoid issues with field mappings, we recommend creating separate detectors for different log types.' + ); + }); + }); describe('...validate create detector flow', () => { beforeEach(() => {