Skip to content

Commit 4b92d89

Browse files
[Security Solution] Cypress template creation (#80180)
* init tests * fix cypress test * remove console * fix functional test * update functional test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 49e0a51 commit 4b92d89

4 files changed

Lines changed: 23 additions & 13 deletions

File tree

x-pack/plugins/security_solution/cypress/integration/timeline_creation.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ import { openTimeline } from '../tasks/timelines';
4545

4646
import { OVERVIEW_URL } from '../urls/navigation';
4747

48-
// FLAKY: https://github.com/elastic/kibana/issues/79389
49-
describe.skip('Timelines', () => {
48+
describe('Timelines', () => {
5049
before(() => {
5150
cy.server();
5251
cy.route('PATCH', '**/api/timeline').as('timeline');

x-pack/plugins/security_solution/cypress/integration/timeline_template_creation.spec.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212
NOTES_BUTTON,
1313
NOTES_COUNT,
1414
NOTES_TEXT_AREA,
15+
PIN_EVENT,
1516
TIMELINE_DESCRIPTION,
16-
// TIMELINE_FILTER,
1717
TIMELINE_QUERY,
1818
TIMELINE_TITLE,
1919
} from '../screens/timeline';
@@ -35,7 +35,7 @@ import {
3535
closeTimeline,
3636
createNewTimelineTemplate,
3737
markAsFavorite,
38-
openTimelineFromSettings,
38+
openTimelineTemplateFromSettings,
3939
populateTimeline,
4040
waitForTimelineChanges,
4141
} from '../tasks/timeline';
@@ -55,12 +55,11 @@ describe('Timeline Templates', () => {
5555
createNewTimelineTemplate();
5656
populateTimeline();
5757
addFilter(timeline.filter);
58-
// To fix
59-
// cy.get(PIN_EVENT).should(
60-
// 'have.attr',
61-
// 'aria-label',
62-
// 'This event may not be pinned while editing a template timeline'
63-
// );
58+
cy.get(PIN_EVENT).should(
59+
'have.attr',
60+
'aria-label',
61+
'This event may not be pinned while editing a template timeline'
62+
);
6463
cy.get(LOCKED_ICON).should('be.visible');
6564

6665
addNameToTimeline(timeline.title);
@@ -76,7 +75,7 @@ describe('Timeline Templates', () => {
7675
waitForTimelineChanges();
7776
createNewTimelineTemplate();
7877
closeTimeline();
79-
openTimelineFromSettings();
78+
openTimelineTemplateFromSettings(timelineId);
8079

8180
cy.contains(timeline.title).should('exist');
8281
cy.get(TIMELINES_DESCRIPTION).first().should('have.text', timeline.description);

x-pack/plugins/security_solution/cypress/screens/timeline.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export const NOTES_COUNT = '[data-test-subj="timeline-notes-count"]';
5858

5959
export const OPEN_TIMELINE_ICON = '[data-test-subj="open-timeline-button"]';
6060

61+
export const OPEN_TIMELINE_TEMPLATE_ICON =
62+
'[data-test-subj="open-timeline-modal-body-filter-template"]';
63+
6164
export const PIN_EVENT = '[data-test-subj="pin"]';
6265

6366
export const PROVIDER_BADGE = '[data-test-subj="providerBadge"]';
@@ -98,6 +101,8 @@ export const TIMELINE_FILTER = (filter: TimelineFilter) => {
98101

99102
export const TIMELINE_FILTER_FIELD = '[data-test-subj="filterFieldSuggestionList"]';
100103

104+
export const TIMELINE_TITLE_BY_ID = (id: string) => `[data-test-subj="title-${id}"]`;
105+
101106
export const TIMELINE_FILTER_OPERATOR = '[data-test-subj="filterOperatorList"]';
102107

103108
export const TIMELINE_FILTER_VALUE =

x-pack/plugins/security_solution/cypress/tasks/timeline.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ import {
4141
TIMELINE_INSPECT_BUTTON,
4242
TIMELINE_SETTINGS_ICON,
4343
TIMELINE_TITLE,
44+
TIMELINE_TITLE_BY_ID,
4445
TIMESTAMP_TOGGLE_FIELD,
4546
TOGGLE_TIMELINE_EXPAND_EVENT,
4647
CREATE_NEW_TIMELINE_TEMPLATE,
48+
OPEN_TIMELINE_TEMPLATE_ICON,
4749
} from '../screens/timeline';
4850
import { TIMELINES_TABLE } from '../screens/timelines';
4951

@@ -69,8 +71,7 @@ export const addNotesToTimeline = (notes: string) => {
6971

7072
export const addFilter = (filter: TimelineFilter) => {
7173
cy.get(ADD_FILTER).click();
72-
cy.get(TIMELINE_FILTER_FIELD).type(filter.field);
73-
cy.get(COMBO_BOX).contains(filter.field).click();
74+
cy.get(TIMELINE_FILTER_FIELD).type(`${filter.field}{downarrow}{enter}`);
7475
cy.get(TIMELINE_FILTER_OPERATOR).type(filter.operator);
7576
cy.get(COMBO_BOX).contains(filter.operator).click();
7677
if (filter.operator !== 'exists') {
@@ -146,6 +147,12 @@ export const openTimelineFromSettings = () => {
146147
cy.get(OPEN_TIMELINE_ICON).click({ force: true });
147148
};
148149

150+
export const openTimelineTemplateFromSettings = (id: string) => {
151+
openTimelineFromSettings();
152+
cy.get(OPEN_TIMELINE_TEMPLATE_ICON).click({ force: true });
153+
cy.get(TIMELINE_TITLE_BY_ID(id)).click({ force: true });
154+
};
155+
149156
export const openTimelineSettings = () => {
150157
cy.get(TIMELINE_SETTINGS_ICON).trigger('click', { force: true });
151158
};

0 commit comments

Comments
 (0)