From 5080d27cf8a24edd16f805265c2044c83cb8d12f Mon Sep 17 00:00:00 2001 From: Amardeepsingh Siglani Date: Wed, 10 Apr 2024 04:33:34 -0700 Subject: [PATCH] fixed tests Signed-off-by: Amardeepsingh Siglani --- .../1_detectors.spec.js | 11 +++++++++++ .../2_rules.spec.js | 13 +++++++------ .../security-analytics-dashboards-plugin/rules.js | 4 ++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/cypress/integration/plugins/security-analytics-dashboards-plugin/1_detectors.spec.js b/cypress/integration/plugins/security-analytics-dashboards-plugin/1_detectors.spec.js index 0d65f9336..2ab346868 100644 --- a/cypress/integration/plugins/security-analytics-dashboards-plugin/1_detectors.spec.js +++ b/cypress/integration/plugins/security-analytics-dashboards-plugin/1_detectors.spec.js @@ -269,6 +269,17 @@ describe('Detectors', () => { .realType(cypressIndexWindows) .realPress('Enter'); + // Select appropriate names to map fields to + for (let field_name in testMappings.properties) { + const mappedTo = testMappings.properties[field_name].path; + + cy.contains('tr', field_name).within(() => { + cy.get(`[data-test-subj="detector-field-mappings-select"]`) + .click() + .type(mappedTo); + }); + } + // Change detector scheduling cy.get(`[data-test-subj="detector-schedule-number-select"]`) .ospClear() diff --git a/cypress/integration/plugins/security-analytics-dashboards-plugin/2_rules.spec.js b/cypress/integration/plugins/security-analytics-dashboards-plugin/2_rules.spec.js index 54cbfd2b3..e56311830 100644 --- a/cypress/integration/plugins/security-analytics-dashboards-plugin/2_rules.spec.js +++ b/cypress/integration/plugins/security-analytics-dashboards-plugin/2_rules.spec.js @@ -310,8 +310,6 @@ describe('Rules', () => { }); it('...can be deleted', () => { - setupIntercept(cy, NODE_API.RULES_SEARCH, 'getRules'); - cy.get(`input[placeholder="Search rules"]`).ospSearch(SAMPLE_RULE.name); // Click the rule link to open the details flyout @@ -336,13 +334,16 @@ describe('Rules', () => { .click({ force: true }) ); - cy.wait(5000); - cy.wait('@getRules'); + cy.wait(2000); - // Search for sample_detector, presumably deleted + setupIntercept(cy, NODE_API.RULES_SEARCH, 'getRules'); + cy.reload(); + + // Search for the custom rule, presumably deleted + cy.wait('@getRules'); cy.wait(3000); cy.get(`input[placeholder="Search rules"]`).ospSearch(SAMPLE_RULE.name); - // Click the rule link to open the details flyout + // The rule link should not exist cy.get('tbody').contains(SAMPLE_RULE.name).should('not.exist'); }); }); diff --git a/cypress/utils/plugins/security-analytics-dashboards-plugin/rules.js b/cypress/utils/plugins/security-analytics-dashboards-plugin/rules.js index 53313fa94..b76171a17 100644 --- a/cypress/utils/plugins/security-analytics-dashboards-plugin/rules.js +++ b/cypress/utils/plugins/security-analytics-dashboards-plugin/rules.js @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -const { BASE_PATH } = require('../../base_constants'); +const { BASE_PATH, BACKEND_BASE_PATH } = require('../../base_constants'); const { FEATURE_SYSTEM_INDICES, NODE_API } = require('./constants'); Cypress.Commands.add('createRule', (ruleJSON) => { @@ -55,7 +55,7 @@ Cypress.Commands.add('deleteRule', (ruleName) => { }); Cypress.Commands.add('deleteAllCustomRules', () => { - const url = `${BASE_PATH}/${FEATURE_SYSTEM_INDICES.CUSTOM_RULES_INDEX}`; + const url = `${BACKEND_BASE_PATH}/${FEATURE_SYSTEM_INDICES.CUSTOM_RULES_INDEX}`; cy.request({ method: 'DELETE', url: url,