From 90500783bb133b79eaca3677a2a3cd34bd815e46 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Thu, 3 Oct 2024 18:21:38 +0100 Subject: [PATCH 1/9] investigate cypress MKI flaky tests --- .../detection_engine/rule_creation/threshold_rule.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts index 3243a2974836f..d8f9f78d0e74d 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts @@ -149,7 +149,7 @@ describe( cy.get(ALERT_GRID_CELL).contains(rule.name); }); - it('Creates a new threshold rule with suppression enabled', () => { + it.only('Creates a new threshold rule with suppression enabled', () => { selectThresholdRuleType(); enablesAndPopulatesThresholdSuppression(5, 'h'); From cc3160c08b8001490e1a129852ce89b53f703184 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Thu, 3 Oct 2024 18:22:25 +0100 Subject: [PATCH 2/9] test --- x-pack/test/security_solution_cypress/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/package.json b/x-pack/test/security_solution_cypress/package.json index 5f7fc4fadf2bf..cd03ed019b8e0 100644 --- a/x-pack/test/security_solution_cypress/package.json +++ b/x-pack/test/security_solution_cypress/package.json @@ -29,7 +29,7 @@ "cypress:entity_analytics:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/entity_analytics/**/*.cy.ts'", "cypress:rule_management:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/rule_management/!(prebuilt_rules)/**/*.cy.ts'", "cypress:rule_management:prebuilt_rules:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/rule_management/prebuilt_rules/**/*.cy.ts'", - "cypress:detection_engine:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/detection_engine/!(exceptions)/**/*.cy.ts'", + "cypress:detection_engine:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/detection_engine/!(exceptions)rule_creation/threshold_rule.cy.ts'", "cypress:detection_engine:exceptions:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/detection_engine/exceptions/**/*.cy.ts'", "cypress:ai_assistant:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/ai_assistant/**/*.cy.ts'", "cypress:investigations:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/investigations/**/*.cy.ts'", From d606b2d5c126b33ba70cea62ce317b2fd2767674 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Thu, 3 Oct 2024 18:22:57 +0100 Subject: [PATCH 3/9] Update threshold_rule.cy.ts --- .../detection_engine/rule_creation/threshold_rule.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts index d8f9f78d0e74d..3243a2974836f 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts @@ -149,7 +149,7 @@ describe( cy.get(ALERT_GRID_CELL).contains(rule.name); }); - it.only('Creates a new threshold rule with suppression enabled', () => { + it('Creates a new threshold rule with suppression enabled', () => { selectThresholdRuleType(); enablesAndPopulatesThresholdSuppression(5, 'h'); From f1aa87d27437b6be2bbf7fae9ad59e8c9e6a6fa6 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Fri, 4 Oct 2024 10:44:17 +0100 Subject: [PATCH 4/9] attempt to rewrite test --- .../detection_engine/rule_creation/threshold_rule.cy.ts | 6 +++++- .../cypress/tasks/create_new_rule.ts | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts index d8f9f78d0e74d..34d786e303585 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts @@ -58,6 +58,8 @@ import { fillScheduleRuleAndContinue, selectThresholdRuleType, waitForAlertsToPopulate, + fillDefineThresholdRule, + continueFromDefineStep, } from '../../../../tasks/create_new_rule'; import { login } from '../../../../tasks/login'; import { visit } from '../../../../tasks/navigation'; @@ -152,8 +154,10 @@ describe( it.only('Creates a new threshold rule with suppression enabled', () => { selectThresholdRuleType(); + fillDefineThresholdRule(rule); enablesAndPopulatesThresholdSuppression(5, 'h'); - fillDefineThresholdRuleAndContinue(rule); + continueFromDefineStep(); + // ensures duration displayed on define step in preview mode cy.get(DEFINITION_DETAILS).within(() => { getDetails(SUPPRESS_FOR_DETAILS).should('have.text', '5h'); diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/create_new_rule.ts b/x-pack/test/security_solution_cypress/cypress/tasks/create_new_rule.ts index 68dc2cfffd908..501dd0461dd44 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/create_new_rule.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/create_new_rule.ts @@ -557,7 +557,7 @@ export const fillRuleActionFilters = (alertsFilter: AlertsFilter) => { .type(`{selectall}${alertsFilter.timeframe.timezone}{enter}`); }; -export const fillDefineThresholdRuleAndContinue = (rule: ThresholdRuleCreateProps) => { +export const fillDefineThresholdRule = (rule: ThresholdRuleCreateProps) => { const thresholdField = 0; const threshold = 1; @@ -578,7 +578,11 @@ export const fillDefineThresholdRuleAndContinue = (rule: ThresholdRuleCreateProp cy.wrap(inputs[threshold]).clear(); cy.wrap(inputs[threshold]).type(`${rule.threshold.value}`); }); - cy.get(DEFINE_CONTINUE_BUTTON).should('exist').click({ force: true }); +}; + +export const fillDefineThresholdRuleAndContinue = (rule: ThresholdRuleCreateProps) => { + fillDefineThresholdRule(rule); + continueFromDefineStep(); }; export const fillDefineEqlRule = (rule: EqlRuleCreateProps) => { @@ -908,6 +912,7 @@ export const enablesAndPopulatesThresholdSuppression = ( // enables suppression for threshold rule cy.get(THRESHOLD_ENABLE_SUPPRESSION_CHECKBOX).should('not.be.checked'); cy.get(THRESHOLD_ENABLE_SUPPRESSION_CHECKBOX).click(); + cy.get(THRESHOLD_ENABLE_SUPPRESSION_CHECKBOX).should('be.checked'); setAlertSuppressionDuration(interval, timeUnit); From 4a47627753ad49d1950e9d52aa824fe56eec4a72 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:12:28 +0100 Subject: [PATCH 5/9] intended failure of test --- .../detection_engine/rule_creation/threshold_rule.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts index 8af755c6ed328..b565b90878d78 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts @@ -160,7 +160,7 @@ describe( // ensures duration displayed on define step in preview mode cy.get(DEFINITION_DETAILS).within(() => { - getDetails(SUPPRESS_FOR_DETAILS).should('have.text', '5h'); + getDetails(SUPPRESS_FOR_DETAILS).should('have.text', '6h'); }); fillAboutRuleMinimumAndContinue(rule); From e5faf018f7c1cfeec67f8ffb188146bc96366e30 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:08:38 +0100 Subject: [PATCH 6/9] Update package.json --- x-pack/test/security_solution_cypress/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/security_solution_cypress/package.json b/x-pack/test/security_solution_cypress/package.json index cd03ed019b8e0..ec41cacdea917 100644 --- a/x-pack/test/security_solution_cypress/package.json +++ b/x-pack/test/security_solution_cypress/package.json @@ -29,7 +29,7 @@ "cypress:entity_analytics:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/entity_analytics/**/*.cy.ts'", "cypress:rule_management:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/rule_management/!(prebuilt_rules)/**/*.cy.ts'", "cypress:rule_management:prebuilt_rules:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/rule_management/prebuilt_rules/**/*.cy.ts'", - "cypress:detection_engine:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/detection_engine/!(exceptions)rule_creation/threshold_rule.cy.ts'", + "cypress:detection_engine:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/detection_engine/!(exceptions)/**/*.cy.ts'", "cypress:detection_engine:exceptions:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/detection_engine/exceptions/**/*.cy.ts'", "cypress:ai_assistant:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/ai_assistant/**/*.cy.ts'", "cypress:investigations:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/investigations/**/*.cy.ts'", @@ -47,4 +47,4 @@ "cypress:run:qa:serverless:detection_engine:exceptions": "yarn cypress:qa:serverless --spec './cypress/e2e/detection_response/detection_engine/exceptions/**/*.cy.ts'", "cypress:run:qa:serverless:ai_assistant": "yarn cypress:qa:serverless --spec './cypress/e2e/ai_assistant/**/*.cy.ts'" } -} \ No newline at end of file +} From 14098748f1233e4181c5569e139b44ef0299e741 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:08:59 +0100 Subject: [PATCH 7/9] Update threshold_rule.cy.ts --- .../detection_engine/rule_creation/threshold_rule.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts index b565b90878d78..8af755c6ed328 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts @@ -160,7 +160,7 @@ describe( // ensures duration displayed on define step in preview mode cy.get(DEFINITION_DETAILS).within(() => { - getDetails(SUPPRESS_FOR_DETAILS).should('have.text', '6h'); + getDetails(SUPPRESS_FOR_DETAILS).should('have.text', '5h'); }); fillAboutRuleMinimumAndContinue(rule); From 73d0c0dd8749eaf9dcba76c1633b1dd6b73a676d Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:11:55 +0100 Subject: [PATCH 8/9] remove EOF --- x-pack/test/security_solution_cypress/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/package.json b/x-pack/test/security_solution_cypress/package.json index ec41cacdea917..5f7fc4fadf2bf 100644 --- a/x-pack/test/security_solution_cypress/package.json +++ b/x-pack/test/security_solution_cypress/package.json @@ -47,4 +47,4 @@ "cypress:run:qa:serverless:detection_engine:exceptions": "yarn cypress:qa:serverless --spec './cypress/e2e/detection_response/detection_engine/exceptions/**/*.cy.ts'", "cypress:run:qa:serverless:ai_assistant": "yarn cypress:qa:serverless --spec './cypress/e2e/ai_assistant/**/*.cy.ts'" } -} +} \ No newline at end of file From e6d79cdec70a12beafd7e96e58cb26367893dae0 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:19:11 +0100 Subject: [PATCH 9/9] Update threshold_rule.cy.ts --- .../detection_engine/rule_creation/threshold_rule.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts index 91a7f0081fe30..8af755c6ed328 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/threshold_rule.cy.ts @@ -70,7 +70,7 @@ import { CREATE_RULE_URL } from '../../../../urls/navigation'; describe( 'Threshold rules', { - tags: ['@ess', '@serverless', '@skipInServerlessMKI'], + tags: ['@ess', '@serverless'], }, () => { const rule = getNewThresholdRule();