Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Unskip timeline creation Cypress test #85871

Merged
merged 2 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { timeline } from '../objects/timeline';
import {
FAVORITE_TIMELINE,
LOCKED_ICON,
NOTES,
NOTES_TAB_BUTTON,
// NOTES_COUNT,
NOTES_TEXT_AREA,
NOTE_BY_NOTE_ID,
PIN_EVENT,
TIMELINE_DESCRIPTION,
TIMELINE_FILTER,
// TIMELINE_FILTER,
TIMELINE_QUERY,
TIMELINE_TITLE,
Expand All @@ -24,7 +25,7 @@ import {
TIMELINES_NOTES_COUNT,
TIMELINES_FAVORITE,
} from '../screens/timelines';
import { deleteTimeline } from '../tasks/api_calls/timelines';
import { deleteTimeline, getTimelineById } from '../tasks/api_calls/timelines';

import { loginAndWaitForPage } from '../tasks/login';
import { openTimelineUsingToggle } from '../tasks/security_main';
Expand All @@ -46,11 +47,11 @@ import { openTimeline } from '../tasks/timelines';
import { OVERVIEW_URL } from '../urls/navigation';

// FLAKY: https://github.com/elastic/kibana/issues/79389
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please remove this line and close the related ticket if is still opened?

describe.skip('Timelines', () => {
describe('Timelines', () => {
let timelineId: string;

after(() => {
deleteTimeline(timelineId);
if (timelineId) deleteTimeline(timelineId);
});

it('Creates a timeline', () => {
Expand Down Expand Up @@ -90,13 +91,16 @@ describe.skip('Timelines', () => {
cy.get(TIMELINE_TITLE).should('have.text', timeline.title);
cy.get(TIMELINE_DESCRIPTION).should('have.text', timeline.description);
cy.get(TIMELINE_QUERY).should('have.text', `${timeline.query} `);
// Comments this assertion until we agreed what to do with the filters.
// cy.get(TIMELINE_FILTER(timeline.filter)).should('exist');
// cy.get(NOTES_COUNT).should('have.text', '1');
cy.get(TIMELINE_FILTER(timeline.filter)).should('exist');
cy.get(PIN_EVENT).should('have.attr', 'aria-label', 'Pinned event');
cy.get(NOTES_TAB_BUTTON).click();
cy.get(NOTES_TEXT_AREA).should('exist');
cy.get(NOTES).should('have.text', timeline.notes);

getTimelineById(timelineId).then((singleTimeline) => {
const noteId = singleTimeline!.body.data.getOneTimeline.notes[0].noteId;

cy.get(`${NOTE_BY_NOTE_ID(noteId)} p`).should('have.text', timeline.notes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please extract this to our screens folder?

});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface TimelineFilter {
export const filter: TimelineFilter = {
field: 'host.name',
operator: 'exists',
value: 'exists',
};

export const timeline: CompleteTimeline = {
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/security_solution/cypress/screens/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export const LOCKED_ICON = '[data-test-subj="timeline-date-picker-lock-button"]'

export const NOTES = '[data-test-subj="note-card-body"]';

export const NOTE_BY_NOTE_ID = (noteId: string) => `[data-test-subj="note-preview-${noteId}"]`;

export const NOTES_TEXT_AREA = '[data-test-subj="add-a-note"] textarea';

export const NOTES_TAB_BUTTON = '[data-test-subj="timelineTabs-notes"]';
Expand Down Expand Up @@ -103,7 +105,8 @@ export const TIMELINE_FIELDS_BUTTON =
'[data-test-subj="timeline"] [data-test-subj="show-field-browser"]';

export const TIMELINE_FILTER = (filter: TimelineFilter) => {
return `[data-test-subj="filter filter-enabled filter-key-${filter.field} filter-value-${filter.value} filter-unpinned"]`;
// The space at the end of the line is required. We want to keep it until it is updated.
return `[data-test-subj="filter filter-enabled filter-key-${filter.field} filter-value-${filter.value} filter-unpinned "]`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this extra space on the end here meaningful in some way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is how it looks atm, and the component is not made by us. Update it here to fit current case and get the right element.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Could you add a comment to that effect? Someone's editor may accidentally fix that on save or something and recreate the error. Might be worth contacting the code owners of the component too, to just remove the space in their code as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @michaelolo24, we should fix the code and see if break anything else

};

export const TIMELINE_FILTER_FIELD = '[data-test-subj="filterFieldSuggestionList"]';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,18 @@ export const deleteTimeline = (timelineId: string) => {
headers: { 'kbn-xsrf': 'delete-signals' },
});
};

export const getTimelineById = (timelineId: string) =>
cy.request({
method: 'POST',
url: 'api/solutions/security/graphql',
body: {
operationName: 'GetOneTimeline',
variables: {
id: timelineId,
},
query:
'query GetOneTimeline($id: ID!, $timelineType: TimelineType) {\n getOneTimeline(id: $id, timelineType: $timelineType) {\n savedObjectId\n columns {\n aggregatable\n category\n columnHeaderType\n description\n example\n indexes\n id\n name\n searchable\n type\n __typename\n }\n dataProviders {\n id\n name\n enabled\n excluded\n kqlQuery\n type\n queryMatch {\n field\n displayField\n value\n displayValue\n operator\n __typename\n }\n and {\n id\n name\n enabled\n excluded\n kqlQuery\n type\n queryMatch {\n field\n displayField\n value\n displayValue\n operator\n __typename\n }\n __typename\n }\n __typename\n }\n dateRange {\n start\n end\n __typename\n }\n description\n eventType\n eventIdToNoteIds {\n eventId\n note\n timelineId\n noteId\n created\n createdBy\n timelineVersion\n updated\n updatedBy\n version\n __typename\n }\n excludedRowRendererIds\n favorite {\n fullName\n userName\n favoriteDate\n __typename\n }\n filters {\n meta {\n alias\n controlledBy\n disabled\n field\n formattedValue\n index\n key\n negate\n params\n type\n value\n __typename\n }\n query\n exists\n match_all\n missing\n range\n script\n __typename\n }\n kqlMode\n kqlQuery {\n filterQuery {\n kuery {\n kind\n expression\n __typename\n }\n serializedQuery\n __typename\n }\n __typename\n }\n indexNames\n notes {\n eventId\n note\n timelineId\n timelineVersion\n noteId\n created\n createdBy\n updated\n updatedBy\n version\n __typename\n }\n noteIds\n pinnedEventIds\n pinnedEventsSaveObject {\n pinnedEventId\n eventId\n timelineId\n created\n createdBy\n updated\n updatedBy\n version\n __typename\n }\n status\n title\n timelineType\n templateTimelineId\n templateTimelineVersion\n savedQueryId\n sort\n created\n createdBy\n updated\n updatedBy\n version\n __typename\n }\n}\n',
},
headers: { 'kbn-xsrf': '' },
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const exportTimeline = (timelineId: string) => {
};

export const openTimeline = (id: string) => {
cy.get(TIMELINE(id)).click();
cy.get(TIMELINE(id), { timeout: 500 }).click();
};

export const waitForTimelinesPanelToBeLoaded = () => {
Expand Down