Skip to content

[7.x] Fixes Cypress flake by adding pipe, click, and should (#92762)#92777

Merged
kibanamachine merged 2 commits intoelastic:7.xfrom
kibanamachine:backport/7.x/pr-92762
Feb 25, 2021
Merged

[7.x] Fixes Cypress flake by adding pipe, click, and should (#92762)#92777
kibanamachine merged 2 commits intoelastic:7.xfrom
kibanamachine:backport/7.x/pr-92762

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backports the following commits to 7.x:

## Summary

We were seeing flake tests with the error messages:

```ts
expected '<button.euiButton.euiButton--primary>' to have text 'Install 2 Elastic prebuilt rules ', but the text was 'Install 1 Elastic prebuilt rule '
```

Running this locally several times I was able to reproduce the flake. I was able to see that the click handler when clicked on the check boxes is not always taking effect for the first check box. A common issue with Cypress is that a lot of page loads and JS activities on pages can add/remove click handlers quickly such as when we are frosting and un-frosting a loading screen.

When we try and click on the click handlers for a test and the click handlers are not added yet, we miss one or more and end up with a flake test. Instead we can click as fast as possible using `pipe` and then checking that the check box is clicked before continuing using a `should`

Even though the loading screen is done frosting in these tests, the click handler can take one or two milliseconds before they end up being added to the checkboxes.

**Analysis**

When you have the flake and fail you can scroll in Cypress and pin a point in time and see that indeed we did not get the first checkbox checked even though we had a click. Which makes sense as within a few milliseconds the click handlers are added and we do check the second checkbox:
<img width="2083" alt="analysis" src="https://user-images.githubusercontent.com/1151048/109119992-a19d1b80-7702-11eb-882a-c035eba97455.png">

### 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
@FrankHassanabad
Copy link
Copy Markdown
Contributor

@elasticmachine merge upstream

@kibanamachine
Copy link
Copy Markdown
Contributor Author

💛 Build succeeded, but was flaky


Test Failures

Kibana Pipeline / general / "before all" hook for "should contain the right query".Timeline query tab Query tab "before all" hook for "should contain the right query"

Link to Jenkins

Stack Trace

Failed Tests Reporter:
  - Test has not failed recently on tracked branches

AssertionError: Timed out retrying after 60000ms: Expected to find element: `[data-test-subj="title-c94a1f90-7796-11eb-a8ab-91303a3593dd"]`, but never found it.

Because this error occurred during a `before all` hook we are skipping the remaining tests in the current suite: `Timeline query tab`

Although you have test retries enabled, we do not retry tests when `before all` or `after all` hooks fail
    at Object.openTimelineById (http://localhost:6121/__cypress/tests?p=cypress/integration/timelines/query_tab.spec.ts:16058:15)
    at Context.eval (http://localhost:6121/__cypress/tests?p=cypress/integration/timelines/query_tab.spec.ts:15045:28)

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @FrankHassanabad

@kibanamachine kibanamachine merged commit df8ccf0 into elastic:7.x Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants