Skip to content

Commit

Permalink
[8.x] [Security Solution] Unskips Timeline Cypress tests (#195721) (#…
Browse files Browse the repository at this point in the history
…197944)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution] Unskips Timeline Cypress tests
(#195721)](#195721)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jatin
Kathuria","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-25T17:14:49Z","message":"[Security
Solution] Unskips Timeline Cypress tests (#195721)\n\n##
Summary\r\n\r\nFixes below Flaky tests issues :\r\n\r\n- [x]
https://github.com/elastic/kibana/issues/180688\r\n- [x]
https://github.com/elastic/kibana/issues/176945\r\n- [x]
https://github.com/elastic/kibana/issues/175180\r\n- [x]
https://github.com/elastic/kibana/issues/181466\r\n- [x]
https://github.com/elastic/kibana/issues/182021\r\n- [x]
https://github.com/elastic/kibana/issues/183085\r\n- [x]
https://github.com/elastic/kibana/issues/175180\r\n\r\n---------\r\n\r\nCo-authored-by:
Michael Olorunnisola
<[email protected]>","sha":"5bd8ff528c37aa77e099d8ecc224a1f7468412b5","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","release_note:skip","v9.0.0","Team:Threat
Hunting:Investigations","v8.16.0"],"number":195721,"url":"https://github.com/elastic/kibana/pull/195721","mergeCommit":{"message":"[Security
Solution] Unskips Timeline Cypress tests (#195721)\n\n##
Summary\r\n\r\nFixes below Flaky tests issues :\r\n\r\n- [x]
https://github.com/elastic/kibana/issues/180688\r\n- [x]
https://github.com/elastic/kibana/issues/176945\r\n- [x]
https://github.com/elastic/kibana/issues/175180\r\n- [x]
https://github.com/elastic/kibana/issues/181466\r\n- [x]
https://github.com/elastic/kibana/issues/182021\r\n- [x]
https://github.com/elastic/kibana/issues/183085\r\n- [x]
https://github.com/elastic/kibana/issues/175180\r\n\r\n---------\r\n\r\nCo-authored-by:
Michael Olorunnisola
<[email protected]>","sha":"5bd8ff528c37aa77e099d8ecc224a1f7468412b5"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195721","number":195721,"mergeCommit":{"message":"[Security
Solution] Unskips Timeline Cypress tests (#195721)\n\n##
Summary\r\n\r\nFixes below Flaky tests issues :\r\n\r\n- [x]
https://github.com/elastic/kibana/issues/180688\r\n- [x]
https://github.com/elastic/kibana/issues/176945\r\n- [x]
https://github.com/elastic/kibana/issues/175180\r\n- [x]
https://github.com/elastic/kibana/issues/181466\r\n- [x]
https://github.com/elastic/kibana/issues/182021\r\n- [x]
https://github.com/elastic/kibana/issues/183085\r\n- [x]
https://github.com/elastic/kibana/issues/175180\r\n\r\n---------\r\n\r\nCo-authored-by:
Michael Olorunnisola
<[email protected]>","sha":"5bd8ff528c37aa77e099d8ecc224a1f7468412b5"}},{"branch":"8.16","label":"v8.16.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
  • Loading branch information
logeekal authored Oct 28, 2024
1 parent c35f6b9 commit 9299aa5
Show file tree
Hide file tree
Showing 15 changed files with 164 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {
EVENT_SUMMARY_COLUMN,
ALERT_RENDERER_HOST_NAME,
SHOW_TOP_N_HEADER,
HOVER_ACTIONS,
} from '../../../screens/alerts';
import {
DATA_GRID_COLUMN_ORDER_BTN,
DATA_GRID_FIELD_SORT_BTN,
} from '../../../screens/common/data_grid';
import { HOVER_ACTIONS } from '../../../screens/timeline';
import {
showHoverActionsEventRenderedView,
switchAlertTableToEventRenderedView,
Expand All @@ -43,12 +43,12 @@ describe(`Event Rendered View`, { tags: ['@ess', '@serverless'] }, () => {
waitForAlerts();
});

it('Event Summary Column', () => {
it('should show Event Summary column correctly', () => {
cy.get(EVENT_SUMMARY_COLUMN).should('be.visible');
cy.get(EVENT_SUMMARY_ALERT_RENDERER_CONTENT).should('be.visible');
});

it('Hover Action TopN in event summary column', () => {
it('should show TopN in Event Summary column', () => {
showHoverActionsEventRenderedView(ALERT_RENDERER_HOST_NAME);
cy.get(HOVER_ACTIONS.SHOW_TOP).trigger('click');
cy.get(TOP_N_ALERT_HISTOGRAM).should('be.visible');
Expand All @@ -64,15 +64,15 @@ describe(`Event Rendered View`, { tags: ['@ess', '@serverless'] }, () => {
* This test main checks if Alert Table controls are rendered properly.
*
* */
it('Field Browser is not visible', () => {
it('should not show Field Browser', () => {
cy.get(FIELDS_BROWSER_BTN).should('not.exist');
});

it('Sorting control is not visible', () => {
it('should now show Sorting Control', () => {
cy.get(DATA_GRID_FIELD_SORT_BTN).should('not.exist');
});

it('Column Order button is not visible', () => {
it('should not show column order control', () => {
cy.get(DATA_GRID_COLUMN_ORDER_BTN).should('not.exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import { ROLES } from '@kbn/security-solution-plugin/common/test';
import { getTimeline } from '../../../objects/timeline';

import {
LOCKED_ICON,
// NOTES_TEXT,
PIN_EVENT,
TIMELINE_FILTER,

TIMELINE_FLYOUT_WRAPPER,
TIMELINE_QUERY,
TIMELINE_PANEL,
Expand All @@ -30,17 +28,13 @@ import { visit, visitWithTimeRange } from '../../../tasks/navigation';
import { openTimelineUsingToggle } from '../../../tasks/security_main';
import { selectCustomTemplates } from '../../../tasks/templates';
import {
addFilter,
addNameAndDescriptionToTimeline,
// addNotesToTimeline,
clickingOnCreateTimelineFormTemplateBtn,
closeTimeline,
createNewTimeline,
executeTimelineKQL,
expandEventAction,
goToQueryTab,
pinFirstEvent,
populateTimeline,
addNameToTimelineAndSave,
addNameToTimelineAndSaveAsNew,
} from '../../../tasks/timeline';
Expand All @@ -50,8 +44,7 @@ import { OVERVIEW_URL, TIMELINE_TEMPLATES_URL, TIMELINES_URL } from '../../../ur

const mockTimeline = getTimeline();

// FLAKY: https://github.com/elastic/kibana/issues/180688
describe.skip('Timelines', { tags: ['@ess', '@serverless'] }, (): void => {
describe('Timelines', { tags: ['@ess', '@serverless'] }, (): void => {
beforeEach(() => {
deleteTimelines();
});
Expand Down Expand Up @@ -92,32 +85,6 @@ describe.skip('Timelines', { tags: ['@ess', '@serverless'] }, (): void => {
);
});

it('should create a timeline by clicking untitled timeline from bottom bar', () => {
login();
visitWithTimeRange(OVERVIEW_URL);
openTimelineUsingToggle();
addNameAndDescriptionToTimeline(mockTimeline);
populateTimeline();
goToQueryTab();

addFilter(mockTimeline.filter);
cy.get(TIMELINE_FILTER(mockTimeline.filter)).should('exist');

pinFirstEvent();
cy.get(PIN_EVENT)
.should('have.attr', 'aria-label')
.and('match', /Unpin the event in row 2/);

cy.get(LOCKED_ICON).should('be.visible');

// TODO: fix this
// While typing the note, cypress encounters this -> Error: ResizeObserver loop completed with undelivered notifications.
// addNotesToTimeline(mockTimeline.notes);
// cy.get(TIMELINE_TAB_CONTENT_GRAPHS_NOTES)
// .find(NOTES_TEXT)
// .should('have.text', mockTimeline.notes);
});

it('should show the different timeline states', () => {
login();
visitWithTimeRange(TIMELINES_URL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
TIMELINE_DROPPED_DATA_PROVIDERS,
TIMELINE_DATA_PROVIDERS_ACTION_MENU,
TIMELINE_FLYOUT_HEADER,
GET_TIMELINE_GRID_CELL,
TIMELINE_DATA_PROVIDERS_CONTAINER,
GET_TIMELINE_GRID_CELL_VALUE,
} from '../../../screens/timeline';

import { waitForAllHostsToBeLoaded } from '../../../tasks/hosts/all_hosts';
Expand All @@ -19,7 +19,6 @@ import { login } from '../../../tasks/login';
import { visitWithTimeRange } from '../../../tasks/navigation';
import {
addDataProvider,
updateDataProviderbyDraggingField,
addNameAndDescriptionToTimeline,
populateTimeline,
createTimelineFromBottomBar,
Expand All @@ -28,12 +27,13 @@ import {
} from '../../../tasks/timeline';
import { getTimeline } from '../../../objects/timeline';
import { hostsUrl } from '../../../urls/navigation';
import { LOADING_INDICATOR } from '../../../screens/security_header';

// FLAKY: https://github.com/elastic/kibana/issues/176945
const mockTimeline = getTimeline();
describe.skip('Timeline data providers', { tags: ['@ess', '@serverless'] }, () => {
describe('Timeline data providers', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
login();
cy.intercept('PATCH', '/api/timeline').as('updateTimeline');
visitWithTimeRange(hostsUrl('allHosts'));
waitForAllHostsToBeLoaded();
createTimelineFromBottomBar();
Expand All @@ -53,28 +53,20 @@ describe.skip('Timeline data providers', { tags: ['@ess', '@serverless'] }, () =
cy.get(TIMELINE_DATA_PROVIDERS_ACTION_MENU).should('exist');
});

it('should persist timeline when data provider is updated by dragging a field from data grid', () => {
updateDataProviderbyDraggingField('host.name', 0);
saveTimeline();
cy.reload();
cy.get(`${GET_TIMELINE_GRID_CELL('host.name')}`)
.first()
.then((hostname) => {
cy.get(TIMELINE_DATA_PROVIDERS_CONTAINER).contains(`host.name: "${hostname.text()}"`);
});
});

it('should persist timeline when a field is added by hover action "Add To Timeline" in data provider ', () => {
addDataProvider({ field: 'host.name', operator: 'exists' });
saveTimeline();
cy.wait('@updateTimeline');
cy.get(LOADING_INDICATOR).should('not.exist');
updateDataProviderByFieldHoverAction('host.name', 0);
saveTimeline();
cy.wait('@updateTimeline');
cy.reload();
cy.get(`${GET_TIMELINE_GRID_CELL('host.name')}`)
cy.get(`${GET_TIMELINE_GRID_CELL_VALUE('host.name')}`)
.first()
.then((hostname) => {
cy.get(TIMELINE_DATA_PROVIDERS_CONTAINER).should((dataProviderContainer) => {
expect(dataProviderContainer).to.contain(`host.name: "${hostname.text()}"`);
expect(dataProviderContainer).to.contain(`host.name: "${hostname.text().trim()}"`);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import {
addDiscoverEsqlQuery,
addFieldToTable,
assertFieldsAreLoaded,
verifyDiscoverEsqlQuery,
} from '../../../../tasks/discover';
import {
Expand Down Expand Up @@ -69,8 +70,7 @@ const handleIntercepts = () => {
});
};

// Failing: See https://github.com/elastic/kibana/issues/180755
describe.skip(
describe(
'Discover Timeline State Integration',
{
tags: ['@ess', '@skipInServerless'],
Expand All @@ -81,6 +81,7 @@ describe.skip(
visitWithTimeRange(ALERTS_URL);
createTimelineFromBottomBar();
goToEsqlTab();
addDiscoverEsqlQuery(esqlQuery);
updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE);
handleIntercepts();
});
Expand All @@ -90,17 +91,14 @@ describe.skip(
addNameToTimelineAndSave('Timerange timeline');
createNewTimeline();
goToEsqlTab();
cy.get(GET_LOCAL_SHOW_DATES_BUTTON(DISCOVER_CONTAINER)).should(
'contain.text',
`Last 15 minutes`
);
cy.get(GET_LOCAL_SHOW_DATES_BUTTON(DISCOVER_CONTAINER)).should('be.disabled'); // default state
});
it('should save/restore esql tab dataview/timerange/filter/query/columns when saving/resoring timeline', () => {
const timelineSuffix = Date.now();
const timelineName = `DataView timeline-${timelineSuffix}`;
const column1 = 'event.category';
const column2 = 'ecs.version';
addDiscoverEsqlQuery(esqlQuery);
assertFieldsAreLoaded();
addFieldToTable(column1);
addFieldToTable(column2);

Expand Down Expand Up @@ -132,6 +130,7 @@ describe.skip(
const column1 = 'event.category';
const column2 = 'ecs.version';
addDiscoverEsqlQuery(esqlQuery);
assertFieldsAreLoaded();
addFieldToTable(column1);
addFieldToTable(column2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
goToEsqlTab,
openActiveTimeline,
addNameAndDescriptionToTimeline,
saveTimeline,
addNameToTimelineAndSave,
} from '../../../../tasks/timeline';
import { ALERTS_URL } from '../../../../urls/navigation';
import { getTimeline } from '../../../../objects/timeline';
Expand All @@ -35,7 +35,25 @@ const INITIAL_START_DATE = 'Jan 18, 2021 @ 20:33:29.186';
const INITIAL_END_DATE = 'Jan 19, 2024 @ 20:33:29.186';

const mockTimeline = getTimeline();
// FAILURE introduced by the fix for 8.11.4 related to the default empty string and fix for the infinite loop on the esql tab
const esqlQuery = 'from auditbeat-* | limit 5';

const TIMELINE_REQ_WITH_SAVED_SEARCH = 'TIMELINE_REQ_WITH_SAVED_SEARCH';
const TIMELINE_PATCH_REQ = 'TIMELINE_PATCH_REQ';

const handleIntercepts = () => {
cy.intercept('PATCH', '/api/timeline', (req) => {
if (Object.hasOwn(req.body, 'timeline') && req.body.timeline.savedSearchId === null) {
req.alias = TIMELINE_PATCH_REQ;
}
});
cy.intercept('PATCH', '/api/timeline', (req) => {
if (Object.hasOwn(req.body, 'timeline') && req.body.timeline.savedSearchId !== null) {
req.alias = TIMELINE_REQ_WITH_SAVED_SEARCH;
}
});
};

// Flaky: https://github.com/elastic/kibana/issues/180755
describe.skip(
'Timeline Discover ESQL State',
{
Expand All @@ -50,33 +68,29 @@ describe.skip(
win.onbeforeunload = null;
});
goToEsqlTab();
addDiscoverEsqlQuery(esqlQuery);
updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE);
handleIntercepts();
});
it('should not allow the dataview to be changed', () => {
cy.get(DISCOVER_DATA_VIEW_SWITCHER.BTN).should('not.exist');
});
it('should remember esql query when navigating away and back to discover ', () => {
const esqlQuery = 'from auditbeat-* | limit 5';
addDiscoverEsqlQuery(esqlQuery);
it.skip('should remember esql query when navigating away and back to discover ', () => {
submitDiscoverSearchBar();
addNameAndDescriptionToTimeline(mockTimeline);
saveTimeline();
addNameToTimelineAndSave(mockTimeline.title);
cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`);
closeTimeline();
navigateFromHeaderTo(CSP_FINDINGS);
navigateFromHeaderTo(ALERTS);
openActiveTimeline();
goToEsqlTab();

verifyDiscoverEsqlQuery(esqlQuery);
});
it('should remember columns when navigating away and back to discover ', () => {
const esqlQuery = 'from auditbeat-* | limit 5';
addDiscoverEsqlQuery(esqlQuery);
submitDiscoverSearchBar();
addNameAndDescriptionToTimeline(mockTimeline);
addFieldToTable('host.name');
addFieldToTable('user.name');
saveTimeline();
addNameAndDescriptionToTimeline(mockTimeline);
closeTimeline();
navigateFromHeaderTo(CSP_FINDINGS);
navigateFromHeaderTo(ALERTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
addDiscoverEsqlQuery,
addFieldToTable,
convertEditorNonBreakingSpaceToSpace,
waitForDiscoverFieldsToLoad,
} from '../../../../tasks/discover';
import { login } from '../../../../tasks/login';
import { visitWithTimeRange } from '../../../../tasks/navigation';
Expand All @@ -38,8 +39,7 @@ const INITIAL_END_DATE = 'Jan 19, 2024 @ 20:33:29.186';
const NEW_START_DATE = 'Jan 18, 2023 @ 20:33:29.186';
const esqlQuery = 'from auditbeat-* | where ecs.version == "8.0.0"';

// FLAKY: https://github.com/elastic/kibana/issues/175180
describe.skip(
describe(
'Basic esql search and filter operations',
{
tags: ['@ess'],
Expand All @@ -58,16 +58,19 @@ describe.skip(
});

it('should show data according to the esql query', () => {
updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE);
addDiscoverEsqlQuery(`${esqlQuery} | limit 1`);
updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE);
cy.get(DISCOVER_RESULT_HITS).should('have.text', 1);
});

it('should be able to add fields to the table', () => {
updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE);
addDiscoverEsqlQuery(`${esqlQuery} | limit 1`);
addFieldToTable('host.name');
addFieldToTable('user.name');
updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE);
waitForDiscoverFieldsToLoad();
cy.get(DISCOVER_CONTAINER).within(() => {
addFieldToTable('host.name');
addFieldToTable('user.name');
});
cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER('host.name')).should('be.visible');
cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER('user.name')).should('be.visible');
});
Expand All @@ -88,6 +91,8 @@ describe.skip(
});

it(`should change the timerange to ${DEFAULT_DATE} when back is pressed after modifying timerange to ${NEW_START_DATE} without saving`, () => {
// The datepicker is only active when a query exists.
addDiscoverEsqlQuery(esqlQuery);
cy.get(GET_LOCAL_SHOW_DATES_BUTTON(DISCOVER_CONTAINER)).click();
cy.get(GET_LOCAL_DATE_PICKER_START_DATE_POPOVER_BUTTON(DISCOVER_CONTAINER)).first().click({});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { createTimeline } from '../../../tasks/api_calls/timelines';
import { expectedExportedTimeline } from '../../../objects/timeline';
import { closeToast } from '../../../tasks/common/toast';

// FLAKY: https://github.com/elastic/kibana/issues/187550
describe.skip('Export timelines', { tags: ['@ess', '@serverless'] }, () => {
describe('Export timelines', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
login();
deleteTimelines();
Expand All @@ -42,6 +41,10 @@ describe.skip('Export timelines', { tags: ['@ess', '@serverless'] }, () => {
visit(TIMELINES_URL);
});

/**
* TODO: Good candidate for converting to a jest Test
* https://github.com/elastic/kibana/issues/195612
*/
it('should export custom timeline(s)', function () {
cy.log('Export a custom timeline via timeline actions');

Expand All @@ -60,6 +63,7 @@ describe.skip('Export timelines', { tags: ['@ess', '@serverless'] }, () => {
cy.wrap(response?.statusCode).should('eql', 200);
cy.wrap(response?.body).should('eql', expectedExportedTimeline(this.timelineResponse1));
});

closeToast();

cy.log('Export all custom timelines via bulk actions');
Expand Down
Loading

0 comments on commit 9299aa5

Please sign in to comment.