Skip to content
Snippets Groups Projects
Unverified Commit 91ab0700 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

[E2E] Fix native field filter related flakes (#28410)

parent f1fa503f
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import Tether from "tether";
import cx from "classnames";
import OnClickOutsideWrapper from "metabase/components/OnClickOutsideWrapper";
import { isCypressActive } from "metabase/env";
import "./Popover.css";
......@@ -87,6 +88,10 @@ export default class Popover extends Component {
};
_getPopoverElement(isOpen) {
// 3s is an overkill for Cypress, but let's start with it and dial it down
// if we see that the flakes don't appear anymore
const resizeTimer = isCypressActive ? 3000 : 100;
if (!this._popoverElement && isOpen) {
this._popoverElement = document.createElement("span");
this._popoverElement.className = `PopoverContainer ${this.props.containerClassName}`;
......@@ -96,7 +101,7 @@ export default class Popover extends Component {
if (this.state.width !== width || this.state.height !== height) {
this.setState({ width, height });
}
}, 100);
}, resizeTimer);
}
return this._popoverElement;
}
......
......@@ -175,12 +175,15 @@ export function pickDefaultValue(searchTerm, result) {
cy.findByText("Enter a default value…").click();
cy.findByPlaceholderText("Enter a default value…").type(searchTerm);
// We could search for only one result inside popover()
// instead of `all` then `last`,
// but it flakes out as sometimes the popover
// is detached from the DOM.
// Popover is re-rendering every 100ms!
// That prevents us from targeting popover() element first,
// and then searching for strings inside of it.
//
cy.findAllByText(result).last().click();
// Until FE finds a better solution, our best bet for E2E tests
// is to make sure the string is "visible" before acting on it.
// This seems to help with the flakiness.
//
cy.findByTestId(`${result}-filter-value`).should("be.visible").click();
cy.button("Add filter").click();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment