Skip to content

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
janmonschke committed Nov 1, 2024
1 parent 6544eef commit 20588a8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ import {
} from '../../../tasks/serverless/navigation';
import {
addNameToTimelineAndSave,
closeTimeline,
createNewTimeline,
duplicateFirstTimeline,
populateTimeline,
} from '../../../tasks/timeline';
import { EXPLORE_URL, hostsUrl, MANAGE_URL } from '../../../urls/navigation';
import { EXPLORE_URL, TIMELINES_URL, MANAGE_URL } from '../../../urls/navigation';

// FLAKY: https://github.com/elastic/kibana/issues/174068
describe.skip('[ESS] Save Timeline Prompts', { tags: ['@ess'] }, () => {
describe('[ESS] Save Timeline Prompts', { tags: ['@ess'] }, () => {
beforeEach(() => {
login();
visitWithTimeRange(hostsUrl('allHosts'));
visitWithTimeRange(TIMELINES_URL);
openTimelineUsingToggle();
createNewTimeline();
/*
Expand All @@ -58,7 +59,7 @@ describe.skip('[ESS] Save Timeline Prompts', { tags: ['@ess'] }, () => {
it('should NOT prompt when navigating with an unchanged & unsaved timeline', () => {
openKibanaNavigation();
navigateFromKibanaCollapsibleTo(OBSERVABILITY_ALERTS_PAGE);
cy.url().should('not.contain', hostsUrl('allHosts'));
cy.url().should('not.contain', TIMELINES_URL);
});

it('should prompt when navigating away from security solution with a changed & unsaved timeline', () => {
Expand Down Expand Up @@ -119,13 +120,22 @@ describe.skip('[ESS] Save Timeline Prompts', { tags: ['@ess'] }, () => {
cy.get(TIMELINE_SAVE_MODAL).should('not.exist');
cy.url().should('not.contain', MANAGE_URL);
});

it('should prompt when a timeline is duplicated but not saved', () => {
addNameToTimelineAndSave('Original');
closeTimeline();
duplicateFirstTimeline();
openKibanaNavigation();
navigateFromKibanaCollapsibleTo(MANAGE_PAGE);
cy.get(APP_LEAVE_CONFIRM_MODAL).should('be.visible');
});
});

// In serverless it is not possible to use the navigation menu without closing the timeline
describe('[serverless] Save Timeline Prompts', { tags: ['@serverless'] }, () => {
beforeEach(() => {
login();
visitWithTimeRange(hostsUrl('allHosts'));
visitWithTimeRange(TIMELINES_URL);
openTimelineUsingToggle();
createNewTimeline();
/*
Expand Down Expand Up @@ -201,4 +211,13 @@ describe('[serverless] Save Timeline Prompts', { tags: ['@serverless'] }, () =>
navigateToExploreUsingBreadcrumb(); // explore has timelines disabled
cy.get(APP_LEAVE_CONFIRM_MODAL).should('not.exist');
});

it('should prompt when a timeline is duplicated but not saved', () => {
addNameToTimelineAndSave('Original');
closeTimeline();
duplicateFirstTimeline();
openKibanaNavigation();
navigateFromKibanaCollapsibleTo(MANAGE_PAGE);
cy.get(APP_LEAVE_CONFIRM_MODAL).should('be.visible');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const TIMELINES_PINNED_EVENT_COUNT = '[data-test-subj="pinned-event-count

export const TIMELINES_TABLE = '[data-test-subj="timelines-table"]';

export const DUPLICATE_TIMELINE = '[data-test-subj="open-duplicate"]';

export const TIMELINES_USERNAME = '[data-test-subj="username"]';

export const REFRESH_BUTTON = '[data-test-subj="refreshButton-linkIcon"]';
Expand Down
19 changes: 17 additions & 2 deletions x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,22 @@ import {
QUERY_EVENT_COUNT,
TIMELINE_ENABLE_DISABLE_ALL_ROW_RENDERER,
TIMELINE_DISCOVER_FIELDS_BUTTON,
TIMELINE_TITLE,
} from '../screens/timeline';

import { REFRESH_BUTTON, TIMELINE, TIMELINES_TAB_TEMPLATE } from '../screens/timelines';
import {
DUPLICATE_TIMELINE,
REFRESH_BUTTON,
TIMELINE,
TIMELINES_TABLE,
TIMELINES_TAB_TEMPLATE,
} from '../screens/timelines';
import { waitForTabToBeLoaded } from './common';

import { closeFieldsBrowser, filterFieldsBrowser } from './fields_browser';
import { TIMELINE_CONTEXT_MENU_BTN } from '../screens/alerts';
import { LOADING_INDICATOR } from '../screens/security_header';
import { TOASTER } from '../screens/alerts_detection_rules';
import { COLLAPSED_ACTION_BTN, TOASTER } from '../screens/alerts_detection_rules';
import { RUNTIME_FIELD_INPUT, SAVE_FIELD_BUTTON } from '../screens/create_runtime_field';

const hostExistsQuery = 'host.name: *';
Expand Down Expand Up @@ -150,6 +157,14 @@ export const addNameAndDescriptionToTimeline = (
cy.get(TIMELINE_TITLE_INPUT).should('not.exist');
};

export const duplicateFirstTimeline = () => {
cy.get(TIMELINES_TABLE).within(() => {
cy.get(COLLAPSED_ACTION_BTN).first().click();
});
cy.get(DUPLICATE_TIMELINE).click();
cy.get(TIMELINE_TITLE).should('be.visible');
};

export const goToNotesTab = () => {
cy.get(NOTES_TAB_BUTTON).click();
cy.get(NOTES_TEXT_AREA).should('be.visible');
Expand Down

0 comments on commit 20588a8

Please sign in to comment.