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

fix(cypress): Fix failing/flaky E2E tests #22460

Merged
merged 5 commits into from
Dec 20, 2022

Conversation

codyml
Copy link
Member

@codyml codyml commented Dec 20, 2022

SUMMARY

This PR attempts to fix some failing/flaky Cypress tests:

The code changes include:

  • Replacing .then with .should calls in drilltodetail.test.ts to allow for retries within the callback
  • Adding a timed .wait in nativeFilters.test.ts to give the filter bar orientation menu time to change orientation after scrolling into position
  • Switching the target for .type from the input's parent to the input itself in horizontal filter bar tests, as the input's parent was at times not considered "visible" by Cypress
  • Making Cypress wait for the confirmation toast to appear after saving a chart to a dashboard before navigating away from the page

TESTING INSTRUCTIONS

  • Check that E2E tests pass on CI, and feel free to re-run a few times to try to catch any extra issues
  • Run Cypress E2E tests locally several times with throttling enabled, specifically looking for issues in:
    • dashboard/drilltodetail.test.ts
    • dashboard/nativeFilters.test.ts
    • chart_list/list.test.ts

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Dec 20, 2022

Codecov Report

Merging #22460 (f1f0a91) into master (858796b) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master   #22460   +/-   ##
=======================================
  Coverage   66.89%   66.89%           
=======================================
  Files        1850     1850           
  Lines       70701    70701           
  Branches     7750     7750           
=======================================
  Hits        47292    47292           
  Misses      21393    21393           
  Partials     2016     2016           
Flag Coverage Δ
javascript 53.86% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for taking on this challenge, as CI has been pretty painful lately ❤️

@@ -82,7 +82,7 @@ function prepareDashboardFilters(
}).then(res => {
const { body } = res;
const dashboardId = body.result.id;
const allFilters: Record<string, any>[] = [];
const allFilters: Record<string, unknown>[] = [];
Copy link
Member

Choose a reason for hiding this comment

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

I believe these are Filters:

import { Filters } from '@superset-ui/core';

const allFilters: Record<string, Filters>[] = [];

Copy link
Member Author

@codyml codyml Dec 20, 2022

Choose a reason for hiding this comment

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

Hmm, I tried this but it gave me a "Module '"@superset-ui/core"' has no exported member 'Filter'." error. I also didn't see anywhere else in superset-frontend/cypress-base that imports from @superset-ui/core – do you know if these packages are supposed to be isolated for any reason?

Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

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

LGTM!

@geido geido merged commit 21b56b2 into apache:master Dec 20, 2022
expect($rows).to.contain('Amy');
});
// checking the paginated data
cy.get('.ant-pagination-item')
.should('have.length', 6)
.then($pages => {
.should($pages => {
Copy link
Member

Choose a reason for hiding this comment

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

Cool, I didn't know that should waits and then doesn't!

Copy link
Member Author

Choose a reason for hiding this comment

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

Me either, this PR was a learning experience!

@@ -202,6 +202,7 @@ function openVerticalFilterBar() {

function setFilterBarOrientation(orientation: 'vertical' | 'horizontal') {
cy.getBySel('filterbar-orientation-icon').click();
cy.wait(250);
Copy link
Member

Choose a reason for hiding this comment

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

Can we add timeout to getBySel instead of this wait? Like cy.getBySel('dropdown-selectable-info', { timeout: 250 })

Copy link
Member

Choose a reason for hiding this comment

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

Actually, not sure which method do we prefer in Superset, so feel free to leave it as is 🙂

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind, I didn't notice that it's merged 😄

Copy link
Member Author

@codyml codyml Dec 20, 2022

Choose a reason for hiding this comment

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

Haha no worries! The issue seemed to be that the loading of the page caused some scrolling action while the menu was opening, which disrupted Cypress's ability to click on the menu item even though it is able to find it, so this .wait hopefully will let the scrolling finish in more cases before Cypress tries to click on the menu item.

@EugeneTorap
Copy link
Contributor

Hi @codyml! I have problem with chart_list/filter.test.ts and dashboard_list/filter.test.ts

image
image

@EugeneTorap
Copy link
Contributor

@codyml Can you see my #22489 PR and check failed cypress CI?

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/S 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants