Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Consolidate modular embedding component and navigation e2e specs (#84060)

Chris Vandoodewaard408c465ea8b1
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts
index ed42bb71c40..32851379297 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts
@@ -25,6 +25,41 @@ const clickEmbeddedTableCell = (value: string, rowsCount: number) => {
tableRoot().findByText(value).should("be.visible").click({ force: true });
};
+const LIMITED_ORDERS_QUESTION_DETAILS = {
+ name: "Limited Orders",
+ query: { "source-table": ORDERS_ID, limit: LIMITED_ORDERS_ROW_COUNT },
+};
+
+const LIMITED_ORDERS_DASHBOARD_NAME = "Limited Orders dashboard";
+
+const assertDrillsEnabled = () => {
+ clickEmbeddedTableCell("37.65", LIMITED_ORDERS_ROW_COUNT);
+
+ H.getSimpleEmbedIframeContent()
+ .findByText(/Filter by this value/)
+ .should("be.visible");
+
+ H.getSimpleEmbedIframeContent()
+ .findByTestId("click-actions-filter-section")
+ .find("button")
+ .first()
+ .click();
+
+ H.getSimpleEmbedIframeContent()
+ .findByTestId("table-root")
+ .findByText("29.8")
+ .should("be.visible");
+ H.getSimpleEmbedIframeContent().findByText("Save").should("not.exist");
+};
+
+const assertDrillsDisabled = () => {
+ clickEmbeddedTableCell("37.65", LIMITED_ORDERS_ROW_COUNT);
+
+ H.getSimpleEmbedIframeContent()
+ .findByText(/Filter by this value/)
+ .should("not.exist");
+};
+
describe("scenarios > embedding > sdk iframe embedding > custom elements api", () => {
beforeEach(() => {
cy.signInAsAdmin();
@@ -111,91 +146,63 @@ describe("scenarios > embedding > sdk iframe embedding > custom elements api", (
.should("have.css", "color", "rgb(18, 52, 86)");
});
- it("should show title when with-title is passed with no value", () => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript()}
- <metabase-dashboard dashboard-id="${ORDERS_DASHBOARD_ID}" with-title />
- `);
-
- H.getSimpleEmbedIframeContent()
- .findByText("Orders in a dashboard")
- .should("be.visible");
- });
-
- it("should show title when with-title is 'true'", () => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript()}
- <metabase-dashboard dashboard-id="${ORDERS_DASHBOARD_ID}" with-title="true" />
- `);
-
- H.getSimpleEmbedIframeContent()
- .findByText("Orders in a dashboard")
- .should("be.visible");
- });
-
- it("should hide title when with-title is false", () => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript()}
- <metabase-dashboard dashboard-id="${ORDERS_DASHBOARD_ID}" with-title="false" />
- `);
-
- H.getSimpleEmbedIframeContent()
- .findByText("Orders in a dashboard")
- .should("not.exist");
- });
-
- it("should enable drill-through when drills is true", () => {
- H.createQuestionAndDashboard({
- questionDetails: {
- name: "Limited Orders",
- query: { "source-table": ORDERS_ID, limit: LIMITED_ORDERS_ROW_COUNT },
+ (
+ [
+ {
+ attributes: "with-title drills",
+ withTitle: true,
+ drills: true,
+ withDownloads: false,
},
- }).then(({ body: { dashboard_id } }) => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript()}
- <metabase-dashboard dashboard-id="${dashboard_id}" drills />
- `);
-
- cy.wait("@getDashCardQuery");
-
- clickEmbeddedTableCell("37.65", LIMITED_ORDERS_ROW_COUNT);
-
- H.getSimpleEmbedIframeContent()
- .findByText(/Filter by this value/)
- .should("be.visible");
- });
- });
-
- it("should disable drill-through when drills is false", () => {
- H.createQuestionAndDashboard({
- questionDetails: {
- name: "Limited Orders",
- query: { "source-table": ORDERS_ID, limit: LIMITED_ORDERS_ROW_COUNT },
+ {
+ attributes: 'with-title="false" drills="false" with-downloads',
+ withTitle: false,
+ drills: false,
+ withDownloads: true,
},
- }).then(({ body: { dashboard_id } }) => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript()}
- <metabase-dashboard dashboard-id="${dashboard_id}" drills="false" />
- `);
-
- cy.wait("@getDashCardQuery");
+ {
+ attributes: 'with-title="true" drills="true" with-downloads',
+ withTitle: true,
+ drills: true,
+ withDownloads: true,
+ },
+ ] as const
+ ).forEach(({ attributes, withTitle, drills, withDownloads }) => {
+ it(`should apply \`${attributes}\``, () => {
+ H.createQuestionAndDashboard({
+ questionDetails: LIMITED_ORDERS_QUESTION_DETAILS,
+ dashboardDetails: { name: LIMITED_ORDERS_DASHBOARD_NAME },
+ }).then(({ body: { dashboard_id } }) => {
+ H.visitCustomHtmlPage(`
+ ${H.getNewEmbedScriptTag()}
+ ${H.getNewEmbedConfigurationScript()}
+ <metabase-dashboard dashboard-id="${dashboard_id}" ${attributes} />
+ `);
- clickEmbeddedTableCell("37.65", LIMITED_ORDERS_ROW_COUNT);
+ cy.wait("@getDashCardQuery");
- H.getSimpleEmbedIframeContent()
- .findByText(/Filter by this value/)
- .should("not.exist");
+ H.getSimpleEmbedIframeContent()
+ .findByText(LIMITED_ORDERS_QUESTION_DETAILS.name)
+ .should("be.visible");
+ H.getSimpleEmbedIframeContent()
+ .findByText(LIMITED_ORDERS_DASHBOARD_NAME)
+ .should(withTitle ? "be.visible" : "not.exist");
+ H.getSimpleEmbedIframeContent()
+ .findByLabelText("Download as PDF")
+ .should(withDownloads ? "be.visible" : "not.exist");
+
+ if (drills) {
+ assertDrillsEnabled();
+ } else {
+ assertDrillsDisabled();
+ }
+ });
});
});
});
describe("<metabase-question>", () => {
- it("should embed a question with <metabase-question question-id='${number}'>", () => {
+ it("should embed a question with <metabase-question question-id='${number}'> and remove a column via viz settings (metabase#77135)", () => {
H.visitCustomHtmlPage(`
${H.getNewEmbedScriptTag()}
@@ -205,6 +212,17 @@ describe("scenarios > embedding > sdk iframe embedding > custom elements api", (
`);
H.getSimpleEmbedIframeContent(0).findByText("Orders").should("exist");
+
+ cy.log("remove a column via viz settings (metabase#77135)");
+ H.getSimpleEmbedIframeContent().within(() => {
+ H.tableInteractive().findByText("Tax").should("be.visible");
+
+ cy.findByTestId("viz-settings-button").click();
+ cy.findByRole("button", { name: /Add or remove columns/ }).click();
+
+ cy.findByLabelText("Tax").should("be.checked").click();
+ H.tableInteractive().findByText("Tax").should("not.exist");
+ });
});
it("should allow rendering two different questions in the same page", () => {
@@ -234,81 +252,69 @@ describe("scenarios > embedding > sdk iframe embedding > custom elements api", (
.should("exist", { timeout: 10000 });
});
- it("should show title when with-title is true", () => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript()}
- <metabase-question question-id="${ORDERS_QUESTION_ID}" with-title />
- `);
-
- H.getSimpleEmbedIframeContent().findByText("Orders").should("be.visible");
- });
-
- it("should hide title when with-title is false", () => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript()}
- <metabase-question question-id="${ORDERS_QUESTION_ID}" with-title="false" />
- `);
-
- H.getSimpleEmbedIframeContent().findByText("Orders").should("not.exist");
- });
-
- it("should hide download button when with-downloads is false", () => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript()}
- <metabase-question question-id="${ORDERS_QUESTION_ID}" with-downloads="false" />
- `);
-
- cy.wait("@getCardQuery");
-
- H.getSimpleEmbedIframeContent()
- .findByTestId("interactive-question-result-toolbar")
- .should("be.visible")
- .findByLabelText("download icon")
- .should("not.exist");
- });
-
- it("should enable drill-through when drills is true", () => {
- H.createQuestion({
- name: "Limited Orders",
- query: { "source-table": ORDERS_ID, limit: LIMITED_ORDERS_ROW_COUNT },
- }).then(({ body: { id: questionId } }) => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript()}
- <metabase-question question-id="${questionId}" drills />
- `);
-
- cy.wait("@getCardQuery");
-
- clickEmbeddedTableCell("37.65", LIMITED_ORDERS_ROW_COUNT);
-
- H.getSimpleEmbedIframeContent()
- .findByText(/Filter by this value/)
- .should("be.visible");
- });
- });
-
- it("should disable drill-through when drills is false", () => {
- H.createQuestion({
- name: "Limited Orders",
- query: { "source-table": ORDERS_ID, limit: LIMITED_ORDERS_ROW_COUNT },
- }).then(({ body: { id: questionId } }) => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript()}
- <metabase-question question-id="${questionId}" drills="false" />
- `);
-
- cy.wait("@getCardQuery");
-
- clickEmbeddedTableCell("37.65", LIMITED_ORDERS_ROW_COUNT);
-
- H.getSimpleEmbedIframeContent()
- .findByText(/Filter by this value/)
- .should("not.exist");
+ (
+ [
+ {
+ attributes: "with-title drills with-downloads",
+ withTitle: true,
+ drills: true,
+ withDownloads: true,
+ },
+ {
+ attributes: 'with-title="true" drills="false"',
+ withTitle: true,
+ drills: false,
+ withDownloads: undefined,
+ },
+ {
+ attributes: 'with-title="false" drills="true" with-downloads="false"',
+ withTitle: false,
+ drills: true,
+ withDownloads: false,
+ },
+ ] as const
+ ).forEach(({ attributes, withTitle, drills, withDownloads }) => {
+ it(`should apply \`${attributes}\``, () => {
+ H.createQuestion(LIMITED_ORDERS_QUESTION_DETAILS).then(
+ ({ body: { id: questionId } }) => {
+ H.visitCustomHtmlPage(`
+ ${H.getNewEmbedScriptTag()}
+ ${H.getNewEmbedConfigurationScript()}
+ <metabase-question question-id="${questionId}" ${attributes} />
+ `);
+
+ cy.wait("@getCardQuery");
+
+ H.getSimpleEmbedIframeContent()
+ .findByTestId("table-root")
+ .should(
+ "have.attr",
+ "data-rows-count",
+ String(LIMITED_ORDERS_ROW_COUNT),
+ );
+ H.getSimpleEmbedIframeContent()
+ .findByText(LIMITED_ORDERS_QUESTION_DETAILS.name)
+ .should(withTitle ? "be.visible" : "not.exist");
+
+ if (drills) {
+ H.getSimpleEmbedIframeContent()
+ .findByTestId("interactive-question-result-toolbar")
+ .should("be.visible")
+ .findByLabelText("download icon")
+ .should(withDownloads ? "be.visible" : "not.exist");
+ } else {
+ H.getSimpleEmbedIframeContent()
+ .findByTestId("interactive-question-result-toolbar")
+ .should("not.exist");
+ }
+
+ if (drills) {
+ assertDrillsEnabled();
+ } else {
+ assertDrillsDisabled();
+ }
+ },
+ );
});
});
@@ -319,6 +325,9 @@ describe("scenarios > embedding > sdk iframe embedding > custom elements api", (
<metabase-question question-id="new" is-save-enabled />
`);
+ H.getSimpleEmbedIframeContent().within(() => {
+ H.popover().findByText("Orders Model").should("be.visible");
+ });
H.getSimpleEmbedIframeContent().findByText("Orders").click();
H.getSimpleEmbedIframeContent().findByText("Save").should("be.visible");
});
@@ -583,8 +592,10 @@ describe("scenarios > embedding > sdk iframe embedding > custom elements api", (
<metabase-question question-id="new" entity-types='["table"]' />
`);
- H.getSimpleEmbedIframeContent().should("contain", "Orders");
- H.getSimpleEmbedIframeContent().should("not.contain", "Orders model");
+ H.getSimpleEmbedIframeContent().within(() => {
+ H.popover().findByText("Orders").should("be.visible");
+ H.popover().findByText("Orders Model").should("not.exist");
+ });
});
it("should support json5 with strings wrapped in single quotes", () => {
@@ -594,8 +605,10 @@ describe("scenarios > embedding > sdk iframe embedding > custom elements api", (
<metabase-question question-id="new" entity-types="['table']" />
`);
- H.getSimpleEmbedIframeContent().should("contain", "Orders");
- H.getSimpleEmbedIframeContent().should("not.contain", "Orders model");
+ H.getSimpleEmbedIframeContent().within(() => {
+ H.popover().findByText("Orders").should("be.visible");
+ H.popover().findByText("Orders Model").should("not.exist");
+ });
});
});
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/eajs-internal-navigation.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/eajs-internal-navigation.cy.spec.ts
index ca4ab4996c1..d9be12e0350 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/eajs-internal-navigation.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/eajs-internal-navigation.cy.spec.ts
@@ -153,7 +153,7 @@ describe("scenarios > embedding > sdk iframe embedding > internal-navigation", (
});
});
- it("should navigate to a linked dashboard with filters when clicking a dashboard link", () => {
+ it("should navigate to a linked dashboard with filters and to a linked question with parameters", () => {
cy.get<number>("@startingDashboardId").then((startingDashboardId) => {
H.visitCustomHtmlPage(`
${H.getNewEmbedScriptTag()}
@@ -196,18 +196,6 @@ describe("scenarios > embedding > sdk iframe embedding > internal-navigation", (
H.getSimpleEmbedIframeContent()
.findByText(/Back to/)
.should("not.exist");
- });
-
- it("should navigate to a linked question with parameters when clicking a question link", () => {
- cy.get<number>("@startingDashboardId").then((startingDashboardId) => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript({})}
- <metabase-dashboard dashboard-id="${startingDashboardId}" drills enable-entity-navigation />
- `);
- });
-
- cy.wait("@getDashCardQuery");
cy.log("click on the question link");
H.getSimpleEmbedIframeContent()
@@ -361,7 +349,7 @@ describe("scenarios > embedding > sdk iframe embedding > internal-navigation", (
});
});
- it("should hide breadcrumbs during internal navigation and show them again after going back", () => {
+ it("should hide breadcrumbs during internal navigation, show them again after going back, and clean up the navigation stack", () => {
H.visitCustomHtmlPage(`
${H.getNewEmbedScriptTag()}
${H.getNewEmbedConfigurationScript({})}
@@ -392,15 +380,18 @@ describe("scenarios > embedding > sdk iframe embedding > internal-navigation", (
.first()
.click();
+ cy.log("back button should be visible");
+ H.getSimpleEmbedIframeContent()
+ .findByText("Back to First Dashboard")
+ .should("be.visible");
+
cy.log("breadcrumbs should be hidden after navigating");
H.getSimpleEmbedIframeContent()
.findByTestId("sdk-breadcrumbs")
.should("not.exist");
- cy.log("back button should be visible");
H.getSimpleEmbedIframeContent()
.findByText("Back to First Dashboard")
- .should("be.visible")
.click();
cy.log("verify we returned to First Dashboard");
@@ -417,36 +408,6 @@ describe("scenarios > embedding > sdk iframe embedding > internal-navigation", (
H.getSimpleEmbedIframeContent()
.findByText(/Back to/)
.should("not.exist");
- });
-
- it("should clean up navigation stack when clicking a collection breadcrumb after navigating back", () => {
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript({})}
- <metabase-browser initial-collection="root" enable-entity-navigation />
- `);
-
- cy.log("open First Dashboard from the browser");
- H.getSimpleEmbedIframeContent()
- .findByText("First Dashboard")
- .should("be.visible")
- .click();
-
- cy.wait("@getDashCardQuery");
-
- cy.log("navigate to Target Dashboard via click behavior link");
- H.getSimpleEmbedIframeContent()
- .findAllByText("Go to Target Dashboard")
- .first()
- .click();
-
- cy.wait("@getDashboard");
-
- cy.log("click back to return to First Dashboard");
- H.getSimpleEmbedIframeContent()
- .findByText("Back to First Dashboard")
- .should("be.visible")
- .click();
cy.log(
"click 'Our analytics' breadcrumb to go back to the collection browser",
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.ts
index 688ca363311..05aa7155145 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.ts
@@ -1,7 +1,6 @@
import {
FIRST_COLLECTION_ID,
ORDERS_DASHBOARD_ID,
- ORDERS_QUESTION_ID,
} from "e2e/support/cypress_sample_instance_data";
const { H } = cy;
@@ -145,179 +144,6 @@ describe("scenarios > embedding > sdk iframe embed options passthrough", () => {
H.prepareSdkIframeEmbedTest({ signOut: true });
});
- it("shows a static question with drills=false", () => {
- const frame = H.loadSdkIframeEmbedTestPage({
- elements: [
- {
- component: "metabase-question",
- attributes: {
- questionId: ORDERS_QUESTION_ID,
- drills: false,
- },
- },
- ],
- });
-
- cy.wait("@getCardQuery");
-
- frame.within(() => {
- cy.log("1. static question must not contain title and toolbar");
- cy.findByTestId("interactive-question-result-toolbar").should(
- "not.exist",
- );
-
- cy.log("2. clicking on the column value should not show the popover");
- cy.findAllByText("37.65").first().should("be.visible");
- cy.findAllByText("37.65").first().click();
- cy.findByText(/Filter by this value/).should("not.exist");
- });
- });
-
- it("shows a static question with drills=false, withTitle=true", () => {
- const frame = H.loadSdkIframeEmbedTestPage({
- elements: [
- {
- component: "metabase-question",
- attributes: {
- questionId: ORDERS_QUESTION_ID,
- drills: false,
- withTitle: true,
- },
- },
- ],
- });
-
- cy.wait("@getCardQuery");
-
- frame.within(() => {
- cy.log("static question must contain title, but not toolbar");
- cy.findByText("Orders").should("be.visible");
- cy.findByTestId("interactive-question-result-toolbar").should(
- "not.exist",
- );
- });
- });
-
- it("shows a static dashboard using drills=false, withTitle=false, withDownloads=true", () => {
- const frame = H.loadSdkIframeEmbedTestPage({
- elements: [
- {
- component: "metabase-dashboard",
- attributes: {
- dashboardId: ORDERS_DASHBOARD_ID,
- drills: false,
- withTitle: false,
- withDownloads: true,
- },
- },
- ],
- });
-
- cy.wait("@getDashCardQuery");
-
- frame.within(() => {
- cy.log("1. card title should be visible");
- cy.findByText("Orders").should("be.visible");
-
- cy.log("2. dashboard title should not exist -- withTitle=false");
- cy.findByText("Orders in a dashboard").should("not.exist");
-
- cy.log("3. download button should be visible -- withDownloads=true");
- cy.get('[aria-label="Download as PDF"]').should("be.visible");
-
- cy.log("4. clicking on the column value should not show the popover");
- cy.findAllByText("37.65").first().should("be.visible");
-
- cy.findAllByText("37.65").first().click();
-
- cy.findByText(/Filter by this value/).should("not.exist");
- });
- });
-
- it("renders an interactive question with drills=true, withTitle=false, withDownloads=true", () => {
- const frame = H.loadSdkIframeEmbedTestPage({
- elements: [
- {
- component: "metabase-question",
- attributes: {
- questionId: ORDERS_QUESTION_ID,
- drills: true,
- withDownloads: true,
- withTitle: false,
- },
- },
- ],
- });
-
- cy.wait("@getCardQuery");
-
- frame.within(() => {
- cy.log("1. card title should not exist");
- cy.findByText("Orders").should("not.exist");
-
- cy.log("2. download button on the toolbar should be visible");
- cy.get("[aria-label='download icon']").should("be.visible");
-
- cy.log("3. clicking on the column value should show the popover");
- cy.findAllByText("37.65").first().should("be.visible");
- cy.findAllByText("37.65").first().click();
- cy.findByText(/Filter by this value/).should("be.visible");
-
- cy.log("4. clicking on the filter should drill down");
- cy.findByTestId("click-actions-filter-section")
- .find("button")
- .first()
- .click();
- cy.findAllByText("29.8").first().should("be.visible");
-
- cy.log("5. should not show a save button");
- cy.findByText("Save").should("not.exist");
- });
- });
-
- it("renders an interactive dashboard with drills=true, withDownloads=true, withTitle=false", () => {
- const frame = H.loadSdkIframeEmbedTestPage({
- elements: [
- {
- component: "metabase-dashboard",
- attributes: {
- dashboardId: ORDERS_DASHBOARD_ID,
- drills: true,
- withDownloads: true,
- withTitle: false,
- },
- },
- ],
- });
-
- cy.wait("@getDashCardQuery");
-
- frame.within(() => {
- cy.log("1. dashboard title should not exist -- withTitle=false");
- cy.findByText("Orders in a dashboard").should("not.exist");
-
- cy.log("2. card title should be visible");
- cy.findByText("Orders").should("be.visible");
-
- cy.log("3. download button should be visible -- withDownloads=true");
- cy.get('[aria-label="Download as PDF"]').should("be.visible");
-
- cy.log("4. clicking on the column value should show the popover");
- cy.findAllByText("37.65").first().should("be.visible").click();
- cy.findByText(/Filter by this value/).should("be.visible");
-
- cy.log("5. clicking on the filter should drill down");
- cy.findByTestId("click-actions-filter-section")
- .find("button")
- .first()
- .click();
- cy.findAllByText("29.8").first().should("be.visible");
-
- cy.log("6. saving should be disabled in drill-throughs");
- cy.findByText("Save").should("not.exist");
- });
- });
-
it("renders the exploration template with isSaveEnabled=true, targetCollection, entityTypes", () => {
const frame = H.loadSdkIframeEmbedTestPage({
elements: [
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/metabase-browser.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/metabase-browser.cy.spec.ts
index 76e7d2c9892..ee0f9394ff6 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/metabase-browser.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/metabase-browser.cy.spec.ts
@@ -55,7 +55,7 @@ describe("scenarios > embedding > sdk iframe embedding > metabase-browser", () =
});
});
- it("should not show New question button when user has no curate permissions on initial-collection", () => {
+ it("should not show Save button when opening an existing question from a read-only collection", () => {
H.prepareSdkIframeEmbedTest({
withToken: "bleeding-edge",
signOut: false,
@@ -87,48 +87,10 @@ describe("scenarios > embedding > sdk iframe embedding > metabase-browser", () =
`);
H.getSimpleEmbedIframeContent().within(() => {
- // User can see the collection contents (they have read access)
cy.findByText("Test Question").should("be.visible");
-
- // But New question button should be hidden since they can't save
cy.findByText("New question").should("not.exist");
- });
- });
- });
- it("should not show Save button when opening an existing question from a read-only collection", () => {
- H.prepareSdkIframeEmbedTest({
- withToken: "bleeding-edge",
- signOut: false,
- });
-
- H.createCollection({
- name: "Read Only Collection",
- }).then(({ body: collection }) => {
- cy.updateCollectionGraph({
- [DATA_GROUP_ID]: {
- root: READ,
- [collection.id]: READ,
- },
- });
-
- H.createQuestion({
- name: "Test Question",
- query: { "source-table": ORDERS_ID },
- collection_id: collection.id,
- });
-
- cy.signIn("nocollection");
-
- setupEmbed(`
- <metabase-browser
- initial-collection="${collection.id}"
- read-only="false"
- />
- `);
-
- H.getSimpleEmbedIframeContent().within(() => {
- cy.findByText("Test Question").should("be.visible").click();
+ cy.findByText("Test Question").click();
cy.findByTestId("visualization-root").should("be.visible");
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/reproductions.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/reproductions.cy.spec.ts
deleted file mode 100644
index f336a8aecf9..00000000000
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/reproductions.cy.spec.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-const { H } = cy;
-import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
-
-describe("issue 77135", () => {
- it("should add/remove columns via viz settings (EMB-2057)", () => {
- H.prepareSdkIframeEmbedTest({
- withToken: "bleeding-edge",
- signOut: false,
- });
-
- H.visitCustomHtmlPage(`
- ${H.getNewEmbedScriptTag()}
- ${H.getNewEmbedConfigurationScript({})}
- <metabase-question question-id="${ORDERS_QUESTION_ID}" />
- `);
-
- H.getSimpleEmbedIframeContent().within(() => {
- H.tableInteractive().findByText("Tax").should("be.visible");
-
- cy.findByTestId("viz-settings-button").click();
- cy.findByRole("button", { name: /Add or remove columns/ }).click();
-
- cy.findByLabelText("Tax").should("be.checked").click();
-
- H.tableInteractive().findByText("Tax").should("not.exist");
- });
- });
-});
diff --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.ts
index d5d7c33d658..0fbd3d7e935 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
@@ -22,65 +22,6 @@ describe("scenarios > embedding > modular embedding", () => {
});
});
- it("uses the embedding-simple client request header", () => {
- H.loadSdkIframeEmbedTestPage({
- elements: [
- {
- component: "metabase-dashboard",
- attributes: {
- dashboardId: ORDERS_DASHBOARD_ID,
- },
- },
- ],
- });
-
- cy.wait("@getDashCardQuery").then(({ request }) => {
- expect(request?.headers?.["x-metabase-client"]).to.equal(
- "embedding-simple",
- );
- });
- });
-
- it("displays a dashboard", () => {
- const frame = H.loadSdkIframeEmbedTestPage({
- elements: [
- {
- component: "metabase-dashboard",
- attributes: {
- dashboardId: ORDERS_DASHBOARD_ID,
- },
- },
- ],
- });
-
- cy.wait("@getDashCardQuery");
-
- frame.within(() => {
- cy.findByText("Orders in a dashboard").should("be.visible");
- cy.findByText("Orders").should("be.visible");
- H.assertTableRowsCount(2000);
- });
- });
-
- it("displays a question", () => {
- const frame = H.loadSdkIframeEmbedTestPage({
- elements: [
- {
- component: "metabase-question",
- attributes: {
- questionId: ORDERS_QUESTION_ID,
- },
- },
- ],
- });
-
- cy.wait("@getCardQuery");
-
- frame.within(() => {
- H.assertSdkInteractiveQuestionOrdersUsable();
- });
- });
-
it("table visualization should span the full width of the container (metabase#69831)", () => {
cy.signInAsAdmin();
H.createQuestion({
@@ -343,6 +284,12 @@ describe("scenarios > embedding > modular embedding", () => {
],
});
+ cy.wait("@getDashCardQuery").then(({ request }) => {
+ expect(request?.headers?.["x-metabase-client"]).to.equal(
+ "embedding-simple",
+ );
+ });
+
frame.within(() => {
cy.findByText("Orders in a dashboard").should("be.visible");
cy.findByText("Orders").should("be.visible");
@@ -554,6 +501,11 @@ describe("scenarios > embedding > modular embedding", () => {
});
it("should send an modular embedding usage event", () => {
+ let proxyCallCount = 0;
+ cy.intercept("POST", "/api/analytics-proxy", () => {
+ proxyCallCount++;
+ }).as("analyticsProxy");
+
cy.signOut();
cy.visit("http://localhost:4000");
const frame = H.loadSdkIframeEmbedTestPage({
@@ -733,6 +685,10 @@ describe("scenarios > embedding > modular embedding", () => {
},
],
});
+
+ cy.wrap(null).then(() => {
+ expect(proxyCallCount).to.eq(0);
+ });
});
it("should send locale_used=true when locale is configured", () => {
@@ -816,32 +772,6 @@ describe("scenarios > embedding > modular embedding", () => {
});
});
- it("should not send SDK tracker events through the analytics proxy", () => {
- let proxyCallCount = 0;
- cy.intercept("POST", "/api/analytics-proxy", () => {
- proxyCallCount++;
- }).as("analyticsProxy");
-
- cy.signOut();
- cy.visit("http://localhost:4000");
- H.loadSdkIframeEmbedTestPage({
- origin: "http://different-than-metabase-instance.com",
- elements: [
- {
- component: "metabase-dashboard",
- attributes: { dashboardId: ORDERS_DASHBOARD_ID },
- },
- ],
- selector: `[dashboard-id="${ORDERS_DASHBOARD_ID}"] > iframe`,
- }).within(() => {
- cy.findByText("Orders in a dashboard").should("be.visible");
- });
-
- cy.wrap(null).then(() => {
- expect(proxyCallCount).to.eq(0);
- });
- });
-
it("should not send an modular embedding usage event in the preview", () => {
cy.visit(`/question/${ORDERS_QUESTION_ID}`);
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/view-and-curate-content.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/view-and-curate-content.cy.spec.ts
index 4a4dc54dec2..017e31095cc 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/view-and-curate-content.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/view-and-curate-content.cy.spec.ts
@@ -15,34 +15,6 @@ describe("scenarios > embedding > sdk iframe embedding > view and curate content
});
describe("<metabase-browser> (read-only mode)", () => {
- it("should show a collection browser with collection items", () => {
- setupEmbed('<metabase-browser initial-collection="root" />');
-
- H.getSimpleEmbedIframeContent()
- .should("contain", "Name")
- .findAllByText("Orders")
- .first()
- .should("be.visible");
- });
-
- it("should navigate to question when clicking on a question item", () => {
- setupEmbed('<metabase-browser initial-collection="root" />');
-
- H.getSimpleEmbedIframeContent()
- .findByText("Orders")
- .should("be.visible")
- .click();
-
- cy.log("should show question view");
- cy.get("iframe[data-metabase-embed]").should(($iframe) => {
- const body = $iframe.contents().find("body");
- expect(body).to.exist;
- });
- H.getSimpleEmbedIframeContent()
- .findByTestId("query-visualization-root", { timeout: 20_000 })
- .should("be.visible");
- });
-
it("should show New Question button and open data picker when clicked", () => {
setupEmbed('<metabase-browser initial-collection="root" />');
@@ -54,6 +26,12 @@ describe("scenarios > embedding > sdk iframe embedding > view and curate content
H.getSimpleEmbedIframeContent()
.findByText("Pick your starting data")
.should("be.visible");
+
+ cy.log("the default data picker lists tables and models");
+ H.getSimpleEmbedIframeContent().within(() => {
+ H.popover().findByText("Orders").should("be.visible");
+ H.popover().findByText("Orders Model").should("be.visible");
+ });
});
it("should pass through collection-visible-columns parameter", () => {
@@ -92,6 +70,10 @@ describe("scenarios > embedding > sdk iframe embedding > view and curate content
/>
`);
+ H.getSimpleEmbedIframeContent()
+ .findAllByText("Orders")
+ .first()
+ .should("be.visible");
H.getSimpleEmbedIframeContent()
.findByText("New question")
.should("not.exist");
@@ -99,22 +81,6 @@ describe("scenarios > embedding > sdk iframe embedding > view and curate content
});
describe("<metabase-browser> (read-write mode)", () => {
- it("should show New Dashboard button and open modal when clicked", () => {
- setupEmbed(
- '<metabase-browser initial-collection="root" read-only="false" />',
- );
-
- H.getSimpleEmbedIframeContent()
- .findByText("New dashboard")
- .should("be.visible")
- .click();
-
- cy.log("should show create dashboard modal");
- H.getSimpleEmbedIframeContent()
- .findByText("New dashboard")
- .should("be.visible");
- });
-
it("should update breadcrumbs when creating dashboard in different collection", () => {
setupEmbed(
'<metabase-browser initial-collection="root" read-only="false" />',
@@ -158,22 +124,6 @@ describe("scenarios > embedding > sdk iframe embedding > view and curate content
.should("be.visible");
});
- it("should show New Question button and open data picker when clicked", () => {
- setupEmbed(
- '<metabase-browser initial-collection="root" read-only="false" />',
- );
-
- H.getSimpleEmbedIframeContent()
- .findByText("New question")
- .should("be.visible")
- .click();
-
- cy.log("should show data picker");
- H.getSimpleEmbedIframeContent()
- .findByText("Pick your starting data")
- .should("be.visible");
- });
-
it("should show Save button and save modal with entity picker preselecting the current collection when creating a new question (EMB-1609)", () => {
setupEmbed(
'<metabase-browser initial-collection="root" read-only="false" />',
@@ -211,6 +161,9 @@ describe("scenarios > embedding > sdk iframe embedding > view and curate content
/>
`);
+ H.getSimpleEmbedIframeContent()
+ .findByText("New question")
+ .should("be.visible");
H.getSimpleEmbedIframeContent()
.findByText("New dashboard")
.should("not.exist");
@@ -292,6 +245,9 @@ describe("scenarios > embedding > sdk iframe embedding > view and curate content
/>
`);
+ H.getSimpleEmbedIframeContent()
+ .findByText("New dashboard")
+ .should("be.visible");
H.getSimpleEmbedIframeContent()
.findByText("New question")
.should("not.exist");
@@ -313,9 +269,11 @@ describe("scenarios > embedding > sdk iframe embedding > view and curate content
.findByText("Pick your starting data")
.should("be.visible");
- cy.log("should show Orders table but not Orders model");
- H.getSimpleEmbedIframeContent().should("contain", "Orders");
- H.getSimpleEmbedIframeContent().should("not.contain", "Orders model");
+ cy.log("should show Orders table but not Orders Model");
+ H.getSimpleEmbedIframeContent().within(() => {
+ H.popover().findByText("Orders").should("be.visible");
+ H.popover().findByText("Orders Model").should("not.exist");
+ });
});
});
@@ -328,7 +286,19 @@ describe("scenarios > embedding > sdk iframe embedding > view and curate content
.findByText("Our analytics", { timeout: 10_000 })
.should("be.visible");
- H.getSimpleEmbedIframeContent().findAllByText("Orders").first().click();
+ cy.log("should show a collection browser with collection items");
+ H.getSimpleEmbedIframeContent()
+ .should("contain", "Name")
+ .and("contain", "Last edited by")
+ .findAllByText("Orders")
+ .first()
+ .should("be.visible")
+ .click();
+
+ cy.log("should show question view");
+ H.getSimpleEmbedIframeContent()
+ .findByTestId("query-visualization-root", { timeout: 20_000 })
+ .should("be.visible");
cy.log("should show breadcrumb for the question");
H.getSimpleEmbedIframeContent().should("contain", "Orders");
@@ -337,6 +307,9 @@ describe("scenarios > embedding > sdk iframe embedding > view and curate content
cy.log("should be back at collection browser");
H.getSimpleEmbedIframeContent().should("contain", "Name");
+ H.getSimpleEmbedIframeContent()
+ .findByTestId("query-visualization-root")
+ .should("not.exist");
});
});
});