diff --git a/x-pack/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts b/x-pack/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts index b7e42f7e46a706..24325676f0cca0 100644 --- a/x-pack/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts +++ b/x-pack/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { newRule, totalNumberOfPrebuiltRules } from '../objects/rule'; +import { newRule, totalNumberOfPrebuiltRulesInEsArchive } from '../objects/rule'; import { ABOUT_FALSE_POSITIVES, @@ -91,7 +91,7 @@ describe('Signal detection rules, custom', () => { changeToThreeHundredRowsPerPage(); waitForRulesToBeLoaded(); - const expectedNumberOfRules = totalNumberOfPrebuiltRules + 1; + const expectedNumberOfRules = totalNumberOfPrebuiltRulesInEsArchive + 1; cy.get(RULES_TABLE).then($table => { cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); }); diff --git a/x-pack/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts b/x-pack/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts index db56193c6b51c7..ad56c905aa4fc5 100644 --- a/x-pack/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts +++ b/x-pack/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { machineLearningRule, totalNumberOfPrebuiltRules } from '../objects/rule'; +import { machineLearningRule, totalNumberOfPrebuiltRulesInEsArchive } from '../objects/rule'; import { ABOUT_FALSE_POSITIVES, @@ -88,7 +88,7 @@ describe('Signal detection rules, machine learning', () => { changeToThreeHundredRowsPerPage(); waitForRulesToBeLoaded(); - const expectedNumberOfRules = totalNumberOfPrebuiltRules + 1; + const expectedNumberOfRules = totalNumberOfPrebuiltRulesInEsArchive + 1; cy.get(RULES_TABLE).then($table => { cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); }); diff --git a/x-pack/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts b/x-pack/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts index 74a11fb455ac0f..866302e81e1a02 100644 --- a/x-pack/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts +++ b/x-pack/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts @@ -28,12 +28,7 @@ import { waitForSignalsIndexToBeCreated, waitForSignalsPanelToBeLoaded, } from '../tasks/detections'; -import { - esArchiverLoad, - esArchiverLoadEmptyKibana, - esArchiverUnloadEmptyKibana, - esArchiverUnload, -} from '../tasks/es_archiver'; +import { esArchiverLoadEmptyKibana, esArchiverUnloadEmptyKibana } from '../tasks/es_archiver'; import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; import { DETECTIONS } from '../urls/navigation'; @@ -76,15 +71,32 @@ describe('Signal detection rules, prebuilt rules', () => { describe('Deleting prebuilt rules', () => { beforeEach(() => { - esArchiverLoad('prebuilt_rules_loaded'); + const expectedNumberOfRules = totalNumberOfPrebuiltRules; + const expectedElasticRulesBtnText = `Elastic rules (${expectedNumberOfRules})`; + + esArchiverLoadEmptyKibana(); loginAndWaitForPageWithoutDateRange(DETECTIONS); waitForSignalsPanelToBeLoaded(); waitForSignalsIndexToBeCreated(); goToManageSignalDetectionRules(); + waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded(); + loadPrebuiltDetectionRules(); + waitForPrebuiltDetectionRulesToBeLoaded(); + + cy.get(ELASTIC_RULES_BTN) + .invoke('text') + .should('eql', expectedElasticRulesBtnText); + + changeToThreeHundredRowsPerPage(); + waitForRulesToBeLoaded(); + + cy.get(RULES_TABLE).then($table => { + cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); + }); }); afterEach(() => { - esArchiverUnload('prebuilt_rules_loaded'); + esArchiverUnloadEmptyKibana(); }); it('Does not allow to delete one rule when more than one is selected', () => { diff --git a/x-pack/plugins/siem/cypress/objects/rule.ts b/x-pack/plugins/siem/cypress/objects/rule.ts index 4e0189ea597da1..7ce8aa69f33390 100644 --- a/x-pack/plugins/siem/cypress/objects/rule.ts +++ b/x-pack/plugins/siem/cypress/objects/rule.ts @@ -4,7 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -export const totalNumberOfPrebuiltRules = 127; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { rawRules } from '../../server/lib/detection_engine/rules/prepackaged_rules/index'; + +export const totalNumberOfPrebuiltRules = rawRules.length; + +export const totalNumberOfPrebuiltRulesInEsArchive = 127; interface Mitre { tactic: string; diff --git a/x-pack/plugins/siem/cypress/tsconfig.json b/x-pack/plugins/siem/cypress/tsconfig.json index b9c1d950eaaef6..929a3fb39babb0 100644 --- a/x-pack/plugins/siem/cypress/tsconfig.json +++ b/x-pack/plugins/siem/cypress/tsconfig.json @@ -8,6 +8,7 @@ "types": [ "cypress", "node" - ] - } -} \ No newline at end of file + ], + "resolveJsonModule": true, + }, +}