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

[Enhancement] Random failure on embed.spec.js due to click too early #1431

Open
peterzhuamazon opened this issue Jun 22, 2024 · 5 comments
Open
Labels
bug Something isn't working

Comments

@peterzhuamazon
Copy link
Member

Coming from opensearch-project/opensearch-build#4745

Running:  core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table            (3 of 5)
            /embed.spec.js                                                                          


  table visualization in embedded mode
    ✓ Should open table vis in embedded mode (31196ms)
    ✓ Should allow to filter in embedded mode (10004ms)
    ✓ Should filter for value in embedded mode (15156ms)
    1) Should filter out value in embedded mode


  3 passing (2m)
  1 failing

  1) table visualization in embedded mode
       Should filter out value in embedded mode:
     CypressError: Timed out retrying after 60050ms: `cy.click()` failed because this element is detached from the DOM.

`<button class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--small" type="button" aria-label="Filter out value: 0" data-test-subj="filterOutValue">...</button>`

Cypress requires elements be attached in the DOM to interact with them.

The previous command that ran was:

  > `cy.find()`

This DOM element likely became detached somewhere between the previous and current command.

Common situations why this happens:
  - Your JS framework re-rendered asynchronously
  - Your app code reacted to an event firing and removed the element

You typically need to re-query for the element or add 'guards' which delay Cypress from running new commands.

https://on.cypress.io/element-has-detached-from-dom
      at $Cy.ensureAttached (http://localhost:5601/__cypress/runner/cypress_runner.js:163936:76)
      at runAllChecks (http://localhost:5601/__cypress/runner/cypress_runner.js:150536:12)
      at retryActionability (http://localhost:5601/__cypress/runner/cypress_runner.js:150616:16)
      at tryCatcher (http://localhost:5601/__cypress/runner/cypress_runner.js:13022:23)
      at Function.Promise.attempt.Promise.try (http://localhost:5601/__cypress/runner/cypress_runner.js:10296:29)
      at whenStable (http://localhost:5601/__cypress/runner/cypress_runner.js:168808:63)
      at http://localhost:5601/__cypress/runner/cypress_runner.js:168305:14
      at tryCatcher (http://localhost:5601/__cypress/runner/cypress_runner.js:13022:23)
      at Promise._settlePromiseFromHandler (http://localhost:5601/__cypress/runner/cypress_runner.js:10957:31)
      at Promise._settlePromise (http://localhost:5601/__cypress/runner/cypress_runner.js:11014:18)
      at Promise._settlePromise0 (http://localhost:5601/__cypress/runner/cypress_runner.js:11059:10)
      at Promise._settlePromises (http://localhost:5601/__cypress/runner/cypress_runner.js:11139:18)
      at Promise._fulfill (http://localhost:5601/__cypress/runner/cypress_runner.js:11083:18)
      at http://localhost:5601/__cypress/runner/cypress_runner.js:12697:46
  From Your Spec Code:
      at Context.eval (http://localhost:5601/__cypress/tests?p=cypress/support/index.js:3171:3)

After some debugging we realize if adding 2000ms wait before the click, test would pass consistently suggesting the element needs time to load in https://github.com/opensearch-project/opensearch-dashboards-functional-test/blob/d486264c185825729f60a1e135b01a9c12c29eed/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/embed.spec.js

    cy.tbClickTableCellAction(2, 0, 0, 'expand', 0, true);
->cy.wait(2000);
    cy.tbClickFilterFromExpand('filter for');
    cy.reload();
    cy.tbGetTableDataFromVisualization().then((data) => {
@@ -157,6 +158,7 @@ describe('table visualization in embedded mode', () => {
        expect(data).to.deep.eq(expectedData);
      });
      cy.tbClickTableCellAction(2, 0, 0, 'expand', 0, true);
->cy.wait(2000);
      cy.tbClickFilterFromExpand('filter out');
      cy.reload();
      cy.tbGetTableDataFromVisualization().then((data) => {

We need some proper way to fix this permanently as well as other similar cases.

Thanks.

@peterzhuamazon
Copy link
Member Author

Before certain stuck we can clearly see there uncaught exceptions:
Screenshot 2024-06-22 at 8 28 38 AM

@ashwin-pc
Copy link
Member

Instead of waits, I think we should try changing these to should('be.visible') in the cy.tbClickFilterFromExpand helper before executing the clicks.

@ashwin-pc
Copy link
Member

Also this applies to all the tests in this file that come into the Dom after the page has loaded

@peterzhuamazon
Copy link
Member Author

Before certain stuck we can clearly see there uncaught exceptions: Screenshot 2024-06-22 at 8 28 38 AM

Apparently this PR is missed in backports, thus showing all these errors here:

Screenshot 2024-06-22 at 8 28 38 AM

cc: @ashwin-pc @abbyhu2000
Thanks!

@peterzhuamazon peterzhuamazon moved this to What can be improved 🟡 in OpenSearch Project Retrospective Jun 24, 2024
@peterzhuamazon peterzhuamazon changed the title [BUG] Random failure on embed.spec.js due to click too early [Enhancement] Random failure on embed.spec.js due to click too early Jun 24, 2024
@dblock
Copy link
Member

dblock commented Jul 15, 2024

[Catch All Triage - 1, 2]

@dblock dblock removed the untriaged label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: What can be improved 🟡
Development

No branches or pull requests

3 participants