Skip to content

Commit

Permalink
Clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
banderror committed Dec 15, 2020
1 parent 732211e commit b336286
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -17,7 +18,7 @@ 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';

describe('Detections > Callouts indicating read-only access to resources', () => {
const ALERTS_CALLOUT = 'read-only-access-to-alerts';
Expand Down Expand Up @@ -127,5 +128,5 @@ const reloadPage = () => {
};

const waitForPageTitleToBeShown = () => {
cy.get('[data-test-subj="header-page-title"]').should('be.visible');
cy.get(PAGE_TITLE).should('be.visible');
};
Original file line number Diff line number Diff line change
@@ -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-"]';
Original file line number Diff line number Diff line change
@@ -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"]';
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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');
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -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(<div />),
Expand Down

0 comments on commit b336286

Please sign in to comment.