forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SIEM] Adds 'Load prebuilt rules' Cypress test (elastic#59529)
* adds 'load prebuilt rules' * fixes typecheck issue * updates jest snapshot
- Loading branch information
1 parent
5db1b0a
commit 9ab4aa0
Showing
13 changed files
with
166 additions
and
3 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { ELASTIC_RULES_BTN, RULES_TABLE, RULES_ROW } from '../screens/signal_detection_rules'; | ||
|
||
import { | ||
changeToThreeHundredRowsPerPage, | ||
loadPrebuiltDetectionRules, | ||
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded, | ||
waitForPrebuiltDetectionRulesToBeLoaded, | ||
waitForRulesToBeLoaded, | ||
} from '../tasks/signal_detection_rules'; | ||
import { | ||
goToManageSignalDetectionRules, | ||
waitForSignalsIndexToBeCreated, | ||
waitForSignalsPanelToBeLoaded, | ||
} from '../tasks/detections'; | ||
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; | ||
|
||
import { DETECTIONS } from '../urls/navigation'; | ||
|
||
describe('Signal detection rules', () => { | ||
before(() => { | ||
loginAndWaitForPageWithoutDateRange(DETECTIONS); | ||
}); | ||
it('Loads prebuilt rules', () => { | ||
waitForSignalsPanelToBeLoaded(); | ||
waitForSignalsIndexToBeCreated(); | ||
goToManageSignalDetectionRules(); | ||
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded(); | ||
loadPrebuiltDetectionRules(); | ||
waitForPrebuiltDetectionRulesToBeLoaded(); | ||
|
||
const expectedElasticRulesBtnText = 'Elastic rules (92)'; | ||
cy.get(ELASTIC_RULES_BTN) | ||
.invoke('text') | ||
.should('eql', expectedElasticRulesBtnText); | ||
|
||
changeToThreeHundredRowsPerPage(); | ||
waitForRulesToBeLoaded(); | ||
|
||
const expectedNumberOfRules = 92; | ||
cy.get(RULES_TABLE).then($table => { | ||
cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const LOADING_SIGNALS_PANEL = '[data-test-subj="loading-signals-panel"]'; | ||
|
||
export const MANAGE_SIGNAL_DETECTION_RULES_BTN = '[data-test-subj="manage-signal-detection-rules"]'; |
22 changes: 22 additions & 0 deletions
22
x-pack/legacy/plugins/siem/cypress/screens/signal_detection_rules.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const ELASTIC_RULES_BTN = '[data-test-subj="show-elastic-rules-filter-button"]'; | ||
|
||
export const LOAD_PREBUILT_RULES_BTN = '[data-test-subj="load-prebuilt-rules"]'; | ||
|
||
export const LOADING_INITIAL_PREBUILT_RULES_TABLE = | ||
'[data-test-subj="initialLoadingPanelAllRulesTable"]'; | ||
|
||
export const LOADING_SPINNER = '[data-test-subj="loading-spinner"]'; | ||
|
||
export const PAGINATION_POPOVER_BTN = '[data-test-subj="tablePaginationPopoverButton"]'; | ||
|
||
export const RULES_TABLE = '[data-test-subj="rules-table"]'; | ||
|
||
export const RULES_ROW = '.euiTableRow'; | ||
|
||
export const THREE_HUNDRED_ROWS = '[data-test-subj="tablePagination-300-rows"]'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { LOADING_SIGNALS_PANEL, MANAGE_SIGNAL_DETECTION_RULES_BTN } from '../screens/detections'; | ||
|
||
export const goToManageSignalDetectionRules = () => { | ||
cy.get(MANAGE_SIGNAL_DETECTION_RULES_BTN) | ||
.should('exist') | ||
.click({ force: true }); | ||
}; | ||
|
||
export const waitForSignalsIndexToBeCreated = () => { | ||
cy.request({ url: '/api/detection_engine/index', retryOnStatusCodeFailure: true }).then( | ||
response => { | ||
if (response.status !== 200) { | ||
cy.wait(7500); | ||
} | ||
} | ||
); | ||
}; | ||
|
||
export const waitForSignalsPanelToBeLoaded = () => { | ||
cy.get(LOADING_SIGNALS_PANEL).should('exist'); | ||
cy.get(LOADING_SIGNALS_PANEL).should('not.exist'); | ||
}; |
40 changes: 40 additions & 0 deletions
40
x-pack/legacy/plugins/siem/cypress/tasks/signal_detection_rules.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
LOAD_PREBUILT_RULES_BTN, | ||
LOADING_INITIAL_PREBUILT_RULES_TABLE, | ||
LOADING_SPINNER, | ||
PAGINATION_POPOVER_BTN, | ||
RULES_TABLE, | ||
THREE_HUNDRED_ROWS, | ||
} from '../screens/signal_detection_rules'; | ||
|
||
export const changeToThreeHundredRowsPerPage = () => { | ||
cy.get(PAGINATION_POPOVER_BTN).click({ force: true }); | ||
cy.get(THREE_HUNDRED_ROWS).click(); | ||
}; | ||
|
||
export const loadPrebuiltDetectionRules = () => { | ||
cy.get(LOAD_PREBUILT_RULES_BTN) | ||
.should('exist') | ||
.click({ force: true }); | ||
}; | ||
|
||
export const waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded = () => { | ||
cy.get(LOADING_INITIAL_PREBUILT_RULES_TABLE).should('exist'); | ||
cy.get(LOADING_INITIAL_PREBUILT_RULES_TABLE).should('not.exist'); | ||
}; | ||
|
||
export const waitForPrebuiltDetectionRulesToBeLoaded = () => { | ||
cy.get(LOAD_PREBUILT_RULES_BTN).should('not.exist'); | ||
cy.get(RULES_TABLE).should('exist'); | ||
}; | ||
|
||
export const waitForRulesToBeLoaded = () => { | ||
cy.get(LOADING_SPINNER).should('exist'); | ||
cy.get(LOADING_SPINNER).should('not.exist'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
x-pack/legacy/plugins/siem/public/components/loader/__snapshots__/index.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters