[Security Solution][Timeline] - Fix the continued flake for one of the timeline cypress tests (#98637) (#99058)

This PR addresses continued flake with the notes tab cypress tests.
This commit is contained in:
Yara Tercero 2021-05-03 10:17:16 -07:00 committed by GitHub
parent 88c54372c2
commit b8863f2061
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 56 deletions

View file

@ -13,39 +13,27 @@ import { createTimeline } from '../../tasks/api_calls/timelines';
import { cleanKibana } from '../../tasks/common';
import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login';
import {
addNotesToTimeline,
closeTimeline,
goToNotesTab,
openTimelineById,
waitForEventsPanelToBeLoaded,
} from '../../tasks/timeline';
import { addNotesToTimeline, closeTimeline, openTimelineById } from '../../tasks/timeline';
import { waitForTimelinesPanelToBeLoaded } from '../../tasks/timelines';
import { TIMELINES_URL } from '../../urls/navigation';
describe('Timeline notes tab', () => {
let timelineId: string | null = null;
let timelineId: string | undefined;
before(() => {
cleanKibana();
loginAndWaitForPageWithoutDateRange(TIMELINES_URL);
waitForTimelinesPanelToBeLoaded();
createTimeline(timeline)
.then((response) => {
timelineId = response.body.data.persistTimeline.timeline.savedObjectId;
})
.then(() => {
waitForTimelinesPanelToBeLoaded();
openTimelineById(timelineId!)
.click({ force: true })
.then(() => {
waitForEventsPanelToBeLoaded();
addNotesToTimeline(timeline.notes);
goToNotesTab();
});
});
createTimeline(timeline).then((response) => {
timelineId = response.body.data.persistTimeline.timeline.savedObjectId;
waitForTimelinesPanelToBeLoaded();
openTimelineById(timelineId!);
addNotesToTimeline(timeline.notes);
});
});
after(() => {
closeTimeline();
});

View file

@ -27,14 +27,12 @@ import {
openTimelineById,
openTimelineFromSettings,
pinFirstEvent,
waitForEventsPanelToBeLoaded,
} from '../../tasks/timeline';
import { waitForTimelinesPanelToBeLoaded } from '../../tasks/timelines';
import { TIMELINES_URL } from '../../urls/navigation';
// FLAKY: https://github.com/elastic/kibana/issues/97544
describe.skip('Open timeline', () => {
describe('Open timeline', () => {
let timelineId: string | null = null;
before(() => {
cleanKibana();
@ -50,13 +48,9 @@ describe.skip('Open timeline', () => {
addNoteToTimeline(note, timelineId!).should((response) => {
expect(response.status).to.equal(200);
waitForTimelinesPanelToBeLoaded();
openTimelineById(timelineId!)
.click({ force: true })
.then(() => {
waitForEventsPanelToBeLoaded();
pinFirstEvent();
markAsFavorite();
});
openTimelineById(timelineId!);
pinFirstEvent();
markAsFavorite();
});
});
});
@ -97,6 +91,7 @@ describe.skip('Open timeline', () => {
cy.get(TIMELINE_TITLE).should('have.text', timeline.title);
});
// FLAKY: https://github.com/elastic/kibana/issues/97544
it('should display timeline content - description', () => {
cy.get(TIMELINE_DESCRIPTION).should('have.text', timeline.description); // This is the flake part where it sometimes does not show/load the timelines correctly
});

View file

@ -14,13 +14,7 @@ import { createTimeline } from '../../tasks/api_calls/timelines';
import { cleanKibana } from '../../tasks/common';
import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login';
import {
addFilter,
closeTimeline,
openTimelineById,
pinFirstEvent,
waitForEventsPanelToBeLoaded,
} from '../../tasks/timeline';
import { addFilter, closeTimeline, openTimelineById, pinFirstEvent } from '../../tasks/timeline';
import { waitForTimelinesPanelToBeLoaded } from '../../tasks/timelines';
import { TIMELINES_URL } from '../../urls/navigation';
@ -41,13 +35,9 @@ describe('Timeline query tab', () => {
addNoteToTimeline(note, timelineId!).should((response) => {
expect(response.status).to.equal(200);
waitForTimelinesPanelToBeLoaded();
openTimelineById(timelineId!)
.click({ force: true })
.then(() => {
waitForEventsPanelToBeLoaded();
pinFirstEvent();
addFilter(timeline.filter);
});
openTimelineById(timelineId!);
pinFirstEvent();
addFilter(timeline.filter);
});
});
});

View file

@ -63,7 +63,7 @@ export const NOTE_CONTENT = (noteId: string) => `${NOTE_BY_NOTE_ID(noteId)} p`;
export const NOTES_TEXT_AREA = '[data-test-subj="add-a-note"] textarea';
export const NOTES_TAB_BUTTON = 'button[data-test-subj="timelineTabs-notes"]';
export const NOTES_TAB_BUTTON = '[data-test-subj="timelineTabs-notes"]';
export const NOTES_TEXT = '.euiMarkdownFormat';

View file

@ -90,8 +90,11 @@ export const addNameAndDescriptionToTimeline = (timeline: Timeline) => {
};
export const goToNotesTab = () => {
cy.get(NOTES_TAB_BUTTON)
.pipe(($el) => $el.trigger('click'))
cy.root()
.pipe(($el) => {
$el.find(NOTES_TAB_BUTTON).trigger('click');
return $el.find(NOTES_TEXT_AREA);
})
.should('be.visible');
};
@ -100,14 +103,26 @@ export const getNotePreviewByNoteId = (noteId: string) => {
};
export const goToQueryTab = () => {
cy.get(QUERY_TAB_BUTTON).click({ force: true });
cy.root()
.pipe(($el) => {
$el.find(QUERY_TAB_BUTTON).trigger('click');
return $el.find(QUERY_TAB_BUTTON);
})
.should('have.class', 'euiTab-isSelected');
};
export const addNotesToTimeline = (notes: string) => {
cy.wait(150);
goToNotesTab();
cy.get(NOTES_TEXT_AREA).type(notes);
cy.get(ADD_NOTE_BUTTON).click({ force: true });
cy.get(QUERY_TAB_BUTTON).click();
cy.root()
.pipe(($el) => {
$el.find(ADD_NOTE_BUTTON).trigger('click');
return $el.find(NOTES_TAB_BUTTON).find('.euiBadge');
})
.should('have.text', '1');
goToQueryTab();
goToNotesTab();
};
export const addFilter = (filter: TimelineFilter) => {
@ -159,13 +174,23 @@ export const closeOpenTimelineModal = () => {
};
export const closeTimeline = () => {
cy.get(CLOSE_TIMELINE_BTN).filter(':visible').click({ force: true });
cy.root()
.pipe(($el) => {
$el.find(CLOSE_TIMELINE_BTN).filter(':visible').trigger('click');
return $el.find(QUERY_TAB_BUTTON);
})
.should('not.be.visible');
};
export const createNewTimeline = () => {
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').click({ force: true });
cy.get(TIMELINE_SETTINGS_ICON)
.filter(':visible')
.pipe(($el) => $el.trigger('click'))
.should('be.visible');
cy.wait(300);
cy.get(CREATE_NEW_TIMELINE).click();
cy.get(CREATE_NEW_TIMELINE)
.eq(0)
.pipe(($el) => $el.trigger('click'));
};
export const createNewTimelineTemplate = () => {
@ -207,7 +232,12 @@ export const openTimelineTemplateFromSettings = (id: string) => {
};
export const openTimelineById = (timelineId: string) => {
return cy.get(TIMELINE_TITLE_BY_ID(timelineId)).pipe(($el) => $el.trigger('click'));
cy.root()
.pipe(($el) => {
$el.find(TIMELINE_TITLE_BY_ID(timelineId)).trigger('click');
return $el.find(QUERY_TAB_BUTTON).find('.euiBadge');
})
.should('be.visible');
};
export const pinFirstEvent = () => {