Skip to content

Commit

Permalink
Bringing cypress tests back (#109129) (#109303)
Browse files Browse the repository at this point in the history
* fixes threshold cypress tests

* add ticket command

* fixes threshold cypress tests

* add ticket command

* fixes 'Creates a new case with timeline and opens the timeline' test

* unskips navigation tests

* removes 'sets correct classes when the user starts dragging a host, but is not hovering over the data providers' test since we are not supporting drag and drop on timeline

* removes drag and drop related tests from 'data_providers.spec.ts'

* modifies todo on skipped exceptions tests to add more clarity

* fixes 'attach' to case and local storage test

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
MadameSheema and kibanamachine authored Aug 20, 2021
1 parent f1cbb7b commit 72b0858
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
ALL_CASES_CLOSED_CASES_STATS,
ALL_CASES_COMMENTS_COUNT,
ALL_CASES_IN_PROGRESS_CASES_STATS,
ALL_CASES_ITEM_ACTIONS_BTN,
ALL_CASES_NAME,
ALL_CASES_OPEN_CASES_COUNT,
ALL_CASES_OPEN_CASES_STATS,
Expand All @@ -26,7 +25,6 @@ import {
import {
CASE_DETAILS_DESCRIPTION,
CASE_DETAILS_PAGE_TITLE,
// CASE_DETAILS_PUSH_TO_EXTERNAL_SERVICE_BTN,
CASE_DETAILS_STATUS,
CASE_DETAILS_TAGS,
CASE_DETAILS_USER_ACTION_DESCRIPTION_USERNAME,
Expand Down Expand Up @@ -67,8 +65,8 @@ describe('Cases', () => {
.as('mycase')
);
});
// TODO: enable once attach timeline to cases is re-enabled
it.skip('Creates a new case with timeline and opens the timeline', function () {

it('Creates a new case with timeline and opens the timeline', function () {
loginAndWaitForPageWithoutDateRange(CASES_URL);
goToCreateNewCase();
fillCasesMandatoryfields(this.mycase);
Expand All @@ -92,7 +90,6 @@ describe('Cases', () => {
cy.get(ALL_CASES_COMMENTS_COUNT).should('have.text', '0');
cy.get(ALL_CASES_OPENED_ON).should('include.text', 'ago');
cy.get(ALL_CASES_SERVICE_NOW_INCIDENT).should('have.text', 'Not pushed');
cy.get(ALL_CASES_ITEM_ACTIONS_BTN).should('exist');

goToCaseDetails();

Expand All @@ -108,7 +105,6 @@ describe('Cases', () => {
cy.get(CASE_DETAILS_USERNAMES).eq(REPORTER).should('have.text', this.mycase.reporter);
cy.get(CASE_DETAILS_USERNAMES).eq(PARTICIPANTS).should('have.text', this.mycase.reporter);
cy.get(CASE_DETAILS_TAGS).should('have.text', expectedTags);
// cy.get(CASE_DETAILS_PUSH_TO_EXTERNAL_SERVICE_BTN).should('have.attr', 'disabled');

openCaseTimeline();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ const loadDetectionsPage = (role: ROLES) => {
waitForAlertsToPopulate();
};

// TODO: This test may need changes in our UI based on RBAC
describe.skip('Alerts timeline', () => {
describe('Alerts timeline', () => {
before(() => {
// First we login as a privileged user to create alerts.
cleanKibana();
Expand All @@ -45,7 +44,7 @@ describe.skip('Alerts timeline', () => {
});

it('should not allow user with read only privileges to attach alerts to cases', () => {
cy.get(TIMELINE_CONTEXT_MENU_BTN).first().click();
cy.get(TIMELINE_CONTEXT_MENU_BTN).first().click({ force: true });
cy.get(ATTACH_ALERT_TO_CASE_BUTTON).should('not.exist');
});
});
Expand All @@ -56,7 +55,7 @@ describe.skip('Alerts timeline', () => {
});

it('should allow a user with crud privileges to attach alerts to cases', () => {
cy.get(TIMELINE_CONTEXT_MENU_BTN).first().click();
cy.get(TIMELINE_CONTEXT_MENU_BTN).first().click({ force: true });
cy.get(ATTACH_ALERT_TO_CASE_BUTTON).first().should('not.be.disabled');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login';

import { ALERTS_URL } from '../../urls/navigation';

// TODO: Alert counts and preview results not showing correct values. Need to fix this test
describe.skip('Detection rules, threshold', () => {
describe('Detection rules, threshold', () => {
let rule = getNewThresholdRule();
const expectedUrls = getNewThresholdRule().referenceUrls.join('');
const expectedFalsePositives = getNewThresholdRule().falsePositivesExamples.join('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('From alert', () => {
esArchiverUnload('auditbeat_for_exceptions2');
});

// TODO: Looks like the signal is missing some fields. Need to update to make sure it shows up
// TODO: Unskip the test when `https://github.com/elastic/kibana/issues/108244` it is fixed
it.skip('Creates an exception and deletes it', () => {
addExceptionFromFirstAlert();
addsException(getException());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('From rule', () => {
esArchiverUnload('auditbeat_for_exceptions2');
});

// TODO: Looks like the signal is missing some fields. Need to update to make sure it shows up
// TODO: Unskip the test when `https://github.com/elastic/kibana/issues/108244` it is fixed
it.skip('Creates an exception and deletes it', () => {
goToExceptionsTab();
addsExceptionFromRuleSettings(getException());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {
} from '../../screens/kibana_navigation';
import { cleanKibana } from '../../tasks/common';

describe.skip('top-level navigation common to all pages in the Security app', () => {
describe('top-level navigation common to all pages in the Security app', () => {
before(() => {
cleanKibana();
loginAndWaitForPage(TIMELINES_URL);
Expand Down Expand Up @@ -111,7 +111,7 @@ describe.skip('top-level navigation common to all pages in the Security app', ()
});
});

describe.skip('Kibana navigation to all pages in the Security app ', () => {
describe('Kibana navigation to all pages in the Security app ', () => {
before(() => {
loginAndWaitForPage(KIBANA_HOME);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,12 @@
*/

import {
TIMELINE_DATA_PROVIDERS,
TIMELINE_DATA_PROVIDERS_EMPTY,
TIMELINE_DROPPED_DATA_PROVIDERS,
TIMELINE_DATA_PROVIDERS_ACTION_MENU,
IS_DRAGGING_DATA_PROVIDERS,
TIMELINE_FLYOUT_HEADER,
TIMELINE_FLYOUT,
} from '../../screens/timeline';
import { HOSTS_NAMES_DRAGGABLE } from '../../screens/hosts/all_hosts';

import {
dragAndDropFirstHostToTimeline,
dragFirstHostToEmptyTimelineDataProviders,
unDragFirstHostToEmptyTimelineDataProviders,
dragFirstHostToTimeline,
waitForAllHostsToBeLoaded,
} from '../../tasks/hosts/all_hosts';
import { waitForAllHostsToBeLoaded } from '../../tasks/hosts/all_hosts';

import { loginAndWaitForPage } from '../../tasks/login';
import { openTimelineUsingToggle } from '../../tasks/security_main';
Expand All @@ -44,22 +33,6 @@ describe('timeline data providers', () => {
closeTimeline();
});

it.skip('renders the data provider of a host dragged from the All Hosts widget on the hosts page', () => {
dragAndDropFirstHostToTimeline();
openTimelineUsingToggle();
cy.get(`${TIMELINE_FLYOUT} ${TIMELINE_DROPPED_DATA_PROVIDERS}`)
.first()
.invoke('text')
.then((dataProviderText) => {
cy.get(HOSTS_NAMES_DRAGGABLE)
.first()
.invoke('text')
.should((hostname) => {
expect(dataProviderText).to.eq(`host.name: "${hostname}"AND`);
});
});
});

it('displays the data provider action menu when Enter is pressed', (done) => {
openTimelineUsingToggle();
addDataProvider({ field: 'host.name', operator: 'exists' }).then(() => {
Expand All @@ -77,25 +50,4 @@ describe('timeline data providers', () => {
done();
});
});

it.skip('sets correct classes when the user starts dragging a host, but is not hovering over the data providers', () => {
dragFirstHostToTimeline();

cy.get(IS_DRAGGING_DATA_PROVIDERS)
.find(TIMELINE_DATA_PROVIDERS)
.filter(':visible')
.should('have.class', 'drop-target-data-providers');
});

it.skip('render an extra highlighted area in dataProvider when the user starts dragging a host AND is hovering over the data providers', () => {
dragFirstHostToEmptyTimelineDataProviders();

cy.get(IS_DRAGGING_DATA_PROVIDERS)
.find(TIMELINE_DATA_PROVIDERS_EMPTY)
.children()
.should('exist');

// Release the dragging item so the cursor can peform other action
unDragFirstHostToEmptyTimelineDataProviders();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
import { TIMELINE_BOTTOM_BAR_TOGGLE_BUTTON } from '../../screens/security_main';
import {
CREATE_NEW_TIMELINE,
IS_DRAGGING_DATA_PROVIDERS,
TIMELINE_DATA_PROVIDERS,
TIMELINE_FLYOUT_HEADER,
TIMELINE_SETTINGS_ICON,
} from '../../screens/timeline';
import { cleanKibana } from '../../tasks/common';

import { dragFirstHostToTimeline, waitForAllHostsToBeLoaded } from '../../tasks/hosts/all_hosts';
import { waitForAllHostsToBeLoaded } from '../../tasks/hosts/all_hosts';
import { loginAndWaitForPage } from '../../tasks/login';
import {
closeTimelineUsingCloseButton,
Expand Down Expand Up @@ -78,13 +76,4 @@ describe('timeline flyout button', () => {
cy.get('[data-test-subj="nav-search-option"]').its('length').should('be.gte', 1);
closeTimelineUsingCloseButton();
});

it.skip('sets correct classes when the user starts dragging a host, but is not hovering over the data providers', () => {
dragFirstHostToTimeline();

cy.get(IS_DRAGGING_DATA_PROVIDERS)
.find(TIMELINE_DATA_PROVIDERS)
.filter(':visible')
.should('have.class', 'drop-target-data-providers');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import { loginAndWaitForPage } from '../../tasks/login';
import { HOSTS_URL } from '../../urls/navigation';
import { openEvents } from '../../tasks/hosts/main';
import { DATAGRID_HEADERS } from '../../screens/timeline';
import { TABLE_COLUMN_EVENTS_MESSAGE } from '../../screens/hosts/external_events';
import { waitsForEventsToBeLoaded } from '../../tasks/hosts/events';
import { removeColumn } from '../../tasks/timeline';

// TODO: Fix bug in persisting the columns of timeline
describe.skip('persistent timeline', () => {
describe('persistent timeline', () => {
beforeEach(() => {
cleanKibana();
loginAndWaitForPage(HOSTS_URL);
Expand All @@ -27,15 +26,18 @@ describe.skip('persistent timeline', () => {
});

it('persist the deletion of a column', function () {
cy.get(DATAGRID_HEADERS).eq(TABLE_COLUMN_EVENTS_MESSAGE).should('have.text', 'message');
removeColumn(TABLE_COLUMN_EVENTS_MESSAGE);
const MESSAGE_COLUMN = 'message';
const MESSAGE_COLUMN_POSITION = 2;

cy.get(DATAGRID_HEADERS).eq(MESSAGE_COLUMN_POSITION).should('have.text', MESSAGE_COLUMN);
removeColumn(MESSAGE_COLUMN);

cy.get(DATAGRID_HEADERS).should('have.length', this.expectedNumberOfTimelineColumns);

reload();
waitsForEventsToBeLoaded();

cy.get(DATAGRID_HEADERS).should('have.length', this.expectedNumberOfTimelineColumns);
cy.get(DATAGRID_HEADERS).each(($el) => expect($el.text()).not.equal('message'));
cy.get(DATAGRID_HEADERS).each(($el) => expect($el.text()).not.equal(MESSAGE_COLUMN));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@
export const ALL_HOSTS_TABLE = '[data-test-subj="table-allHosts-loading-false"]';

export const HOSTS_NAMES = '[data-test-subj="render-content-host.name"] a.euiLink';

export const HOSTS_NAMES_DRAGGABLE = '[data-test-subj="render-content-host.name"]';

This file was deleted.

9 changes: 2 additions & 7 deletions x-pack/plugins/security_solution/cypress/screens/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export const DATAGRID_HEADERS =

export const FAVORITE_TIMELINE = '[data-test-subj="timeline-favorite-filled-star"]';

export const FIELD_BROWSER = '[data-test-subj="show-field-browser"]';

export const GRAPH_TAB_BUTTON = '[data-test-subj="timelineTabs-graph"]';

export const HEADER = '[data-test-subj="header"]';
Expand Down Expand Up @@ -143,12 +145,8 @@ export const TIMELINE_CORRELATION_INPUT = '[data-test-subj="eqlQueryBarTextInput

export const TIMELINE_CORRELATION_TAB = '[data-test-subj="timelineTabs-eql"]';

export const IS_DRAGGING_DATA_PROVIDERS = '.is-dragging';

export const TIMELINE_BOTTOM_BAR_CONTAINER = '[data-test-subj="timeline-bottom-bar-container"]';

export const TIMELINE_DATA_PROVIDERS = '[data-test-subj="dataProviders"]';

export const TIMELINE_DATA_PROVIDERS_ACTION_MENU = '[data-test-subj="providerActions"]';

export const TIMELINE_ADD_FIELD_BUTTON = '[data-test-subj="addField"]';
Expand All @@ -161,9 +159,6 @@ export const TIMELINE_DATA_PROVIDER_VALUE = `[data-test-subj="value"]`;

export const SAVE_DATA_PROVIDER_BTN = `[data-test-subj="save"]`;

export const TIMELINE_DATA_PROVIDERS_EMPTY =
'[data-test-subj="dataProviders"] [data-test-subj="empty"]';

export const TIMELINE_DESCRIPTION = '[data-test-subj="timeline-description"]';

export const TIMELINE_DESCRIPTION_INPUT = '[data-test-subj="save-timeline-description"]';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,16 @@ export const fillDefineThresholdRuleAndContinue = (rule: ThresholdRule) => {
const thresholdField = 0;
const threshold = 1;

const typeThresholdField = ($el: Cypress.ObjectLike) => cy.wrap($el).type(rule.thresholdField);
const typeThresholdField = ($el: Cypress.ObjectLike) =>
cy.wrap($el).type(rule.thresholdField, { delay: 35 });

cy.get(IMPORT_QUERY_FROM_SAVED_TIMELINE_LINK).click();
cy.get(TIMELINE(rule.timeline.id!)).click();
cy.get(CUSTOM_QUERY_INPUT).should('have.value', rule.customQuery);
cy.get(THRESHOLD_INPUT_AREA)
.find(INPUT)
.then((inputs) => {
cy.wrap(inputs[thresholdField]).click();
cy.wrap(inputs[thresholdField]).pipe(typeThresholdField);
cy.get(THRESHOLD_FIELD_SELECTION).click({ force: true });
cy.wrap(inputs[threshold]).clear().type(rule.threshold);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,8 @@
* 2.0.
*/

import { ALL_HOSTS_TABLE, HOSTS_NAMES_DRAGGABLE, HOSTS_NAMES } from '../../screens/hosts/all_hosts';
import { TIMELINE_DATA_PROVIDERS, TIMELINE_DATA_PROVIDERS_EMPTY } from '../../screens/timeline';
import { ALL_HOSTS_TABLE, HOSTS_NAMES } from '../../screens/hosts/all_hosts';

import { drag, dragWithoutDrop, drop } from '../../tasks/common';

export const dragAndDropFirstHostToTimeline = () => {
cy.get(HOSTS_NAMES_DRAGGABLE)
.first()
.then((firstHost) => drag(firstHost));
cy.get(TIMELINE_DATA_PROVIDERS)
.filter(':visible')
.then((dataProvidersDropArea) => drop(dataProvidersDropArea));
};

export const dragFirstHostToEmptyTimelineDataProviders = () => {
cy.get(HOSTS_NAMES_DRAGGABLE)
.first()
.then((host) => drag(host));

cy.get(TIMELINE_DATA_PROVIDERS_EMPTY)
.filter(':visible')
.then((dataProvidersDropArea) => dragWithoutDrop(dataProvidersDropArea));
};

export const unDragFirstHostToEmptyTimelineDataProviders = () => {
cy.get(HOSTS_NAMES_DRAGGABLE)
.first()
.then((host) => {
cy.wrap(host)
.trigger('mousemove', {
button: 0,
clientX: host[0].getBoundingClientRect().left,
clientY: host[0].getBoundingClientRect().top,
force: true,
})
.wait(300)
.trigger('mouseup', { force: true })
.wait(300);
});
};

export const dragFirstHostToTimeline = () => {
cy.get(HOSTS_NAMES_DRAGGABLE)
.first()
.then((host) => drag(host));
};
export const openFirstHostDetails = () => {
cy.get(HOSTS_NAMES).first().click({ force: true });
};
Expand Down
Loading

0 comments on commit 72b0858

Please sign in to comment.