Skip to content

Commit

Permalink
Should make cypress less flake with two of our tests (elastic#104033)
Browse files Browse the repository at this point in the history
## Summary

Should reduce flake in two of our Cypress tests.

* Removed skip on a test recently skipped
* Removes a wait() that doesn't seem to have been reducing flake added by a EUI team member
* Adds a `.click()` to give focus to a component in order to improve our chances of typing in the input box
* Adds some `.should('exists')` which will cause Cypress to ensure something exists and a better chance for click handlers to be added
* Adds a pipe as suggested by @yctercero in the flake test

### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
  • Loading branch information
FrankHassanabad authored and madirey committed Jul 6, 2021
1 parent a5f7acf commit 3e6dfda
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('Row renderers', () => {
loginAndWaitForPage(HOSTS_URL);
openTimelineUsingToggle();
populateTimeline();
cy.get(TIMELINE_SHOW_ROW_RENDERERS_GEAR).should('exist');
cy.get(TIMELINE_SHOW_ROW_RENDERERS_GEAR).first().click({ force: true });
});

Expand All @@ -59,6 +60,7 @@ describe('Row renderers', () => {
});

it('Selected renderer can be disabled and enabled', () => {
cy.get(TIMELINE_ROW_RENDERERS_SEARCHBOX).should('exist');
cy.get(TIMELINE_ROW_RENDERERS_SEARCHBOX).type('flow');

cy.get(TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX).first().uncheck();
Expand All @@ -75,8 +77,11 @@ describe('Row renderers', () => {
});
});

it.skip('Selected renderer can be disabled with one click', () => {
cy.get(TIMELINE_ROW_RENDERERS_DISABLE_ALL_BTN).click({ force: true });
it('Selected renderer can be disabled with one click', () => {
cy.get(TIMELINE_ROW_RENDERERS_DISABLE_ALL_BTN).should('exist');
cy.get(TIMELINE_ROW_RENDERERS_DISABLE_ALL_BTN)
.pipe(($el) => $el.trigger('click'))
.should('not.be.visible');

cy.intercept('PATCH', '/api/timeline').as('updateTimeline');
cy.wait('@updateTimeline').its('response.statusCode').should('eq', 200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe('url state', () => {
waitForIpsTableToBeLoaded();
setEndDate(ABSOLUTE_DATE.newEndTimeTyped);
updateDates();
cy.wait(300);

let startDate: string;
let endDate: string;
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/security_solution/cypress/tasks/date_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export const setEndDate = (date: string) => {

cy.get(DATE_PICKER_ABSOLUTE_TAB).first().click({ force: true });

cy.get(DATE_PICKER_ABSOLUTE_INPUT).clear().type(date);
cy.get(DATE_PICKER_ABSOLUTE_INPUT).click().clear().type(date);
};

export const setStartDate = (date: string) => {
cy.get(DATE_PICKER_START_DATE_POPOVER_BUTTON).click({ force: true });

cy.get(DATE_PICKER_ABSOLUTE_TAB).first().click({ force: true });

cy.get(DATE_PICKER_ABSOLUTE_INPUT).clear().type(date);
cy.get(DATE_PICKER_ABSOLUTE_INPUT).click().clear().type(date);
};

export const setTimelineEndDate = (date: string) => {
Expand Down

0 comments on commit 3e6dfda

Please sign in to comment.