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
Fix flaky embedding-reproductions test (#64702)
Kamil Mielnik1a645a55d6a5
diff --git a/e2e/support/commands.js b/e2e/support/commands.jsindex 6fa097fb2cc..6dd539bbf26 100644--- a/e2e/support/commands.js+++ b/e2e/support/commands.js@@ -1,3 +1,5 @@+import "cypress-iframe";+// this is the only place we allow direct helper import// eslint-disable-next-line no-direct-helper-importimport { H } from "e2e/support";diff --git a/e2e/support/helpers/e2e-embedding-helpers.js b/e2e/support/helpers/e2e-embedding-helpers.jsindex 4281148bfbe..6c1881d0954 100644--- a/e2e/support/helpers/e2e-embedding-helpers.js+++ b/e2e/support/helpers/e2e-embedding-helpers.js@@ -178,13 +178,9 @@ function getIframeUrl() {* @param {string} [selector]*/export function getIframeBody(selector = "iframe") {- return cy- .get(selector)- .its("0.contentDocument")- .should("exist")- .its("body")- .should("not.be.undefined")- .then(cy.wrap);+ cy.frameLoaded(selector);+ cy.wait(1); // unclear why, but the tests are flaky without this+ return cy.iframe(selector);}export function getEmbedModalSharingPane() {diff --git a/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.ts b/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.tsindex 935ac031f5a..4f661059cb6 100644--- a/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.ts+++ b/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.ts@@ -93,9 +93,10 @@ export const getSimpleEmbedIframeContent = (iframeIndex = 0) => {*/export function loadSdkIframeEmbedTestPage({origin = "",+ selector,onVisitPage,...options-}: BaseEmbedTestPageOptions) {+}: BaseEmbedTestPageOptions & { selector?: string }) {const testPageSource = getSdkIframeEmbedHtml(options);const testPageUrl = `${origin}/sdk-iframe-test-page`;@@ -108,7 +109,7 @@ export function loadSdkIframeEmbedTestPage({cy.visit(testPageUrl, { onLoad: onVisitPage });cy.title().should("include", "Metabase Embed Test");- return getIframeBody();+ return getIframeBody(selector);}/**diff --git a/e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.js b/e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.jsindex 517e080fe69..5dc5fd1be6e 100644--- a/e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.js+++ b/e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.js@@ -957,24 +957,23 @@ describe("issue 40660", () => {});});- it(- "static dashboard content shouldn't overflow its container (metabase#40660)",- { tags: "@flaky" },- () => {- H.openStaticEmbeddingModal({- activeTab: "parameters",- previewMode: "preview",- });-- H.getIframeBody().within(() => {- cy.findByTestId("embed-frame").scrollTo("bottom");+ it("static dashboard content shouldn't overflow its container (metabase#40660)", () => {+ H.openStaticEmbeddingModal({+ activeTab: "parameters",+ previewMode: "preview",+ });- cy.findByRole("link", { name: "Powered by Metabase" })- .scrollIntoView()- .should("be.visible");- });- },- );+ H.getIframeBody().within(() => {+ cy.findByText(dashboardDetails.name).should("be.visible");+ cy.findByTestId("loading-indicator").should("not.exist");+ cy.findAllByText("1018947080336").should("have.length", 3);+ cy.findByTestId("embed-frame").scrollTo("bottom");++ cy.findByRole("link", { name: "Powered by Metabase" })+ .scrollIntoView()+ .should("be.visible");+ });+ });});// Skipped since it does not make sense when CSP is disableddiff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-iframe-embedding.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-iframe-embedding.cy.spec.tsindex 972df614e4b..b2e30e73cbc 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-iframe-embedding.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/sdk-iframe-embedding.cy.spec.ts@@ -351,6 +351,7 @@ H.describeWithSnowplowEE(attributes: {},},],+ selector: `[dashboard-id="${ORDERS_DASHBOARD_ID}"] > iframe`, // get only the first iframe});frame.within(() => {diff --git a/package.json b/package.jsonindex 0172c5ad0e1..b2d5e2624f9 100644--- a/package.json+++ b/package.json@@ -258,6 +258,7 @@"crypto-browserify": "^3.12.0","css-loader": "^6.10.0","cypress": "^14.5.3",+ "cypress-iframe": "^1.0.1","cypress-multi-reporters": "^1.6.4","cypress-on-fix": "^1.1.0","cypress-real-events": "^1.14.0",diff --git a/yarn.lock b/yarn.lockindex 32a2c140c5e..e5537c02ab0 100644--- a/yarn.lock+++ b/yarn.lock@@ -8636,6 +8636,11 @@ currently-unhandled@^0.4.1:dependencies:array-find-index "^1.0.1"+cypress-iframe@^1.0.1:+ version "1.0.1"+ resolved "https://registry.yarnpkg.com/cypress-iframe/-/cypress-iframe-1.0.1.tgz#2a286cfd47a240aa9af0ad9f339f4c6f942089f8"+ integrity sha512-Ne+xkZmWMhfq3x6wbfzK/SzsVTCrJru3R3cLXsoSAZyfUtJDamXyaIieHXeea3pQDXF4wE2w4iUuvCYHhoD31g==+cypress-multi-reporters@^1.6.4:version "1.6.4"resolved "https://registry.yarnpkg.com/cypress-multi-reporters/-/cypress-multi-reporters-1.6.4.tgz#6f9d25ed8a0d8d7fa5597977adcd2237d1249931"