diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_callouts_readonly.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_callouts_readonly.spec.ts index 2b76660d44cec..23798fb38a794 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_callouts_readonly.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_callouts_readonly.spec.ts @@ -7,6 +7,7 @@ import { ROLES } from '../../common/test'; import { DETECTIONS_RULE_MANAGEMENT_URL, DETECTIONS_URL } from '../urls/navigation'; import { newRule } from '../objects/rule'; +import { PAGE_TITLE } from '../screens/common/page'; import { login, @@ -17,7 +18,21 @@ import { import { waitForAlertsIndexToBeCreated } from '../tasks/alerts'; import { goToRuleDetails } from '../tasks/alerts_detection_rules'; import { createCustomRule, deleteCustomRule, removeSignalsIndex } from '../tasks/api_calls/rules'; -import { getCallOut, waitForCallOutToBeShown, dismissCallOut } from '../tasks/detections/callouts'; +import { getCallOut, waitForCallOutToBeShown, dismissCallOut } from '../tasks/common/callouts'; + +const loadPageAsReadOnlyUser = (url: string) => { + waitForPageWithoutDateRange(url, ROLES.reader); + waitForPageTitleToBeShown(); +}; + +const reloadPage = () => { + cy.reload(); + waitForPageTitleToBeShown(); +}; + +const waitForPageTitleToBeShown = () => { + cy.get(PAGE_TITLE).should('be.visible'); +}; describe('Detections > Callouts indicating read-only access to resources', () => { const ALERTS_CALLOUT = 'read-only-access-to-alerts'; @@ -115,17 +130,3 @@ describe('Detections > Callouts indicating read-only access to resources', () => }); }); }); - -const loadPageAsReadOnlyUser = (url: string) => { - waitForPageWithoutDateRange(url, ROLES.reader); - waitForPageTitleToBeShown(); -}; - -const reloadPage = () => { - cy.reload(); - waitForPageTitleToBeShown(); -}; - -const waitForPageTitleToBeShown = () => { - cy.get('[data-test-subj="header-page-title"]').should('be.visible'); -}; diff --git a/x-pack/plugins/security_solution/cypress/screens/common/callouts.ts b/x-pack/plugins/security_solution/cypress/screens/common/callouts.ts new file mode 100644 index 0000000000000..cbfd59b88f432 --- /dev/null +++ b/x-pack/plugins/security_solution/cypress/screens/common/callouts.ts @@ -0,0 +1,11 @@ +/* + * 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 CALLOUT = '[data-test-subj^="callout-"]'; + +export const callOutWithId = (id: string) => `[data-test-subj="callout-${id}"]`; + +export const CALLOUT_DISMISS_BTN = '[data-test-subj^="callout-dismiss-"]'; diff --git a/x-pack/plugins/security_solution/cypress/screens/common/page.ts b/x-pack/plugins/security_solution/cypress/screens/common/page.ts new file mode 100644 index 0000000000000..f7ddd5cf8d3b7 --- /dev/null +++ b/x-pack/plugins/security_solution/cypress/screens/common/page.ts @@ -0,0 +1,7 @@ +/* + * 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 PAGE_TITLE = '[data-test-subj="header-page-title"]'; diff --git a/x-pack/plugins/security_solution/cypress/tasks/detections/callouts.ts b/x-pack/plugins/security_solution/cypress/tasks/common/callouts.ts similarity index 77% rename from x-pack/plugins/security_solution/cypress/tasks/detections/callouts.ts rename to x-pack/plugins/security_solution/cypress/tasks/common/callouts.ts index 2fbfaf3b5b0b8..dec302ade1e4a 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/detections/callouts.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/common/callouts.ts @@ -4,8 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ +import { callOutWithId, CALLOUT_DISMISS_BTN } from '../../screens/common/callouts'; + export const getCallOut = (id: string, options?: Cypress.Timeoutable) => { - return cy.get(`[data-test-subj="callout-${id}"]`, options); + return cy.get(callOutWithId(id), options); }; export const waitForCallOutToBeShown = (id: string, color: string) => { @@ -16,7 +18,7 @@ export const waitForCallOutToBeShown = (id: string, color: string) => { export const dismissCallOut = (id: string) => { getCallOut(id, { timeout: 10000 }).within(() => { - cy.get('[data-test-subj^="callout-dismiss-"]').should('be.visible').click(); + cy.get(CALLOUT_DISMISS_BTN).should('be.visible').click(); cy.root().should('not.exist'); }); }; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/index.test.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/index.test.tsx index 9690d3845aa3a..bfd7801ea5ed4 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/index.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/index.test.tsx @@ -49,14 +49,6 @@ jest.mock('../../../containers/detection_engine/rules/api', () => ({ createPrepackagedRules: jest.fn(), })); -// jest.mock('../../../../common/lib/kibana', () => { -// return { -// useToast: jest.fn(), -// useHttp: jest.fn(), -// useKibana: jest.fn(), -// }; -// }); - jest.mock('../../../components/value_lists_management_modal', () => { return { ValueListsModal: jest.fn().mockReturnValue(
),