The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Make `isRenderedWithinViewport` retry until element settles in viewport (#77401)
github-automation-metabasec06c3b8f1674
diff --git a/e2e/support/commands/visibility/isRenderedWithinViewport.js b/e2e/support/commands/visibility/isRenderedWithinViewport.jsindex aea550ce487..14f3d16f79a 100644--- a/e2e/support/commands/visibility/isRenderedWithinViewport.js+++ b/e2e/support/commands/visibility/isRenderedWithinViewport.js@@ -5,12 +5,20 @@ Cypress.Commands.add(},(subject) => {const viewportTop = 0;- const viewportBottom = Cypress.$(cy.state("window")).height();- const element = subject[0].getBoundingClientRect();- expect(element.top).to.be.greaterThan(viewportTop);- expect(element.bottom).to.be.greaterThan(viewportTop);- expect(element.top).not.to.be.greaterThan(viewportBottom);- expect(element.bottom).not.to.be.greaterThan(viewportBottom);+ // Retry the geometry check: callers assert this right after an action that+ // scrolls the element into view (e.g. "focus" the recently moved filter),+ // and the scroll may still be settling. Reading getBoundingClientRect once+ // races that scroll; wrapping the assertions in `.should()` lets Cypress+ // re-read the rect until it lands within the viewport (or times out).+ cy.wrap(subject).should(($subject) => {+ const viewportBottom = Cypress.$(cy.state("window")).height();+ const element = $subject[0].getBoundingClientRect();++ expect(element.top).to.be.greaterThan(viewportTop);+ expect(element.bottom).to.be.greaterThan(viewportTop);+ expect(element.top).not.to.be.greaterThan(viewportBottom);+ expect(element.bottom).not.to.be.greaterThan(viewportBottom);+ });},);