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
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 @@ -172,21 +172,21 @@ describe('Drill to detail modal', () => {
openModalFromMenu('big_number_total');
// checking the data
cy.getBySel('row-count-label').should('contain', '75.7k rows');
cy.get('.virtual-table-cell').then($rows => {
cy.get('.virtual-table-cell').should($rows => {
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!

expect($pages).to.contain('1');
expect($pages).to.contain('1514');
});
cy.get('.ant-pagination-item').eq(4).click();
// skips error on pagination
cy.on('uncaught:exception', () => false);
cy.wait('@samples');
cy.get('.virtual-table-cell').then($rows => {
cy.get('.virtual-table-cell').should($rows => {
expect($rows).to.contain('Kelly');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?

filters.forEach((f, i) => {
allFilters.push({
id: `NATIVE_FILTER-fLH0pxFQ${i}`,
Expand Down Expand Up @@ -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.

cy.getBySel('dropdown-selectable-info')
.contains('Orientation of filter bar')
.should('exist');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ export function getNativeFilterPlaceholderWithIndex(index: number) {
export function applyNativeFilterValueWithIndex(index: number, value: string) {
cy.get(nativeFilters.filterFromDashboardView.filterValueInput)
.eq(index)
.parent()
.should('be.visible', { timeout: 10000 })
.should('exist', { timeout: 10000 })
.type(`${value}{enter}`);
// click the title to dismiss shown options
cy.get(nativeFilters.filterFromDashboardView.filterName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export function saveChartToDashboard(dashboardName: string) {
cy.wait('@update');
cy.wait('@get');
cy.wait('@getExplore');
cy.contains(`was added to dashboard [${dashboardName}]`);
}

export function visitSampleChartFromList(chartName: string) {
Expand Down