From acd7c31f22e40f3e36ad8ef81aed74305985bd3e Mon Sep 17 00:00:00 2001 From: Ryan Laurie <30528226+iethree@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:20:25 -0600 Subject: [PATCH] Combine embedding e2e specs (#43843) --- .../embedding-downloads-questions.cy.spec.js | 141 --- .../embedding/embedding-questions.cy.spec.js | 133 +++ .../embedding-reproductions.cy.spec.js | 814 ++++++++++++++++++ ...ocked-filters-same-source-table.cy.spec.js | 179 ---- ...8-dashboard-filter-single-value.cy.spec.js | 108 --- ...parameters-in-embedded-question.cy.spec.js | 69 -- ...0845-25031-locked-numeric-param.cy.spec.js | 157 ---- .../30535-session-sandboxing.cy.spec.js | 63 -- ...-embed-preview-parameter-values.cy.spec.js | 233 ----- ...-when-embedding-long-dashboards.cy.spec.js | 58 -- 10 files changed, 947 insertions(+), 1008 deletions(-) delete mode 100644 e2e/test/scenarios/embedding/embedding-downloads-questions.cy.spec.js create mode 100644 e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.js delete mode 100644 e2e/test/scenarios/embedding/reproductions/15860-locked-filters-same-source-table.cy.spec.js delete mode 100644 e2e/test/scenarios/embedding/reproductions/20438-dashboard-filter-single-value.cy.spec.js delete mode 100644 e2e/test/scenarios/embedding/reproductions/20634-locked-parameters-in-embedded-question.cy.spec.js delete mode 100644 e2e/test/scenarios/embedding/reproductions/20845-25031-locked-numeric-param.cy.spec.js delete mode 100644 e2e/test/scenarios/embedding/reproductions/30535-session-sandboxing.cy.spec.js delete mode 100644 e2e/test/scenarios/embedding/reproductions/37914-41635-embed-preview-parameter-values.cy.spec.js delete mode 100644 e2e/test/scenarios/embedding/reproductions/40660-overflow-when-embedding-long-dashboards.cy.spec.js diff --git a/e2e/test/scenarios/embedding/embedding-downloads-questions.cy.spec.js b/e2e/test/scenarios/embedding/embedding-downloads-questions.cy.spec.js deleted file mode 100644 index b7e433f8fe1..00000000000 --- a/e2e/test/scenarios/embedding/embedding-downloads-questions.cy.spec.js +++ /dev/null @@ -1,141 +0,0 @@ -import { - describeEE, - filterWidget, - openStaticEmbeddingModal, - popover, - restore, - setTokenFeatures, - visitEmbeddedPage, - visitIframe, - visitQuestion, -} from "e2e/support/helpers"; - -const questionDetails = { - name: "Simple SQL Query for Embedding", - native: { - query: "select {{text}} as WYSIWYG", - "template-tags": { - text: { - id: "fake-uuid", - name: "text", - "display-name": "Text", - type: "text", - default: null, - }, - }, - }, -}; - -describeEE("scenarios > embedding > questions > downloads", () => { - beforeEach(() => { - cy.intercept("PUT", "/api/card/*").as("publishChanges"); - cy.intercept("GET", "/api/embed/card/**/query").as("dl"); - - restore(); - cy.signInAsAdmin(); - - cy.createNativeQuestion(questionDetails, { - wrapId: true, - }); - }); - - context("without token", () => { - it("should not be possible to disable downloads", () => { - cy.get("@questionId").then(questionId => { - visitQuestion(questionId); - - openStaticEmbeddingModal({ activeTab: "appearance" }); - - cy.log( - "Embedding settings page should not show option to disable downloads", - ); - cy.findByLabelText("Playing with appearance options") - .should("not.contain", "Download data") - .and("not.contain", "Enable users to download data from this embed"); - - cy.log('Use API to "publish" this question and to enable its filter'); - cy.request("PUT", `/api/card/${questionId}`, { - enable_embedding: true, - embedding_params: { - text: "enabled", - }, - }); - - const payload = { - resource: { question: questionId }, - params: {}, - }; - - cy.log( - "Visit embedded question and set its filter through query parameters", - ); - visitEmbeddedPage(payload, { - setFilters: { text: "Foo" }, - }); - - cy.get("[data-testid=cell-data]").should("have.text", "Foo"); - cy.findByRole("contentinfo").icon("download").click(); - - popover().within(() => { - cy.findByText("Download full results"); - cy.findByText(".csv"); - cy.findByText(".xlsx"); - cy.findByText(".json"); - }); - - cy.log( - "Trying to prevent downloads via query params doesn't have any effect", - ); - cy.url().then(url => { - cy.visit(url + "&hide_download_button=true"); - }); - - cy.get("[data-testid=cell-data]").should("have.text", "Foo"); - cy.findByRole("contentinfo").icon("download"); - }); - }); - }); - - context("premium token with paid features", () => { - beforeEach(() => setTokenFeatures("all")); - - it("should be possible to disable downloads", () => { - cy.get("@questionId").then(questionId => { - visitQuestion(questionId); - - openStaticEmbeddingModal({ - activeTab: "appearance", - acceptTerms: false, - }); - - cy.log("Disable downloads"); - cy.findByLabelText("Download data") - .as("allow-download-toggle") - .should("be.checked"); - - cy.findByText("Enable users to download data from this embed").click(); - cy.get("@allow-download-toggle").should("not.be.checked"); - - cy.log('Use API to "publish" this question and to enable its filter'); - cy.request("PUT", `/api/card/${questionId}`, { - enable_embedding: true, - embedding_params: { - text: "enabled", - }, - }); - - visitIframe(); - - filterWidget().type("Foo{enter}"); - cy.get("[data-testid=cell-data]").should("have.text", "Foo"); - - cy.location("search").should("eq", "?text=Foo"); - cy.location("hash").should("match", /&hide_download_button=true$/); - - cy.log("We don't even show the footer if it's empty"); - cy.findByRole("contentinfo").should("not.exist"); - cy.icon("download").should("not.exist"); - }); - }); - }); -}); diff --git a/e2e/test/scenarios/embedding/embedding-questions.cy.spec.js b/e2e/test/scenarios/embedding/embedding-questions.cy.spec.js index aa7b6c7193d..290ee728c2c 100644 --- a/e2e/test/scenarios/embedding/embedding-questions.cy.spec.js +++ b/e2e/test/scenarios/embedding/embedding-questions.cy.spec.js @@ -9,6 +9,10 @@ import { echartsContainer, cartesianChartCircle, testPairedTooltipValues, + describeEE, + filterWidget, + visitEmbeddedPage, + setTokenFeatures, } from "e2e/support/helpers"; import { @@ -225,3 +229,132 @@ function assertOnXYAxisLabels({ xLabel, yLabel } = {}) { echartsContainer().get("text").contains(yLabel); } + +describeEE("scenarios > embedding > questions > downloads", () => { + const questionDetails = { + name: "Simple SQL Query for Embedding", + native: { + query: "select {{text}} as WYSIWYG", + "template-tags": { + text: { + id: "fake-uuid", + name: "text", + "display-name": "Text", + type: "text", + default: null, + }, + }, + }, + }; + beforeEach(() => { + cy.intercept("PUT", "/api/card/*").as("publishChanges"); + cy.intercept("GET", "/api/embed/card/**/query").as("dl"); + + restore(); + cy.signInAsAdmin(); + + cy.createNativeQuestion(questionDetails, { + wrapId: true, + }); + }); + + context("without token", () => { + it("should not be possible to disable downloads", () => { + cy.get("@questionId").then(questionId => { + visitQuestion(questionId); + + openStaticEmbeddingModal({ activeTab: "appearance" }); + + cy.log( + "Embedding settings page should not show option to disable downloads", + ); + cy.findByLabelText("Playing with appearance options") + .should("not.contain", "Download data") + .and("not.contain", "Enable users to download data from this embed"); + + cy.log('Use API to "publish" this question and to enable its filter'); + cy.request("PUT", `/api/card/${questionId}`, { + enable_embedding: true, + embedding_params: { + text: "enabled", + }, + }); + + const payload = { + resource: { question: questionId }, + params: {}, + }; + + cy.log( + "Visit embedded question and set its filter through query parameters", + ); + visitEmbeddedPage(payload, { + setFilters: { text: "Foo" }, + }); + + cy.get("[data-testid=cell-data]").should("have.text", "Foo"); + cy.findByRole("contentinfo").icon("download").click(); + + popover().within(() => { + cy.findByText("Download full results"); + cy.findByText(".csv"); + cy.findByText(".xlsx"); + cy.findByText(".json"); + }); + + cy.log( + "Trying to prevent downloads via query params doesn't have any effect", + ); + cy.url().then(url => { + cy.visit(url + "&hide_download_button=true"); + }); + + cy.get("[data-testid=cell-data]").should("have.text", "Foo"); + cy.findByRole("contentinfo").icon("download"); + }); + }); + }); + + context("premium token with paid features", () => { + beforeEach(() => setTokenFeatures("all")); + + it("should be possible to disable downloads", () => { + cy.get("@questionId").then(questionId => { + visitQuestion(questionId); + + openStaticEmbeddingModal({ + activeTab: "appearance", + acceptTerms: false, + }); + + cy.log("Disable downloads"); + cy.findByLabelText("Download data") + .as("allow-download-toggle") + .should("be.checked"); + + cy.findByText("Enable users to download data from this embed").click(); + cy.get("@allow-download-toggle").should("not.be.checked"); + + cy.log('Use API to "publish" this question and to enable its filter'); + cy.request("PUT", `/api/card/${questionId}`, { + enable_embedding: true, + embedding_params: { + text: "enabled", + }, + }); + + visitIframe(); + + filterWidget().type("Foo{enter}"); + cy.get("[data-testid=cell-data]").should("have.text", "Foo"); + + cy.location("search").should("eq", "?text=Foo"); + cy.location("hash").should("match", /&hide_download_button=true$/); + + cy.log("We don't even show the footer if it's empty"); + cy.findByRole("contentinfo").should("not.exist"); + cy.icon("download").should("not.exist"); + }); + }); + }); +}); diff --git a/e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.js b/e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.js new file mode 100644 index 00000000000..15d4f100259 --- /dev/null +++ b/e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.js @@ -0,0 +1,814 @@ +import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database"; +import { + restore, + popover, + visitDashboard, + visitIframe, + updateDashboardCards, + openStaticEmbeddingModal, + filterWidget, + modal, + visitEmbeddedPage, + visitQuestion, + setTokenFeatures, + getIframeBody, + addOrUpdateDashboardCard, + describeEE, +} from "e2e/support/helpers"; + +const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE; + +describe.skip("issue 15860", () => { + const q1IdFilter = { + name: "Q1 ID", + slug: "q1_id", + id: "fde6db8b", + type: "id", + sectionId: "id", + default: [1], + }; + + const q1CategoryFilter = { + name: "Q1 Category", + slug: "q1_category", + id: "e8ff3175", + type: "string/=", + sectionId: "string", + filteringParameters: [q1IdFilter.id], + }; + + const q2IdFilter = { + name: "Q2 ID", + slug: "q2_id", + id: "t3e6hb7b", + type: "id", + sectionId: "id", + default: [3], + }; + + const q2CategoryFilter = { + name: "Q2 Category", + slug: "q2_category", + id: "ca1n357o", + type: "string/=", + sectionId: "string", + filteringParameters: [q2IdFilter.id], + }; + + function setDefaultValueForLockedFilter(filter, value) { + cy.findByText("Previewing locked parameters") + .parent() + .within(() => { + cy.findByText(filter).click({ force: true }); + }); + + cy.findByPlaceholderText("Enter an ID").type(`${value}{enter}`); + cy.button("Add filter").click(); + } + + beforeEach(() => { + restore(); + cy.signInAsAdmin(); + + cy.createQuestionAndDashboard({ + questionDetails: { + name: "Q1", + query: { "source-table": PRODUCTS_ID }, + }, + dashboardDetails: { + embedding_params: { + q1_id: "locked", + q1_category: "enabled", + q2_id: "locked", + q2_category: "enabled", + }, + enable_embedding: true, + parameters: [ + q1IdFilter, + q1CategoryFilter, + q2IdFilter, + q2CategoryFilter, + ], + }, + cardDetails: { + size_x: 11, + size_y: 6, + }, + }).then(({ body: { card_id: q1, dashboard_id } }) => { + // Create a second question with the same source table + cy.createQuestion({ + name: "Q2", + query: { "source-table": PRODUCTS_ID }, + }).then(({ body: { id: q2 } }) => { + updateDashboardCards({ + dashboard_id, + cards: [ + // Add card for second question with parameter mappings + { + card_id: q2, + row: 0, + col: 8, + size_x: 13, + size_y: 6, + parameter_mappings: [ + { + parameter_id: q2IdFilter.id, + card_id: q2, + target: ["dimension", ["field", PRODUCTS.ID, null]], + }, + { + parameter_id: q2CategoryFilter.id, + card_id: q2, + target: ["dimension", ["field", PRODUCTS.CATEGORY, null]], + }, + ], + }, + // Add parameter mappings to first question's card + { + card_id: q1, + parameter_mappings: [ + { + parameter_id: q1IdFilter.id, + card_id: q1, + target: ["dimension", ["field", PRODUCTS.ID, null]], + }, + { + parameter_id: q1CategoryFilter.id, + card_id: q1, + target: ["dimension", ["field", PRODUCTS.CATEGORY, null]], + }, + ], + }, + ], + }); + }); + + cy.request("PUT", `/api/dashboard/${dashboard_id}`, { + embedding_params: { + q1_id: "locked", + q1_category: "enabled", + q2_id: "locked", + q2_category: "enabled", + }, + enable_embedding: true, + }); + + visitDashboard(dashboard_id); + }); + }); + + it("should work for locked linked filters connected to different cards with the same source table (metabase#15860)", () => { + cy.icon("share").click(); + // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage + cy.findByText("Embed in your application").click(); + + setDefaultValueForLockedFilter("Q1 ID", 1); + setDefaultValueForLockedFilter("Q2 ID", 3); + + visitIframe(); + + // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage + cy.findByText("Q1 Category").click(); + + popover().within(() => { + cy.findByRole("listitem") + .should("have.length", 1) + .and("contain", "Gizmo"); + }); + + // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage + cy.findByText("Q2 Category").click(); + + popover().within(() => { + cy.findByRole("listitem") + .should("have.length", 1) + .and("contain", "Doohickey"); + }); + }); +}); + +describe("issue 20438", () => { + const questionDetails = { + name: "20438", + native: { + query: + "SELECT * FROM PRODUCTS\nWHERE true\n [[AND {{CATEGORY}}]]\n limit 30", + "template-tags": { + CATEGORY: { + id: "24f69111-29f8-135f-9321-1ff94bbb31ad", + name: "CATEGORY", + "display-name": "Category", + type: "dimension", + dimension: ["field", PRODUCTS.CATEGORY, null], + "widget-type": "string/=", + default: null, + }, + }, + }, + }; + + const filter = { + name: "Text", + slug: "text", + id: "b555d25b", + type: "string/=", + sectionId: "string", + }; + + const dashboardDetails = { + parameters: [filter], + }; + + beforeEach(() => { + cy.intercept("GET", "/api/embed/dashboard/**").as("getEmbed"); + + restore(); + cy.signInAsAdmin(); + + cy.createNativeQuestionAndDashboard({ + questionDetails, + dashboardDetails, + }).then(({ body: { id, card_id, dashboard_id } }) => { + // Connect filter to the card + cy.request("PUT", `/api/dashboard/${dashboard_id}`, { + dashcards: [ + { + id, + card_id, + row: 0, + col: 0, + size_x: 24, + size_y: 8, + parameter_mappings: [ + { + parameter_id: filter.id, + card_id, + target: ["dimension", ["template-tag", "CATEGORY"]], + }, + ], + }, + ], + }); + + // Enable embedding and enable the "Text" filter + cy.request("PUT", `/api/dashboard/${dashboard_id}`, { + enable_embedding: true, + embedding_params: { [filter.slug]: "enabled" }, + }); + + visitDashboard(dashboard_id); + }); + }); + + it("dashboard filter connected to the field filter should work with a single value in embedded dashboards (metabase#20438)", () => { + openStaticEmbeddingModal({ activeTab: "parameters" }); + + visitIframe(); + + cy.wait("@getEmbed"); + + filterWidget().click(); + cy.wait("@getEmbed"); + + popover().contains("Doohickey").click(); + cy.wait("@getEmbed"); + + cy.button("Add filter").click(); + cy.wait("@getEmbed"); + + cy.findAllByTestId("cell-data") + // One of product titles for Doohickey + .should("contain", "Small Marble Shoes") + // One of product titles for Gizmo + .and("not.contain", "Rustic Paper Wallet"); + }); +}); + +describe("locked parameters in embedded question (metabase#20634)", () => { + beforeEach(() => { + cy.intercept("PUT", "/api/card/*").as("publishChanges"); + + restore(); + cy.signInAsAdmin(); + + cy.createNativeQuestion( + { + name: "20634", + native: { + query: "select {{text}}", + "template-tags": { + text: { + id: "abc-123", + name: "text", + "display-name": "Text", + type: "text", + default: null, + }, + }, + }, + }, + { visitQuestion: true }, + ); + }); + + it("should let the user lock parameters to specific values", () => { + openStaticEmbeddingModal({ activeTab: "parameters" }); + + modal().within(() => { + // select the dropdown next to the Text parameter so that we can set the value to "Locked" + cy.findByText("Text") + .parent() + .within(() => { + cy.findByText("Disabled").click(); + }); + }); + + // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage + cy.findByText("Locked").click(); + + modal().within(() => { + // set a parameter value + cy.findByPlaceholderText("Text").type("foo{enter}"); + + // publish the embedded question so that we can directly navigate to its url + cy.findByText("Publish").click(); + cy.wait("@publishChanges"); + }); + + // directly navigate to the embedded question + visitIframe(); + + // verify that the Text parameter doesn't show up but that its value is reflected in the dashcard + // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage + cy.findByText("Text").should("not.exist"); + cy.get(".CardVisualization").within(() => { + cy.contains("foo"); + }); + }); +}); + +describe("issues 20845, 25031", () => { + /** + * @param {string} defaultValue - The default value for the defined filter + * @returns object + */ + function getQuestionDetails(defaultValue = undefined) { + return { + name: "20845", + native: { + "template-tags": { + qty_locked: { + id: "6bd8d7be-bd5b-382c-cfa2-683461891663", + name: "qty_locked", + "display-name": "Qty locked", + type: "number", + required: defaultValue ? true : false, + default: defaultValue, + }, + }, + query: + "select count(*) from orders where true [[AND quantity={{qty_locked}}]]", + }, + }; + } + const defaultFilterValues = [undefined, "10"]; + defaultFilterValues.forEach(value => { + const conditionalPartOfTestTitle = value + ? "and the required filter with the default value" + : ""; + const dashboardFilter = { + name: "Equal to", + slug: "equal_to", + id: "c269ebe1", + type: "number/=", + sectionId: "number", + }; + + const dashboardDetails = { + name: "25031", + parameters: [dashboardFilter], + }; + beforeEach(() => { + cy.intercept("PUT", "/api/card/*").as("publishChanges"); + + restore(); + cy.signInAsAdmin(); + + const questionDetails = getQuestionDetails(value); + + cy.createNativeQuestionAndDashboard({ + questionDetails, + dashboardDetails, + }).then(({ body: { id, dashboard_id, card_id } }) => { + cy.wrap(card_id).as("questionId"); + cy.wrap(dashboard_id).as("dashboardId"); + + visitQuestion(card_id); + + // Connect dashbaord filter to the card + cy.request("PUT", `/api/dashboard/${dashboard_id}`, { + dashcards: [ + { + card_id, + id, + row: 0, + col: 0, + size_x: 16, + size_y: 10, + parameter_mappings: [ + { + parameter_id: dashboardFilter.id, + card_id, + target: ["variable", ["template-tag", "qty_locked"]], + }, + ], + }, + ], + }); + }); + }); + + it(`QUESTION: locked parameter should work with numeric values ${conditionalPartOfTestTitle} (metabase#20845)`, () => { + cy.get("@questionId").then(questionId => { + cy.request("PUT", `/api/card/${questionId}`, { + enable_embedding: true, + embedding_params: { + qty_locked: "locked", + }, + }); + + // This issue is not possible to reproduce using UI from this point on. + // We have to manually send the payload in order to make sure it works for both strings and integers. + ["string", "integer"].forEach(type => { + cy.log( + `Make sure it works with ${type.toUpperCase()} in the payload`, + ); + + visitEmbeddedPage({ + resource: { question: questionId }, + params: { + qty_locked: type === "string" ? "15" : 15, // IMPORTANT: integer + }, + }); + }); + + cy.findByTestId("column-header").should("contain", "COUNT(*)"); + cy.findByTestId("cell-data").should("contain", "5"); + }); + }); + + it(`DASHBOARD: locked parameter should work with numeric values ${conditionalPartOfTestTitle} (metabase#25031)`, () => { + cy.get("@dashboardId").then(dashboardId => { + visitDashboard(dashboardId); + cy.request("PUT", `/api/dashboard/${dashboardId}`, { + enable_embedding: true, + embedding_params: { + [dashboardFilter.slug]: "locked", + }, + }); + + // This issue is not possible to reproduce using UI from this point on. + // We have to manually send the payload in order to make sure it works for both strings and integers. + ["string", "integer"].forEach(type => { + cy.log( + `Make sure it works with ${type.toUpperCase()} in the payload`, + ); + + const payload = { + resource: { dashboard: dashboardId }, + params: { + [dashboardFilter.slug]: type === "string" ? "15" : 15, // IMPORTANT: integer + }, + }; + + visitEmbeddedPage(payload); + + // wait for the results to load + cy.contains(dashboardDetails.name); + cy.get(".CardVisualization") + .should("contain", "COUNT(*)") + .and("contain", "5"); + }); + }); + }); + }); +}); + +describeEE("issue 30535", () => { + const questionDetails = { + name: "3035", + query: { + "source-table": PRODUCTS_ID, + limit: 10, + }, + }; + beforeEach(() => { + restore(); + cy.signInAsAdmin(); + setTokenFeatures("all"); + + cy.sandboxTable({ + table_id: PRODUCTS_ID, + attribute_remappings: { + attr_cat: ["dimension", ["field", PRODUCTS.CATEGORY, null]], + }, + }); + + cy.createQuestion(questionDetails).then(({ body: { id } }) => { + cy.request("PUT", `/api/card/${id}`, { enable_embedding: true }); + + visitQuestion(id); + }); + }); + + it("user session should not apply sandboxing to a signed embedded question (metabase#30535)", () => { + openStaticEmbeddingModal({ + activeTab: "parameters", + previewMode: "preview", + acceptTerms: false, + }); + + cy.document().then(doc => { + const iframe = doc.querySelector("iframe"); + + cy.signOut(); + cy.signInAsSandboxedUser(); + + cy.visit(iframe.src); + }); + + cy.findByRole("table").within(() => { + // The sandboxed user has an attribute cat="Widget" + cy.findAllByText("Widget"); + // Sandboxing shouldn't affect results so we should see other product categories as well + cy.findAllByText("Gizmo"); + }); + }); +}); + +describe("dashboard preview", () => { + const questionDetails = { + name: "Products", + query: { "source-table": PRODUCTS_ID }, + }; + + const filter3 = { + name: "Text 2", + slug: "text_2", + id: "b0665b6a", + type: "string/=", + sectionId: "string", + }; + + const filter2 = { + name: "Text 1", + slug: "text_1", + id: "d4c9f2e5", + type: "string/=", + sectionId: "string", + }; + + const filter = { + filteringParameters: [filter2.id], + name: "Text", + slug: "text", + id: "d1b69627", + type: "string/=", + sectionId: "string", + }; + beforeEach(() => { + cy.intercept("GET", "/api/preview_embed/dashboard/**").as( + "previewDashboard", + ); + cy.intercept("GET", "/api/preview_embed/dashboard/**/params/**/values").as( + "previewValues", + ); + + restore(); + cy.signInAsAdmin(); + }); + + it("dashboard linked filters values don't work in static embed preview (metabase#37914)", () => { + const dashboardDetails = { + parameters: [filter, filter2, filter3], + enable_embedding: true, + embedding_params: { + [filter.slug]: "enabled", + [filter2.slug]: "enabled", + [filter3.slug]: "enabled", + }, + }; + cy.createQuestionAndDashboard({ + questionDetails, + dashboardDetails, + }).then(({ body: { card_id, dashboard_id } }) => { + addOrUpdateDashboardCard({ + dashboard_id, + card_id, + card: { + parameter_mappings: [ + { + card_id, + parameter_id: filter.id, + target: [ + "dimension", + ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], + ], + }, + { + card_id, + parameter_id: filter2.id, + target: [ + "dimension", + ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], + ], + }, + { + card_id, + parameter_id: filter3.id, + target: [ + "dimension", + ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], + ], + }, + ], + }, + }); + + visitDashboard(dashboard_id); + }); + + openStaticEmbeddingModal({ + activeTab: "parameters", + previewMode: "preview", + }); + + modal().within(() => { + // Makes it less likely to flake. + cy.wait("@previewDashboard"); + + getIframeBody().within(() => { + cy.log( + "Set filter 2 value, so filter 1 should be filtered by filter 2", + ); + cy.button(filter2.name).click(); + cy.wait("@previewValues"); + popover().within(() => { + cy.findByText("Gadget").should("be.visible"); + cy.findByText("Gizmo").should("be.visible"); + cy.findByText("Widget").should("be.visible"); + cy.findByText("Doohickey").click(); + cy.button("Add filter").click(); + }); + + cy.log("Assert filter 1"); + cy.button(filter.name).click(); + popover().within(() => { + cy.findByText("Gadget").should("not.exist"); + cy.findByText("Gizmo").should("not.exist"); + cy.findByText("Widget").should("not.exist"); + cy.findByText("Doohickey").should("be.visible"); + }); + }); + }); + }); + + it("dashboard linked filters values in embed preview don't behave like embedding (metabase#41635)", () => { + const dashboardDetails = { + parameters: [filter, filter2, filter3], + enable_embedding: true, + embedding_params: { + [filter.slug]: "enabled", + [filter2.slug]: "locked", + [filter3.slug]: "locked", + }, + }; + cy.createQuestionAndDashboard({ + questionDetails, + dashboardDetails, + }).then(({ body: { card_id, dashboard_id } }) => { + addOrUpdateDashboardCard({ + dashboard_id, + card_id, + card: { + parameter_mappings: [ + { + card_id, + parameter_id: filter.id, + target: [ + "dimension", + ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], + ], + }, + { + card_id, + parameter_id: filter2.id, + target: [ + "dimension", + ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], + ], + }, + { + card_id, + parameter_id: filter3.id, + target: [ + "dimension", + ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], + ], + }, + ], + }, + }); + + visitDashboard(dashboard_id); + }); + + openStaticEmbeddingModal({ + activeTab: "parameters", + previewMode: "preview", + }); + + // Makes it less likely to flake. + cy.wait("@previewDashboard"); + + cy.log("Set the first locked parameter values"); + modal() + .findByRole("generic", { name: "Previewing locked parameters" }) + .findByText("Text 1") + .click(); + popover().within(() => { + cy.findByText("Doohickey").click(); + cy.button("Add filter").click(); + }); + + cy.log("Set the second locked parameter values"); + modal() + .findByRole("generic", { name: "Previewing locked parameters" }) + .findByText("Text 2") + .click(); + popover().within(() => { + cy.findByText("Doohickey").click(); + cy.findByText("Gizmo").click(); + cy.findByText("Gadget").click(); + cy.button("Add filter").click(); + }); + + getIframeBody().within(() => { + cy.log("Assert filter 1"); + cy.button(filter.name).click(); + popover().within(() => { + cy.findByText("Gadget").should("not.exist"); + cy.findByText("Gizmo").should("not.exist"); + cy.findByText("Widget").should("not.exist"); + cy.findByText("Doohickey").should("be.visible"); + }); + }); + }); +}); + +describe("issue 40660", () => { + const questionDetails = { + name: "Products", + query: { "source-table": PRODUCTS_ID, limit: 2 }, + }; + + const dashboardDetails = { + name: "long dashboard", + enable_embedding: true, + }; + beforeEach(() => { + cy.intercept("GET", "/api/preview_embed/dashboard/**").as( + "previewDashboard", + ); + + restore(); + cy.signInAsAdmin(); + + cy.createQuestionAndDashboard({ + questionDetails, + dashboardDetails, + }).then(({ body: { id, card_id, dashboard_id } }) => { + updateDashboardCards({ + dashboard_id, + cards: [{ card_id }, { card_id }, { card_id }], + }); + + visitDashboard(dashboard_id); + }); + }); + + it("static dashboard content shouldn't overflow its container (metabase#40660)", () => { + openStaticEmbeddingModal({ + activeTab: "parameters", + previewMode: "preview", + }); + + getIframeBody().within(() => { + cy.findByTestId("embed-frame").scrollTo("bottom"); + + cy.findByRole("link", { name: "Powered by Metabase" }).should( + "be.visible", + ); + }); + }); +}); diff --git a/e2e/test/scenarios/embedding/reproductions/15860-locked-filters-same-source-table.cy.spec.js b/e2e/test/scenarios/embedding/reproductions/15860-locked-filters-same-source-table.cy.spec.js deleted file mode 100644 index 17f3f09b7d1..00000000000 --- a/e2e/test/scenarios/embedding/reproductions/15860-locked-filters-same-source-table.cy.spec.js +++ /dev/null @@ -1,179 +0,0 @@ -import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database"; -import { - restore, - popover, - visitDashboard, - visitIframe, - updateDashboardCards, -} from "e2e/support/helpers"; - -const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE; - -const q1IdFilter = { - name: "Q1 ID", - slug: "q1_id", - id: "fde6db8b", - type: "id", - sectionId: "id", - default: [1], -}; - -const q1CategoryFilter = { - name: "Q1 Category", - slug: "q1_category", - id: "e8ff3175", - type: "string/=", - sectionId: "string", - filteringParameters: [q1IdFilter.id], -}; - -const q2IdFilter = { - name: "Q2 ID", - slug: "q2_id", - id: "t3e6hb7b", - type: "id", - sectionId: "id", - default: [3], -}; - -const q2CategoryFilter = { - name: "Q2 Category", - slug: "q2_category", - id: "ca1n357o", - type: "string/=", - sectionId: "string", - filteringParameters: [q2IdFilter.id], -}; - -describe.skip("issue 15860", () => { - beforeEach(() => { - restore(); - cy.signInAsAdmin(); - - cy.createQuestionAndDashboard({ - questionDetails: { - name: "Q1", - query: { "source-table": PRODUCTS_ID }, - }, - dashboardDetails: { - embedding_params: { - q1_id: "locked", - q1_category: "enabled", - q2_id: "locked", - q2_category: "enabled", - }, - enable_embedding: true, - parameters: [ - q1IdFilter, - q1CategoryFilter, - q2IdFilter, - q2CategoryFilter, - ], - }, - cardDetails: { - size_x: 11, - size_y: 6, - }, - }).then(({ body: { card_id: q1, dashboard_id } }) => { - // Create a second question with the same source table - cy.createQuestion({ - name: "Q2", - query: { "source-table": PRODUCTS_ID }, - }).then(({ body: { id: q2 } }) => { - updateDashboardCards({ - dashboard_id, - cards: [ - // Add card for second question with parameter mappings - { - card_id: q2, - row: 0, - col: 8, - size_x: 13, - size_y: 6, - parameter_mappings: [ - { - parameter_id: q2IdFilter.id, - card_id: q2, - target: ["dimension", ["field", PRODUCTS.ID, null]], - }, - { - parameter_id: q2CategoryFilter.id, - card_id: q2, - target: ["dimension", ["field", PRODUCTS.CATEGORY, null]], - }, - ], - }, - // Add parameter mappings to first question's card - { - card_id: q1, - parameter_mappings: [ - { - parameter_id: q1IdFilter.id, - card_id: q1, - target: ["dimension", ["field", PRODUCTS.ID, null]], - }, - { - parameter_id: q1CategoryFilter.id, - card_id: q1, - target: ["dimension", ["field", PRODUCTS.CATEGORY, null]], - }, - ], - }, - ], - }); - }); - - cy.request("PUT", `/api/dashboard/${dashboard_id}`, { - embedding_params: { - q1_id: "locked", - q1_category: "enabled", - q2_id: "locked", - q2_category: "enabled", - }, - enable_embedding: true, - }); - - visitDashboard(dashboard_id); - }); - }); - - it("should work for locked linked filters connected to different cards with the same source table (metabase#15860)", () => { - cy.icon("share").click(); - // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage - cy.findByText("Embed in your application").click(); - - setDefaultValueForLockedFilter("Q1 ID", 1); - setDefaultValueForLockedFilter("Q2 ID", 3); - - visitIframe(); - - // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage - cy.findByText("Q1 Category").click(); - - popover().within(() => { - cy.findByRole("listitem") - .should("have.length", 1) - .and("contain", "Gizmo"); - }); - - // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage - cy.findByText("Q2 Category").click(); - - popover().within(() => { - cy.findByRole("listitem") - .should("have.length", 1) - .and("contain", "Doohickey"); - }); - }); -}); - -function setDefaultValueForLockedFilter(filter, value) { - cy.findByText("Previewing locked parameters") - .parent() - .within(() => { - cy.findByText(filter).click({ force: true }); - }); - - cy.findByPlaceholderText("Enter an ID").type(`${value}{enter}`); - cy.button("Add filter").click(); -} diff --git a/e2e/test/scenarios/embedding/reproductions/20438-dashboard-filter-single-value.cy.spec.js b/e2e/test/scenarios/embedding/reproductions/20438-dashboard-filter-single-value.cy.spec.js deleted file mode 100644 index c86a3dd85ec..00000000000 --- a/e2e/test/scenarios/embedding/reproductions/20438-dashboard-filter-single-value.cy.spec.js +++ /dev/null @@ -1,108 +0,0 @@ -import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database"; -import { - restore, - filterWidget, - popover, - visitDashboard, - visitIframe, - openStaticEmbeddingModal, -} from "e2e/support/helpers"; - -const { PRODUCTS } = SAMPLE_DATABASE; - -const questionDetails = { - name: "20438", - native: { - query: - "SELECT * FROM PRODUCTS\nWHERE true\n [[AND {{CATEGORY}}]]\n limit 30", - "template-tags": { - CATEGORY: { - id: "24f69111-29f8-135f-9321-1ff94bbb31ad", - name: "CATEGORY", - "display-name": "Category", - type: "dimension", - dimension: ["field", PRODUCTS.CATEGORY, null], - "widget-type": "string/=", - default: null, - }, - }, - }, -}; - -const filter = { - name: "Text", - slug: "text", - id: "b555d25b", - type: "string/=", - sectionId: "string", -}; - -const dashboardDetails = { - parameters: [filter], -}; - -describe("issue 20438", () => { - beforeEach(() => { - cy.intercept("GET", "/api/embed/dashboard/**").as("getEmbed"); - - restore(); - cy.signInAsAdmin(); - - cy.createNativeQuestionAndDashboard({ - questionDetails, - dashboardDetails, - }).then(({ body: { id, card_id, dashboard_id } }) => { - // Connect filter to the card - cy.request("PUT", `/api/dashboard/${dashboard_id}`, { - dashcards: [ - { - id, - card_id, - row: 0, - col: 0, - size_x: 24, - size_y: 8, - parameter_mappings: [ - { - parameter_id: filter.id, - card_id, - target: ["dimension", ["template-tag", "CATEGORY"]], - }, - ], - }, - ], - }); - - // Enable embedding and enable the "Text" filter - cy.request("PUT", `/api/dashboard/${dashboard_id}`, { - enable_embedding: true, - embedding_params: { [filter.slug]: "enabled" }, - }); - - visitDashboard(dashboard_id); - }); - }); - - it("dashboard filter connected to the field filter should work with a single value in embedded dashboards (metabase#20438)", () => { - openStaticEmbeddingModal({ activeTab: "parameters" }); - - visitIframe(); - - cy.wait("@getEmbed"); - - filterWidget().click(); - cy.wait("@getEmbed"); - - popover().contains("Doohickey").click(); - cy.wait("@getEmbed"); - - cy.button("Add filter").click(); - cy.wait("@getEmbed"); - - cy.findAllByTestId("cell-data") - // One of product titles for Doohickey - .should("contain", "Small Marble Shoes") - // One of product titles for Gizmo - .and("not.contain", "Rustic Paper Wallet"); - }); -}); diff --git a/e2e/test/scenarios/embedding/reproductions/20634-locked-parameters-in-embedded-question.cy.spec.js b/e2e/test/scenarios/embedding/reproductions/20634-locked-parameters-in-embedded-question.cy.spec.js deleted file mode 100644 index 8f97e12e07c..00000000000 --- a/e2e/test/scenarios/embedding/reproductions/20634-locked-parameters-in-embedded-question.cy.spec.js +++ /dev/null @@ -1,69 +0,0 @@ -import { - modal, - openStaticEmbeddingModal, - restore, - visitIframe, -} from "e2e/support/helpers"; - -describe("locked parameters in embedded question (metabase#20634)", () => { - beforeEach(() => { - cy.intercept("PUT", "/api/card/*").as("publishChanges"); - - restore(); - cy.signInAsAdmin(); - - cy.createNativeQuestion( - { - name: "20634", - native: { - query: "select {{text}}", - "template-tags": { - text: { - id: "abc-123", - name: "text", - "display-name": "Text", - type: "text", - default: null, - }, - }, - }, - }, - { visitQuestion: true }, - ); - }); - - it("should let the user lock parameters to specific values", () => { - openStaticEmbeddingModal({ activeTab: "parameters" }); - - modal().within(() => { - // select the dropdown next to the Text parameter so that we can set the value to "Locked" - cy.findByText("Text") - .parent() - .within(() => { - cy.findByText("Disabled").click(); - }); - }); - - // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage - cy.findByText("Locked").click(); - - modal().within(() => { - // set a parameter value - cy.findByPlaceholderText("Text").type("foo{enter}"); - - // publish the embedded question so that we can directly navigate to its url - cy.findByText("Publish").click(); - cy.wait("@publishChanges"); - }); - - // directly navigate to the embedded question - visitIframe(); - - // verify that the Text parameter doesn't show up but that its value is reflected in the dashcard - // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage - cy.findByText("Text").should("not.exist"); - cy.get(".CardVisualization").within(() => { - cy.contains("foo"); - }); - }); -}); diff --git a/e2e/test/scenarios/embedding/reproductions/20845-25031-locked-numeric-param.cy.spec.js b/e2e/test/scenarios/embedding/reproductions/20845-25031-locked-numeric-param.cy.spec.js deleted file mode 100644 index 194678044da..00000000000 --- a/e2e/test/scenarios/embedding/reproductions/20845-25031-locked-numeric-param.cy.spec.js +++ /dev/null @@ -1,157 +0,0 @@ -import { - restore, - visitEmbeddedPage, - visitDashboard, - visitQuestion, -} from "e2e/support/helpers"; - -const dashboardFilter = { - name: "Equal to", - slug: "equal_to", - id: "c269ebe1", - type: "number/=", - sectionId: "number", -}; - -const dashboardDetails = { - name: "25031", - parameters: [dashboardFilter], -}; - -const defaultFilterValues = [undefined, "10"]; - -defaultFilterValues.forEach(value => { - const conditionalPartOfTestTitle = value - ? "and the required filter with the default value" - : ""; - - describe("issues 20845, 25031", () => { - beforeEach(() => { - cy.intercept("PUT", "/api/card/*").as("publishChanges"); - - restore(); - cy.signInAsAdmin(); - - const questionDetails = getQuestionDetails(value); - - cy.createNativeQuestionAndDashboard({ - questionDetails, - dashboardDetails, - }).then(({ body: { id, dashboard_id, card_id } }) => { - cy.wrap(card_id).as("questionId"); - cy.wrap(dashboard_id).as("dashboardId"); - - visitQuestion(card_id); - - // Connect dashbaord filter to the card - cy.request("PUT", `/api/dashboard/${dashboard_id}`, { - dashcards: [ - { - card_id, - id, - row: 0, - col: 0, - size_x: 16, - size_y: 10, - parameter_mappings: [ - { - parameter_id: dashboardFilter.id, - card_id, - target: ["variable", ["template-tag", "qty_locked"]], - }, - ], - }, - ], - }); - }); - }); - - it(`QUESTION: locked parameter should work with numeric values ${conditionalPartOfTestTitle} (metabase#20845)`, () => { - cy.get("@questionId").then(questionId => { - cy.request("PUT", `/api/card/${questionId}`, { - enable_embedding: true, - embedding_params: { - qty_locked: "locked", - }, - }); - - // This issue is not possible to reproduce using UI from this point on. - // We have to manually send the payload in order to make sure it works for both strings and integers. - ["string", "integer"].forEach(type => { - cy.log( - `Make sure it works with ${type.toUpperCase()} in the payload`, - ); - - visitEmbeddedPage({ - resource: { question: questionId }, - params: { - qty_locked: type === "string" ? "15" : 15, // IMPORTANT: integer - }, - }); - }); - - cy.findByTestId("column-header").should("contain", "COUNT(*)"); - cy.findByTestId("cell-data").should("contain", "5"); - }); - }); - - it(`DASHBOARD: locked parameter should work with numeric values ${conditionalPartOfTestTitle} (metabase#25031)`, () => { - cy.get("@dashboardId").then(dashboardId => { - visitDashboard(dashboardId); - cy.request("PUT", `/api/dashboard/${dashboardId}`, { - enable_embedding: true, - embedding_params: { - [dashboardFilter.slug]: "locked", - }, - }); - - // This issue is not possible to reproduce using UI from this point on. - // We have to manually send the payload in order to make sure it works for both strings and integers. - ["string", "integer"].forEach(type => { - cy.log( - `Make sure it works with ${type.toUpperCase()} in the payload`, - ); - - const payload = { - resource: { dashboard: dashboardId }, - params: { - [dashboardFilter.slug]: type === "string" ? "15" : 15, // IMPORTANT: integer - }, - }; - - visitEmbeddedPage(payload); - - // wait for the results to load - cy.contains(dashboardDetails.name); - cy.get(".CardVisualization") - .should("contain", "COUNT(*)") - .and("contain", "5"); - }); - }); - }); - }); -}); - -/** - * @param {string} defaultValue - The default value for the defined filter - * @returns object - */ -function getQuestionDetails(defaultValue = undefined) { - return { - name: "20845", - native: { - "template-tags": { - qty_locked: { - id: "6bd8d7be-bd5b-382c-cfa2-683461891663", - name: "qty_locked", - "display-name": "Qty locked", - type: "number", - required: defaultValue ? true : false, - default: defaultValue, - }, - }, - query: - "select count(*) from orders where true [[AND quantity={{qty_locked}}]]", - }, - }; -} diff --git a/e2e/test/scenarios/embedding/reproductions/30535-session-sandboxing.cy.spec.js b/e2e/test/scenarios/embedding/reproductions/30535-session-sandboxing.cy.spec.js deleted file mode 100644 index 7d77b5abeb7..00000000000 --- a/e2e/test/scenarios/embedding/reproductions/30535-session-sandboxing.cy.spec.js +++ /dev/null @@ -1,63 +0,0 @@ -import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database"; -import { - restore, - visitQuestion, - describeEE, - setTokenFeatures, - openStaticEmbeddingModal, -} from "e2e/support/helpers"; - -const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE; - -const questionDetails = { - name: "3035", - query: { - "source-table": PRODUCTS_ID, - limit: 10, - }, -}; - -describeEE("issue 30535", () => { - beforeEach(() => { - restore(); - cy.signInAsAdmin(); - setTokenFeatures("all"); - - cy.sandboxTable({ - table_id: PRODUCTS_ID, - attribute_remappings: { - attr_cat: ["dimension", ["field", PRODUCTS.CATEGORY, null]], - }, - }); - - cy.createQuestion(questionDetails).then(({ body: { id } }) => { - cy.request("PUT", `/api/card/${id}`, { enable_embedding: true }); - - visitQuestion(id); - }); - }); - - it("user session should not apply sandboxing to a signed embedded question (metabase#30535)", () => { - openStaticEmbeddingModal({ - activeTab: "parameters", - previewMode: "preview", - acceptTerms: false, - }); - - cy.document().then(doc => { - const iframe = doc.querySelector("iframe"); - - cy.signOut(); - cy.signInAsSandboxedUser(); - - cy.visit(iframe.src); - }); - - cy.findByRole("table").within(() => { - // The sandboxed user has an attribute cat="Widget" - cy.findAllByText("Widget"); - // Sandboxing shouldn't affect results so we should see other product categories as well - cy.findAllByText("Gizmo"); - }); - }); -}); diff --git a/e2e/test/scenarios/embedding/reproductions/37914-41635-embed-preview-parameter-values.cy.spec.js b/e2e/test/scenarios/embedding/reproductions/37914-41635-embed-preview-parameter-values.cy.spec.js deleted file mode 100644 index 567ad40eb39..00000000000 --- a/e2e/test/scenarios/embedding/reproductions/37914-41635-embed-preview-parameter-values.cy.spec.js +++ /dev/null @@ -1,233 +0,0 @@ -import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database"; -import { - addOrUpdateDashboardCard, - getIframeBody, - modal, - openStaticEmbeddingModal, - popover, - restore, - visitDashboard, -} from "e2e/support/helpers"; - -const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE; - -const questionDetails = { - name: "Products", - query: { "source-table": PRODUCTS_ID }, -}; - -const filter3 = { - name: "Text 2", - slug: "text_2", - id: "b0665b6a", - type: "string/=", - sectionId: "string", -}; - -const filter2 = { - name: "Text 1", - slug: "text_1", - id: "d4c9f2e5", - type: "string/=", - sectionId: "string", -}; - -const filter = { - filteringParameters: [filter2.id], - name: "Text", - slug: "text", - id: "d1b69627", - type: "string/=", - sectionId: "string", -}; - -describe("dashboard preview", () => { - beforeEach(() => { - cy.intercept("GET", "/api/preview_embed/dashboard/**").as( - "previewDashboard", - ); - cy.intercept("GET", "/api/preview_embed/dashboard/**/params/**/values").as( - "previewValues", - ); - - restore(); - cy.signInAsAdmin(); - }); - - it("dashboard linked filters values don't work in static embed preview (metabase#37914)", () => { - const dashboardDetails = { - parameters: [filter, filter2, filter3], - enable_embedding: true, - embedding_params: { - [filter.slug]: "enabled", - [filter2.slug]: "enabled", - [filter3.slug]: "enabled", - }, - }; - cy.createQuestionAndDashboard({ - questionDetails, - dashboardDetails, - }).then(({ body: { card_id, dashboard_id } }) => { - addOrUpdateDashboardCard({ - dashboard_id, - card_id, - card: { - parameter_mappings: [ - { - card_id, - parameter_id: filter.id, - target: [ - "dimension", - ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], - ], - }, - { - card_id, - parameter_id: filter2.id, - target: [ - "dimension", - ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], - ], - }, - { - card_id, - parameter_id: filter3.id, - target: [ - "dimension", - ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], - ], - }, - ], - }, - }); - - visitDashboard(dashboard_id); - }); - - openStaticEmbeddingModal({ - activeTab: "parameters", - previewMode: "preview", - }); - - modal().within(() => { - // Makes it less likely to flake. - cy.wait("@previewDashboard"); - - getIframeBody().within(() => { - cy.log( - "Set filter 2 value, so filter 1 should be filtered by filter 2", - ); - cy.button(filter2.name).click(); - cy.wait("@previewValues"); - popover().within(() => { - cy.findByText("Gadget").should("be.visible"); - cy.findByText("Gizmo").should("be.visible"); - cy.findByText("Widget").should("be.visible"); - cy.findByText("Doohickey").click(); - cy.button("Add filter").click(); - }); - - cy.log("Assert filter 1"); - cy.button(filter.name).click(); - popover().within(() => { - cy.findByText("Gadget").should("not.exist"); - cy.findByText("Gizmo").should("not.exist"); - cy.findByText("Widget").should("not.exist"); - cy.findByText("Doohickey").should("be.visible"); - }); - }); - }); - }); - - it("dashboard linked filters values in embed preview don't behave like embedding (metabase#41635)", () => { - const dashboardDetails = { - parameters: [filter, filter2, filter3], - enable_embedding: true, - embedding_params: { - [filter.slug]: "enabled", - [filter2.slug]: "locked", - [filter3.slug]: "locked", - }, - }; - cy.createQuestionAndDashboard({ - questionDetails, - dashboardDetails, - }).then(({ body: { card_id, dashboard_id } }) => { - addOrUpdateDashboardCard({ - dashboard_id, - card_id, - card: { - parameter_mappings: [ - { - card_id, - parameter_id: filter.id, - target: [ - "dimension", - ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], - ], - }, - { - card_id, - parameter_id: filter2.id, - target: [ - "dimension", - ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], - ], - }, - { - card_id, - parameter_id: filter3.id, - target: [ - "dimension", - ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }], - ], - }, - ], - }, - }); - - visitDashboard(dashboard_id); - }); - - openStaticEmbeddingModal({ - activeTab: "parameters", - previewMode: "preview", - }); - - // Makes it less likely to flake. - cy.wait("@previewDashboard"); - - cy.log("Set the first locked parameter values"); - modal() - .findByRole("generic", { name: "Previewing locked parameters" }) - .findByText("Text 1") - .click(); - popover().within(() => { - cy.findByText("Doohickey").click(); - cy.button("Add filter").click(); - }); - - cy.log("Set the second locked parameter values"); - modal() - .findByRole("generic", { name: "Previewing locked parameters" }) - .findByText("Text 2") - .click(); - popover().within(() => { - cy.findByText("Doohickey").click(); - cy.findByText("Gizmo").click(); - cy.findByText("Gadget").click(); - cy.button("Add filter").click(); - }); - - getIframeBody().within(() => { - cy.log("Assert filter 1"); - cy.button(filter.name).click(); - popover().within(() => { - cy.findByText("Gadget").should("not.exist"); - cy.findByText("Gizmo").should("not.exist"); - cy.findByText("Widget").should("not.exist"); - cy.findByText("Doohickey").should("be.visible"); - }); - }); - }); -}); diff --git a/e2e/test/scenarios/embedding/reproductions/40660-overflow-when-embedding-long-dashboards.cy.spec.js b/e2e/test/scenarios/embedding/reproductions/40660-overflow-when-embedding-long-dashboards.cy.spec.js deleted file mode 100644 index 2a0c57d7623..00000000000 --- a/e2e/test/scenarios/embedding/reproductions/40660-overflow-when-embedding-long-dashboards.cy.spec.js +++ /dev/null @@ -1,58 +0,0 @@ -import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database"; -import { - getIframeBody, - openStaticEmbeddingModal, - restore, - updateDashboardCards, - visitDashboard, -} from "e2e/support/helpers"; - -const { PRODUCTS_ID } = SAMPLE_DATABASE; - -const questionDetails = { - name: "Products", - query: { "source-table": PRODUCTS_ID, limit: 2 }, -}; - -const dashboardDetails = { - name: "long dashboard", - enable_embedding: true, -}; - -describe("issue 40660", () => { - beforeEach(() => { - cy.intercept("GET", "/api/preview_embed/dashboard/**").as( - "previewDashboard", - ); - - restore(); - cy.signInAsAdmin(); - - cy.createQuestionAndDashboard({ - questionDetails, - dashboardDetails, - }).then(({ body: { id, card_id, dashboard_id } }) => { - updateDashboardCards({ - dashboard_id, - cards: [{ card_id }, { card_id }, { card_id }], - }); - - visitDashboard(dashboard_id); - }); - }); - - it("static dashboard content shouldn't overflow its container (metabase#40660)", () => { - openStaticEmbeddingModal({ - activeTab: "parameters", - previewMode: "preview", - }); - - getIframeBody().within(() => { - cy.findByTestId("embed-frame").scrollTo("bottom"); - - cy.findByRole("link", { name: "Powered by Metabase" }).should( - "be.visible", - ); - }); - }); -}); -- GitLab