Skip to content

Commit

Permalink
[Part 2] Simplify detector creation UX (opensearch-project#738)
Browse files Browse the repository at this point in the history
* removed review page; enhanced alerts page

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* updated tests

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* updated trigger details subheading to use selected data

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* updated define detector, overview pages

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* reverting cypress workflow

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* updated field mapping texts

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

---------

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
  • Loading branch information
amsiglan authored Oct 4, 2023
1 parent 87bcabb commit 8a7bf7d
Show file tree
Hide file tree
Showing 22 changed files with 1,658 additions and 1,545 deletions.
55 changes: 15 additions & 40 deletions cypress/integration/1_detectors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const createDetector = (detectorName, dataSource, expectFailure) => {
.click({ force: true, timeout: 5000 })
.then(() => cy.contains('.euiTable .euiTableRow', 'Dns'));

cy.getElementByText('.euiAccordion .euiTitle', 'Configure field mapping - optional');
cy.getElementByText('.euiAccordion .euiTitle', 'Field mapping - optional');
cy.get('[aria-controls="mappedTitleFieldsAccordion"]').then(($btn) => {
// first check if the accordion is expanded, if not than expand the accordion
if ($btn && $btn[0] && $btn[0].getAttribute('aria-expanded') === 'false') {
Expand All @@ -141,8 +141,9 @@ const createDetector = (detectorName, dataSource, expectFailure) => {
getNextButton().click({ force: true });

// TEST ALERTS PAGE
// Open the trigger details accordion
cy.get('[data-test-subj="trigger-details-btn"]').click({ force: true });
cy.getElementByText('.euiTitle.euiTitle--medium', 'Set up alert triggers');
cy.getInputByPlaceholder('Enter a name to describe the alert condition').type('test_trigger');
cy.getElementByTestSubject('alert-tags-combo-box')
.type(`attack.defense_evasion{enter}`)
.find('input')
Expand All @@ -151,27 +152,8 @@ const createDetector = (detectorName, dataSource, expectFailure) => {

cy.getFieldByLabel('Specify alert severity').selectComboboxItem('1 (Highest)');

// go to review page
getNextButton().click({ force: true });

// TEST REVIEW AND CREATE PAGE
cy.getElementByText('.euiTitle', 'Review and create');
cy.getElementByText('.euiTitle', 'Detector details');
cy.getElementByText('.euiTitle', 'Field mapping');
cy.getElementByText('.euiTitle', 'Alert triggers');

cy.validateDetailsItem('Detector name', detectorName);
cy.validateDetailsItem('Description', '-');
cy.validateDetailsItem('Detector schedule', 'Every 1 minute');
cy.validateDetailsItem('Detection rules', '14');
cy.validateDetailsItem('Created at', '-');
cy.validateDetailsItem('Last updated time', '-');
cy.validateDetailsItem('Detector dashboard', 'Not available for this log type');

validateAlertPanel('test_trigger');

cy.intercept('POST', '/mappings').as('createMappingsRequest');
cy.intercept('POST', '/detectors').as('createDetectorRequest');
cy.intercept('POST', '/_plugins/_security_analytics/mappings').as('createMappingsRequest');
cy.intercept('POST', '/_plugins/_security_analytics/detectors').as('createDetectorRequest');

// create the detector
cy.getElementByText('button', 'Create').click({ force: true });
Expand Down Expand Up @@ -199,7 +181,7 @@ const createDetector = (detectorName, dataSource, expectFailure) => {

cy.wait(5000); // waiting for the page to be reloaded after pushing detector id into route
cy.getElementByText('button.euiTab', 'Alert triggers').should('be.visible').click();
validateAlertPanel('test_trigger');
validateAlertPanel('Trigger 1');
});
});
});
Expand Down Expand Up @@ -239,7 +221,7 @@ describe('Detectors', () => {

describe('...should validate form fields', () => {
beforeEach(() => {
cy.intercept('/detectors/_search').as('detectorsSearch');
cy.intercept('/_plugins/_security_analytics/detectors/_search').as('detectorsSearch');

// Visit Detectors page before any test
cy.visit(`${OPENSEARCH_DASHBOARDS_URL}/detectors`);
Expand Down Expand Up @@ -342,28 +324,21 @@ describe('Detectors', () => {
it('...should validate alerts page', () => {
fillDetailsForm(detectorName, cypressIndexDns);
getNextButton().click({ force: true });
getTriggerNameField().should('be.empty');

getTriggerNameField().focus().blur();
getTriggerNameField()
.parents('.euiFormRow__fieldWrapper')
.find('.euiFormErrorText')
.contains('Enter a name.');

getTriggerNameField().type('Trigger name').focus().blur();

// 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');

getNextButton().should('be.enabled');
getCreateDetectorButton().should('be.enabled');

getTriggerNameField().type('{selectall}').type('{backspace}').focus().blur();
getNextButton().should('be.disabled');
getCreateDetectorButton().should('be.disabled');

cy.getButtonByText('Remove').click({ force: true });
getNextButton().should('be.enabled');
getCreateDetectorButton().should('be.enabled');
});

it('...should show mappings warning', () => {
Expand All @@ -382,7 +357,7 @@ describe('Detectors', () => {

describe('...validate create detector flow', () => {
beforeEach(() => {
cy.intercept('/detectors/_search').as('detectorsSearch');
cy.intercept('/_plugins/_security_analytics/detectors/_search').as('detectorsSearch');

// Visit Detectors page before any test
cy.visit(`${OPENSEARCH_DASHBOARDS_URL}/detectors`);
Expand All @@ -400,7 +375,7 @@ describe('Detectors', () => {
});

it('...basic details can be edited', () => {
cy.intercept('GET', '/indices').as('getIndices');
cy.intercept('GET', '/_plugins/_security_analytics/indices').as('getIndices');
openDetectorDetails(detectorName);

editDetectorDetails(detectorName, 'Detector details');
Expand Down
Loading

0 comments on commit 8a7bf7d

Please sign in to comment.