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

[SecuritySolution] Fix flaky cypress timeline templates test #155513

Merged
merged 1 commit into from
Apr 21, 2023
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 @@ -15,7 +15,7 @@ import {
import { TIMELINE_TEMPLATES_URL } from '../../urls/navigation';
import { createTimelineTemplate } from '../../tasks/api_calls/timelines';
import { cleanKibana } from '../../tasks/common';
import { setRowsPerPageTo } from '../../tasks/table_pagination';
import { searchByTitle } from '../../tasks/table_pagination';

describe('Export timelines', () => {
before(() => {
Expand All @@ -27,13 +27,14 @@ describe('Export timelines', () => {
createTimelineTemplate(getTimelineTemplate()).then((response) => {
cy.wrap(response).as('templateResponse');
cy.wrap(response.body.data.persistTimeline.timeline.savedObjectId).as('templateId');
cy.wrap(response.body.data.persistTimeline.timeline.title).as('templateTitle');
});
login();
});

it('Exports a custom timeline template', function () {
visitWithoutDateRange(TIMELINE_TEMPLATES_URL);
setRowsPerPageTo(20);
searchByTitle(this.templateTitle);
exportTimeline(this.templateId);

cy.wait('@export').then(({ response }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ export const TABLE_FIRST_PAGE = tablePageSelector(1);
export const TABLE_SECOND_PAGE = tablePageSelector(2);

export const TABLE_SORT_COLUMN_BTN = '[data-test-subj="tableHeaderSortButton"]';

export const TABLE_SEARCH_BAR = '[data-test-subj="search-bar"]';
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
rowsPerPageSelector,
tablePageSelector,
TABLE_PER_PAGE_POPOVER_BTN,
TABLE_SEARCH_BAR,
TABLE_SORT_COLUMN_BTN,
} from '../screens/table_pagination';

Expand All @@ -33,6 +34,14 @@ export const setRowsPerPageTo = (rowsCount: number) => {
.should('not.exist');
};

export const searchByTitle = (title: string) => {
cy.get(LOADING_SPINNER).should('not.exist');
cy.get(TABLE_PER_PAGE_POPOVER_BTN).should('exist');
cy.get(TABLE_SEARCH_BAR).click({ force: true });
// EuiSearchBox needs the "search" event to be triggered, {enter} doesn't work
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏾

cy.get(TABLE_SEARCH_BAR).type(`"${title}"`).trigger('search');
};

export const expectRowsPerPage = (rowsCount: number) => {
cy.get(TABLE_PER_PAGE_POPOVER_BTN).contains(`Rows per page: ${rowsCount}`);
};
Expand Down