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
Consolidate static embed render and appearance e2e tests (#84879)
Chris Vandoodewaardc975e5b4e50a
diff --git a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.jsindex f71bce08100..7cbec4be676 100644--- a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js+++ b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js@@ -56,6 +56,7 @@ describe("scenarios > embedding > static embedding dashboard", () => {cy.findByRole("heading", { name: "Orders in a dashboard" }).should("be.visible",);+ cy.findByTestId("embed-frame").findAllByRole("gridcell").contains("37.65");cy.log("GET /api/database should not be called");cy.get("@getDatabases.all").should("have.length", 0);});@@ -1414,27 +1415,27 @@ describe("scenarios > embedding > dashboard appearance", () => {cy.get('html[data-mantine-color-scheme="light"]').should("exist");cy.get('html[data-metabase-theme="light"]').should("exist");- cy.log("Test explicit light theme via hash parameter");- visitWithTheme("light");+ cy.log("Test explicit dark theme via hash parameter");+ visitWithTheme("dark");// Test functionality still works with theme parametercy.get("[data-testid=embed-frame]").should("be.visible");- cy.get('html[data-mantine-color-scheme="light"]').should("exist");- cy.get('html[data-metabase-theme="light"]').should("exist");+ cy.get('html[data-mantine-color-scheme="dark"]').should("exist");+ cy.get('html[data-metabase-theme="dark"]').should("exist");// Verify theme parameter is in URL hash- cy.location("hash").should("include", "theme=light");+ cy.location("hash").should("include", "theme=dark");- cy.log("Test explicit dark theme via hash parameter");- visitWithTheme("dark");+ cy.log("Test explicit light theme via hash parameter");+ visitWithTheme("light");// Test functionality still works with theme parametercy.get("[data-testid=embed-frame]").should("be.visible");- cy.get('html[data-mantine-color-scheme="dark"]').should("exist");- cy.get('html[data-metabase-theme="dark"]').should("exist");+ cy.get('html[data-mantine-color-scheme="light"]').should("exist");+ cy.get('html[data-metabase-theme="light"]').should("exist");// Verify theme parameter is in URL hash- cy.location("hash").should("include", "theme=dark");+ cy.location("hash").should("include", "theme=light");});it("should use transparent pivot table cells in static embedding's dark mode (metabase#61741)", () => {diff --git a/e2e/test/scenarios/embedding/embedding-hub.cy.spec.ts b/e2e/test/scenarios/embedding/embedding-hub.cy.spec.tsindex 1ca2bc469db..e09437932b4 100644--- a/e2e/test/scenarios/embedding/embedding-hub.cy.spec.ts+++ b/e2e/test/scenarios/embedding/embedding-hub.cy.spec.ts@@ -371,9 +371,13 @@ describe("scenarios > embedding > embedding hub > security", () => {// OSS leaves PLUGIN_ADMIN_SETTINGS.useUpsellFlow without a trigger, so// UpsellCta renders the store link; paid builds get a button that// opens the in-app flow instead.- cy.findByRole("link", { name: "Try Metabase Pro" }).should(- "be.visible",- );+ cy.findByRole("link", { name: "Try Metabase Pro" })+ .should("be.visible")+ .and(+ "have.attr",+ "href",+ "https://www.metabase.com/upgrade?utm_source=product&utm_medium=upsell&utm_campaign=embedding-hub&utm_content=embedding-hub-security&source_plan=oss&utm_users=10",+ );cy.findByText("Cross-Origin Resource Sharing (CORS)").should("exist");});diff --git a/e2e/test/scenarios/embedding/embedding-questions.cy.spec.js b/e2e/test/scenarios/embedding/embedding-questions.cy.spec.jsindex a8bc5dcfdaa..c86ccdcc8d6 100644--- a/e2e/test/scenarios/embedding/embedding-questions.cy.spec.js+++ b/e2e/test/scenarios/embedding/embedding-questions.cy.spec.js@@ -59,30 +59,44 @@ describe("scenarios > embedding > questions", () => {H.visitIframe();- cy.url().should("include", "embed");-cy.findByTestId("embed-frame").within(() => {cy.findByText("Total Orders");cy.findByText("18,760");});});- it("should display the regular GUI question correctly", () => {+ it("should display GUI questions correctly", () => {const { name: title, description } = regularQuestion;- H.createQuestion(regularQuestion).then(({ body: { id } }) => {- cy.request("PUT", `/api/card/${id}`, { enable_embedding: true });-- H.visitQuestion(id);- H.openLegacyStaticEmbeddingModal({- resource: "question",- resourceId: id,- activeTab: "parameters",- unpublishBeforeOpen: false,- });+ H.createQuestion(+ { ...regularQuestion, enable_embedding: true },+ { wrapId: true, idAlias: "regularQuestionId" },+ );+ H.createQuestion({+ ...regularQuestion,+ enable_embedding: false,+ }).then(({ body: { id: sourceQuestionId } }) => {+ H.createQuestion(+ {+ query: { "source-table": `card__${sourceQuestionId}`, limit: 10 },+ enable_embedding: true,+ },+ { wrapId: true, idAlias: "nestedQuestionId" },+ );});+ H.createQuestion(+ { ...questionWithAggregation, enable_embedding: true },+ { wrapId: true, idAlias: "aggregationQuestionId" },+ );+ H.createQuestion(+ { ...joinedQuestion, enable_embedding: true },+ { wrapId: true, idAlias: "joinedQuestionId" },+ );- H.visitIframe();+ cy.log("Regular question");+ cy.get("@regularQuestionId").then((questionId) => {+ H.visitEmbeddedPage({ resource: { question: questionId }, params: {} });+ });cy.findByTestId("embed-frame").within(() => {cy.findByText(title);@@ -111,23 +125,35 @@ describe("scenarios > embedding > questions", () => {// Data model: Subtotal is turned off globallycy.findByText("Subtotal").should("not.exist");});- });- it("should display the GUI question with aggregation correctly", () => {- H.createQuestion(questionWithAggregation).then(({ body: { id } }) => {- cy.request("PUT", `/api/card/${id}`, { enable_embedding: true });+ cy.log("Nested question");+ cy.get("@nestedQuestionId").then((questionId) => {+ H.visitEmbeddedPage({ resource: { question: questionId }, params: {} });+ });- H.visitQuestion(id);+ cy.findByTestId("embed-frame").within(() => {+ // Global (Data model) settings should be preserved+ cy.findByText("Product ID as Title");+ cy.findByText("Awesome Concrete Shoes");- H.openLegacyStaticEmbeddingModal({- resource: "question",- resourceId: id,- activeTab: "parameters",- unpublishBeforeOpen: false,- });+ // Custom column+ cy.findByText("Math");++ // Base question visualization settings should reset to the defaults (inherit global formatting)+ cy.findByText("Total");+ cy.findByText("39.72");+ cy.findByText("February 11, 2028, 9:40 PM");++ cy.findAllByTestId("mini-bar-container").should("not.exist");++ // Data model: Subtotal is turned off globally+ cy.findByText("Subtotal").should("not.exist");});- H.visitIframe();+ cy.log("Question with aggregation");+ cy.get("@aggregationQuestionId").then((questionId) => {+ H.visitEmbeddedPage({ resource: { question: questionId }, params: {} });+ });assertOnXYAxisLabels({ xLabel: "Created At", yLabel: "Count" });@@ -146,71 +172,12 @@ describe("scenarios > embedding > questions", () => {header: "Aug 2025",rows: [{ name: "2", value: "79" }],});- });-- it("should display the nested GUI question correctly", () => {- H.createQuestion(regularQuestion).then(({ body: { id } }) => {- const nestedQuestion = {- query: { "source-table": `card__${id}`, limit: 10 },- };-- H.createQuestion(nestedQuestion).then(({ body: { id: nestedId } }) => {- cy.request("PUT", `/api/card/${nestedId}`, { enable_embedding: true });-- H.visitQuestion(nestedId);-- H.openLegacyStaticEmbeddingModal({- resource: "question",- resourceId: nestedId,- activeTab: "parameters",- unpublishBeforeOpen: false,- });- });- });-- H.visitIframe();-- // Global (Data model) settings should be preserved- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Product ID as Title");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Awesome Concrete Shoes");-- // Custom column- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Math");-- // Base question visualization settings should reset to the defaults (inherit global formatting)- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Total");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("39.72");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("February 11, 2028, 9:40 PM");-- cy.findAllByTestId("mini-bar-container").should("not.exist");-- // Data model: Subtotal is turned off globally- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Subtotal").should("not.exist");- });-- it("should display GUI question with explicit joins correctly", () => {- H.createQuestion(joinedQuestion).then(({ body: { id } }) => {- cy.request("PUT", `/api/card/${id}`, { enable_embedding: true });- H.visitQuestion(id);-- H.openLegacyStaticEmbeddingModal({- resource: "question",- resourceId: id,- activeTab: "parameters",- unpublishBeforeOpen: false,- });+ cy.log("Question with explicit joins");+ cy.get("@joinedQuestionId").then((questionId) => {+ H.visitEmbeddedPage({ resource: { question: questionId }, params: {} });});- H.visitIframe();-// Base question assertionscy.findByTestId("visualization-root").should("contain", "Product ID as Title")@@ -238,18 +205,6 @@ describe("scenarios [EE] > embedding > questions", () => {H.restore();cy.signInAsAdmin();H.activateToken("pro-self-hosted");-- // Remap Product ID -> Product Title- cy.request("POST", `/api/field/${ORDERS.PRODUCT_ID}/dimension`, {- name: "Product ID as Title",- type: "external",- human_readable_field_id: PRODUCTS.TITLE,- });-- // Do not include Subtotal anywhere- cy.request("PUT", `/api/field/${ORDERS.SUBTOTAL}`, {- visibility_type: "sensitive",- });});it("should display according to `#locale` and `#font` hash parameters (metabase#22561, metabase#50182, metabase#45638)", () => {@@ -288,9 +243,9 @@ describe("scenarios [EE] > embedding > questions", () => {});function assertOnXYAxisLabels({ xLabel, yLabel } = {}) {- H.echartsContainer().get("text").contains(xLabel);+ H.echartsContainer().find("text").contains(xLabel);- H.echartsContainer().get("text").contains(yLabel);+ H.echartsContainer().find("text").contains(yLabel);}describe("issue 30535", () => {@@ -314,29 +269,23 @@ describe("issue 30535", () => {},});- H.createQuestion(questionDetails).then(({ body: { id } }) => {- cy.request("PUT", `/api/card/${id}`, { enable_embedding: true });-- H.visitQuestion(id);-- H.openLegacyStaticEmbeddingModal({- resource: "question",- resourceId: id,- activeTab: "parameters",- previewMode: "preview",- unpublishBeforeOpen: false,- });- });+ H.createQuestion(+ { ...questionDetails, enable_embedding: true },+ { wrapId: true },+ );});it("user session should not apply sandboxing to a signed embedded question (metabase#30535)", () => {- cy.document().then((doc) => {- const iframe = doc.querySelector("iframe");-- cy.signOut();- cy.signInAsSandboxedUser();+ cy.get("@questionId").then((questionId) => {+ H.getEmbeddedPageUrl({+ resource: { question: questionId },+ params: {},+ }).then((urlOptions) => {+ cy.signOut();+ cy.signInAsSandboxedUser();- cy.visit(iframe.src);+ cy.visit(urlOptions);+ });});cy.findByRole("grid").within(() => {@@ -355,23 +304,13 @@ describe("issue 63687", () => {});it("should properly display pin map tiles without auth errors for a valid JWT token", () => {- H.createNativeQuestion(questionAsPinMapWithTiles, {- visitQuestion: true,- wrapId: true,- });-- cy.get("@questionId").then((questionId) => {- H.openLegacyStaticEmbeddingModal({- resource: "question",- resourceId: questionId,- activeTab: "parameters",- unpublishBeforeOpen: false,- });- });+ H.createNativeQuestion(questionAsPinMapWithTiles, { wrapId: true });cy.intercept("/api/embed/tiles/**").as("getTiles");- H.visitIframe();+ cy.get("@questionId").then((questionId) => {+ H.visitEmbeddedPage({ resource: { question: questionId }, params: {} });+ });cy.wait("@getTiles").then(({ response: tileResponse }) => {expect(tileResponse?.statusCode).to.equal(200);diff --git a/e2e/test/scenarios/embedding/embedding-smoketests.cy.spec.js b/e2e/test/scenarios/embedding/embedding-smoketests.cy.spec.jsindex 6368a4dca4f..7b78140f1dd 100644--- a/e2e/test/scenarios/embedding/embedding-smoketests.cy.spec.js+++ b/e2e/test/scenarios/embedding/embedding-smoketests.cy.spec.js@@ -8,7 +8,7 @@ import {const standalonePath = "/embedding/security";-// These tests will run on both OSS and EE instances. Both without a token!+// These tests run only on OSS builds, without a token.describe("scenarios > embedding > smoke tests", { tags: "@OSS" }, () => {beforeEach(() => {H.restore();@@ -24,11 +24,11 @@ describe("scenarios > embedding > smoke tests", { tags: "@OSS" }, () => {cy.visit(`/model/${ORDERS_QUESTION_ID}`);cy.wait("@dataset");- H.sharingMenuButton().should("not.exist");-cy.findByTestId("view-footer").within(() => {cy.icon("download").should("exist");});++ H.sharingMenuButton().should("not.exist");});context("embedding disabled", () => {@@ -38,19 +38,6 @@ describe("scenarios > embedding > smoke tests", { tags: "@OSS" }, () => {resetEmbedding();});- it("should show the sdk upsell link in oss", () => {- cy.visit("/embedding/security");-- mainPage().within(() => {- cy.findByRole("link", { name: "Try Metabase Pro" })- .should("have.attr", "href")- .and(- "eq",- "https://www.metabase.com/upgrade?utm_source=product&utm_medium=upsell&utm_campaign=embedding-hub&utm_content=embedding-hub-security&source_plan=oss&utm_users=10",- );- });- });-it("should not let you use non-guest auth methods", () => {H.visitQuestion(ORDERS_QUESTION_ID);@@ -85,6 +72,19 @@ describe("scenarios > embedding > smoke tests", { tags: "@OSS" }, () => {"currentlyEmbeddedObject",);+ if (object === "dashboard") {+ H.createQuestion({+ name: "Total Orders",+ dashboard_id: ORDERS_DASHBOARD_ID,+ database_id: SAMPLE_DATABASE.id,+ query: {+ "source-table": SAMPLE_DATABASE.ORDERS_ID,+ aggregation: [["count"]],+ },+ display: "scalar",+ });+ }+visitAndEnableSharing(object);H.modal().within(() => {@@ -108,9 +108,9 @@ describe("scenarios > embedding > smoke tests", { tags: "@OSS" }, () => {? "Results (csv, xlsx, json, png)": "Download (csv, xlsx, json, png)",).should("not.exist");- cy.findByRole("button", { name: "Export as PDF" }).should(- "not.exist",- );+ if (object === "dashboard") {+ cy.findByLabelText("Export to PDF").should("not.exist");+ }cy.findByRole("tab", { name: "Parameters" }).click();@@ -128,10 +128,16 @@ describe("scenarios > embedding > smoke tests", { tags: "@OSS" }, () => {});H.visitIframe();+ cy.url().should("contain", `/embed/${object}/`);cy.findByTestId("embed-frame").within(() => {cy.findByRole("heading", { name: objectName });cy.findAllByRole("gridcell").contains("37.65");++ if (object === "dashboard") {+ cy.findByText("Total Orders");+ cy.findByText("18,760");+ }});cy.findByRole("contentinfo").within(() => {@@ -177,9 +183,18 @@ describe("scenarios > embedding > smoke tests", { tags: "@OSS" }, () => {"Embedding is not enabled for this object.",);+ cy.intercept("GET", "/api/card/embeddable").as("embeddableCards");+ cy.intercept("GET", "/api/dashboard/embeddable").as(+ "embeddableDashboards",+ );cy.signInAsAdmin();cy.visit(standalonePath);- cy.wait("@currentlyEmbeddedObject");+ cy.wait(["@embeddableCards", "@embeddableDashboards"]).each(+ (interception) => {+ expect(interception.response.body).to.have.length(0);+ },+ );+ cy.findByTestId("embedding-secret-key-setting").should("be.visible");// The hub's Security tab renders this section only when published// guest embeds exist, so unpublishing empties it rather than@@ -188,49 +203,6 @@ describe("scenarios > embedding > smoke tests", { tags: "@OSS" }, () => {});});- it("should be able to publish/embed a dashboard with a dashboard question saved within it", () => {- H.createQuestion({- name: "Total Orders",- dashboard_id: ORDERS_DASHBOARD_ID,- database_id: SAMPLE_DATABASE.id,- query: {- "source-table": SAMPLE_DATABASE.ORDERS_ID,- aggregation: [["count"]],- },- display: "scalar",- enable_embedding: true,- });-- cy.request("PUT", "/api/setting/enable-embedding-modular", {- value: true,- });-- cy.intercept("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`).as(- "embedObject",- );- cy.intercept("GET", "/api/dashboard/embeddable").as(- "currentlyEmbeddedObject",- );-- visitAndEnableSharing("dashboard");-- H.modal().within(() => {- cy.findByRole("tab", { name: "Look and Feel" }).click();- cy.button("Publish").click();-- cy.wait("@embedObject");- });-- H.visitIframe();- cy.url().should("contain", "/embed/dashboard/");-- cy.findByTestId("embed-frame").within(() => {- cy.findByRole("heading", { name: "Orders in a dashboard" });- cy.findByText("Total Orders");- cy.findByText("18,760");- });- });-it("should regenerate embedding token and invalidate previous embed url", () => {cy.request("PUT", "/api/setting/enable-embedding-modular", {value: true,diff --git a/e2e/test/scenarios/embedding/embedding-snippets.cy.spec.js b/e2e/test/scenarios/embedding/embedding-snippets.cy.spec.jsindex 436a27d1921..2f63d2c8081 100644--- a/e2e/test/scenarios/embedding/embedding-snippets.cy.spec.js+++ b/e2e/test/scenarios/embedding/embedding-snippets.cy.spec.js@@ -24,14 +24,15 @@ tokens.forEach((token) => {H.activateToken(token);});- it("dashboard should have the correct embed snippet", () => {+ it("dashboard and question should have the correct embed snippets", () => {const defaultDownloadsValue =token === "pro-self-hosted" ? true : undefined;++ cy.log("Dashboard");H.visitDashboard(ORDERS_DASHBOARD_ID);H.openLegacyStaticEmbeddingModal({resource: "dashboard",resourceId: ORDERS_DASHBOARD_ID,- acceptTerms: false,});H.modal().within(() => {@@ -125,16 +126,12 @@ tokens.forEach((token) => {highlightedTexts().should("have.length", 1);}});- });- it("question should have the correct embed snippet", () => {- const defaultDownloadsValue =- token === "pro-self-hosted" ? true : undefined;+ cy.log("Question");H.visitQuestion(ORDERS_QUESTION_ID);H.openLegacyStaticEmbeddingModal({resource: "question",resourceId: ORDERS_QUESTION_ID,- acceptTerms: false,});H.modal().within(() => {