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 dashboard drill e2e specs (#84073)
Nemanja Glumacc0b3e4fdfff9
diff --git a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js b/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.jsindex 212a3036782..13d7c889f59 100644--- a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js+++ b/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js@@ -2,7 +2,6 @@ import { assoc } from "icepick";import _ from "underscore";const { H } = cy;-import { SAMPLE_DB_ID, USERS, USER_GROUPS } from "e2e/support/cypress_data";import {ORDERS_DASHBOARD_ID,ORDERS_QUESTION_ID,@@ -15,7 +14,6 @@ import {const { SAMPLE_DATABASE } = require("e2e/support/cypress_sample_database");-const { ALL_USERS_GROUP, COLLECTION_GROUP } = USER_GROUPS;const { ORDERS_ID, ORDERS, PRODUCTS_ID, PRODUCTS, PEOPLE, PEOPLE_ID } =SAMPLE_DATABASE;@@ -427,60 +425,6 @@ describe("issue 28756", () => {});});-describe("issue 29076", () => {- beforeEach(() => {- H.restore();-- cy.intercept("/api/dashboard/*/dashcard/*/card/*/query").as("cardQuery");-- cy.signInAsAdmin();- H.activateToken("pro-self-hosted");-- cy.updatePermissionsGraph({- [ALL_USERS_GROUP]: {- [SAMPLE_DB_ID]: {- "view-data": "blocked",- "create-queries": "no",- },- },- [COLLECTION_GROUP]: {- [SAMPLE_DB_ID]: {- "view-data": "unrestricted",- "create-queries": "query-builder",- },- },- });- cy.sandboxTable({- table_id: ORDERS_ID,- attribute_remappings: {- attr_uid: ["dimension", ["field", ORDERS.ID, null]],- },- });- cy.signInAsSandboxedUser();- });-- it("should be able to drilldown to a saved question in a dashboard with sandboxing (metabase#29076)", () => {- H.visitDashboard(ORDERS_DASHBOARD_ID);- cy.wait("@cardQuery");- // test that user is sandboxed - normal users has over 2000 rows- H.getDashboardCard()- .findByTestId("table-body")- .findAllByRole("row")- .should("have.length", 1);-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Orders").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Visualization").should("be.visible");- H.assertQueryBuilderRowCount(1); // test that user is sandboxed - normal users has over 2000 rows- H.assertDatasetReqIsSandboxed({- requestAlias: "@cardQuery",- columnId: ORDERS.USER_ID,- columnAssertion: Number(USERS.sandboxed.login_attributes.attr_uid),- });- });-});-describe("issue 31274", () => {beforeEach(() => {H.restore();@@ -785,91 +729,6 @@ describe("should not redirect users to other pages when linking an entity (metab}});-describe("issue 42165", () => {- const peopleSourceFieldRef = [- "field",- PEOPLE.SOURCE,- { "base-type": "type/Text", "source-field": ORDERS.USER_ID },- ];- const ordersCreatedAtFieldRef = [- "field",- ORDERS.CREATED_AT,- { "base-type": "type/DateTime", "temporal-unit": "month" },- ];-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- cy.intercept("POST", "/api/dataset").as("dataset");- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(- "dashcardQuery",- );-- H.createDashboardWithQuestions({- dashboardDetails: {- parameters: [- createMockParameter({- id: "param-1",- name: "Date",- slug: "date",- type: "date/all-options",- }),- ],- },- questions: [- {- name: "fooBarQuestion",- display: "bar",- query: {- aggregation: [["count"]],- breakout: [peopleSourceFieldRef, ordersCreatedAtFieldRef],- "source-table": ORDERS_ID,- },- },- ],- }).then(({ dashboard: _dashboard }) => {- cy.request("GET", `/api/dashboard/${_dashboard.id}`).then(- ({ body: dashboard }) => {- const [dashcard] = dashboard.dashcards;- const [parameter] = dashboard.parameters;- cy.request("PUT", `/api/dashboard/${dashboard.id}`, {- dashcards: [- {- ...dashcard,- parameter_mappings: [- {- card_id: dashcard.card_id,- parameter_id: parameter.id,- target: ["dimension", ordersCreatedAtFieldRef],- },- ],- },- ],- }).then(() => {- cy.wrap(_dashboard.id).as("dashboardId");- });- },- );- });- });-- it("should use card name instead of series names when navigating to QB from dashcard title", () => {- cy.get("@dashboardId").then((dashboardId) => {- H.visitDashboard(dashboardId);-- H.filterWidget().click();- H.popover().findByText("Previous 30 days").click();- cy.wait("@dashcardQuery");-- H.getDashboardCard(0).findByText("fooBarQuestion").click();-- cy.wait("@dataset");- cy.title().should("eq", "fooBarQuestion · Metabase");- });- });-});-describe("issue 47170", () => {beforeEach(() => {H.restore();diff --git a/e2e/test/scenarios/dashboard/dashcard-click-behavior-reproductions.cy.spec.ts b/e2e/test/scenarios/dashboard/dashcard-click-behavior-reproductions.cy.spec.tsindex 6b82574b600..77306a76f7d 100644--- a/e2e/test/scenarios/dashboard/dashcard-click-behavior-reproductions.cy.spec.ts+++ b/e2e/test/scenarios/dashboard/dashcard-click-behavior-reproductions.cy.spec.ts@@ -1651,11 +1651,15 @@ describe("issue 13785", () => {.click();cy.wait("@cardQuery");- cy.url().should("include", "2026-08");- H.chartPathWithFillColor("#509EE3").should("have.length", 1);- // Since hover doesn't work in Cypress we can't assert on the popover that's shown when one hovers the bar- // But when this issue gets fixed, Y-axis should definitely show "12" (total count of reviews)- H.echartsContainer().get("text").contains("12");+ cy.location("search").should("eq", "?date_filter=2026-08");+ H.chartPathWithFillColor("#509EE3")+ .should("have.length", 1)+ .first()+ .trigger("mousemove");+ H.assertEChartsTooltip({+ header: "August 2026",+ rows: [{ name: "Count", value: "12" }],+ });});});});diff --git a/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.jsindex b631e6b82f9..62869afac33 100644--- a/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.js+++ b/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.js@@ -917,8 +917,9 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {cy.get("aside").button("Done").click();H.saveDashboard();+ cy.intercept("POST", "/api/dataset").as("multiParamDataset");clickLineChartPoint();- cy.wait("@dataset");+ cy.wait("@multiParamDataset");cy.findByTestId("qb-filters-panel").should("contain.text", "Created At is Jul 1–31, 2025").should("contain.text", "Quantity is equal to 64");diff --git a/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.jsindex 1b69e1edbd5..399de794db4 100644--- a/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.js+++ b/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.js@@ -1,13 +1,25 @@const { H } = cy;+import { SAMPLE_DB_ID, USERS, USER_GROUPS } from "e2e/support/cypress_data";import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";import {ORDERS_DASHBOARD_DASHCARD_ID,ORDERS_DASHBOARD_ID,ORDERS_QUESTION_ID,} from "e2e/support/cypress_sample_instance_data";+import { createMockParameter } from "metabase-types/api/mocks";-const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID, REVIEWS, REVIEWS_ID } =- SAMPLE_DATABASE;+const {+ ORDERS,+ ORDERS_ID,+ PRODUCTS,+ PRODUCTS_ID,+ REVIEWS,+ REVIEWS_ID,+ PEOPLE,+ PEOPLE_ID,+} = SAMPLE_DATABASE;++const { ALL_USERS_GROUP, COLLECTION_GROUP } = USER_GROUPS;describe("scenarios > dashboard > dashboard drill", () => {beforeEach(() => {@@ -15,7 +27,7 @@ describe("scenarios > dashboard > dashboard drill", () => {cy.signInAsAdmin();});- describe("should pass multiple filters for numeric column on drill-through (metabase#13062)", () => {+ it("should pass multiple filters for numeric column on drill-through (metabase#13062)", () => {const questionDetails = {name: "13062Q",query: {@@ -30,66 +42,50 @@ describe("scenarios > dashboard > dashboard drill", () => {type: "category",};- beforeEach(() => {- // Set "Rating" Field type to: "Category"- cy.request("PUT", `/api/field/${REVIEWS.RATING}`, {- semantic_type: "type/Category",- });-- H.createQuestionAndDashboard({ questionDetails }).then(- ({ body: { id, card_id, dashboard_id } }) => {- // Add filter to the dashboard- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {- parameters: [filter],- });-- // Connect filter to the dashboard card- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {- dashcards: [- {- id,- card_id,- row: 0,- col: 0,- size_x: 11,- size_y: 6,- parameter_mappings: [- {- parameter_id: filter.id,- card_id,- target: ["dimension", ["field", REVIEWS.RATING, null]],- },- ],- },- ],- });-- // set filter values (ratings 5 and 4) directly through the URL- cy.visit(`/dashboard/${dashboard_id}?category=5&category=4`);- cy.findByText("2 selections");- },- );+ // Set "Rating" Field type to: "Category"+ cy.request("PUT", `/api/field/${REVIEWS.RATING}`, {+ semantic_type: "type/Category",});- it("when clicking on the field value and on the card title (metabase#13062)", () => {- cy.findByTestId("dashcard").findByText("xavier").click();- H.popover().findByText("Is xavier").click();+ H.createQuestionAndDashboard({ questionDetails }).then(+ ({ body: { id, card_id, dashboard_id } }) => {+ // Add filter to the dashboard+ cy.request("PUT", `/api/dashboard/${dashboard_id}`, {+ parameters: [filter],+ });- cy.findByTestId("qb-filters-panel").within(() => {- cy.findByText("Reviewer is xavier").should("be.visible");- cy.findByText("Rating is equal to 2 selections").should("be.visible");- });+ // Connect filter to the dashboard card+ cy.request("PUT", `/api/dashboard/${dashboard_id}`, {+ dashcards: [+ {+ id,+ card_id,+ row: 0,+ col: 0,+ size_x: 11,+ size_y: 6,+ parameter_mappings: [+ {+ parameter_id: filter.id,+ card_id,+ target: ["dimension", ["field", REVIEWS.RATING, null]],+ },+ ],+ },+ ],+ });- // xavier's review- H.queryBuilderMain()- .contains("Reprehenderit non error")- .should("be.visible");+ cy.wrap(dashboard_id).as("dashboardId");+ },+ );- H.assertQueryBuilderRowCount(1);+ cy.get("@dashboardId").then((dashboardId) => {+ // set filter values (ratings 5 and 4) directly through the URL+ const dashboardUrl = `/dashboard/${dashboardId}?category=5&category=4`;cy.log("when clicking on the card title (metabase#13062-2)");- cy.go("back");- H.filterWidget().findByText("2 selections").should("be.visible");+ cy.visit(dashboardUrl);+ H.filterWidget().should("contain", "2 selections");cy.findByTestId("dashcard").findByText(questionDetails.name).click();cy.findByTestId("qb-filters-panel")@@ -102,73 +98,32 @@ describe("scenarios > dashboard > dashboard drill", () => {.should("be.visible");H.assertQueryBuilderRowCount(907);- });- });- it("should drill-through on a primary key out of 2000 rows", () => {- cy.intercept("POST", "/api/dataset").as("dataset");-- // In this test we're using already present dashboard ("Orders in a dashboard")- const FILTER_ID = "7c9ege62";- const PK_VALUE = "7602";-- cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {- parameters: [- {- id: FILTER_ID,- name: "Category",- slug: "category",- type: "category",- default: ["Gadget"],- },- ],- });- cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {- dashcards: [- {- id: ORDERS_DASHBOARD_DASHCARD_ID,- card_id: ORDERS_QUESTION_ID,- row: 0,- col: 0,- size_x: 16,- size_y: 8,- parameter_mappings: [- {- parameter_id: FILTER_ID,- card_id: ORDERS_QUESTION_ID,- target: [- "dimension",- [- "field",- PRODUCTS.CATEGORY,- { "source-field": ORDERS.PRODUCT_ID },- ],- ],- },- ],- visualization_settings: {},- },- ],- });+ cy.log("when clicking on the field value (metabase#13062-1)");+ cy.visit(dashboardUrl);+ H.filterWidget().should("contain", "2 selections");- H.visitDashboard(ORDERS_DASHBOARD_ID);- H.tableHeaderClick("ID");+ cy.findByTestId("dashcard").findByText("xavier").click();+ H.popover().findByText("Is xavier").click();- cy.get(".test-Table-ID").contains(PK_VALUE).first().click();+ cy.findByTestId("qb-filters-panel").within(() => {+ cy.findByText("Reviewer is xavier").should("be.visible");+ cy.findByText("Rating is equal to 2 selections").should("be.visible");+ });- cy.wait("@dataset");+ // xavier's review+ H.queryBuilderMain()+ .contains("Reprehenderit non error")+ .should("be.visible");- cy.findByTestId("object-detail").within(() => {- cy.findAllByText(PK_VALUE);+ H.assertQueryBuilderRowCount(1);});-- const pattern = new RegExp(`/question\\?objectId=${PK_VALUE}#*`);- cy.url().should("match", pattern);});- it("should drill-through on a foreign key (metabase#8055)", () => {+ it("should drill-through on a foreign key (metabase#8055) and on a primary key out of 2000 rows", () => {// In this test we're using already present dashboard ("Orders in a dashboard")const FILTER_ID = "7c9ege62";+ const PK_VALUE = "7602";cy.log("Add filter (with the default Category) to the dashboard");cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {@@ -211,30 +166,42 @@ describe("scenarios > dashboard > dashboard drill", () => {},],});- cy.intercept("POST", "/api/dataset").as("dataset");+ cy.intercept("POST", "/api/dataset").as("fkDataset");+ cy.log("Drill through on a foreign key (metabase#8055)");H.visitDashboard(ORDERS_DASHBOARD_ID);// Product ID in the first row (query fails for User ID as well)- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("105").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("View details").click();+ H.getDashboardCard().findByText("105").click();+ H.clickActionsPopover().findByText("View details").click();cy.log("Reported on v0.29.3");- cy.wait("@dataset").then((xhr) => {+ cy.wait("@fkDataset").then((xhr) => {expect(xhr.response.body.error).not.to.exist;});cy.findByTestId("object-detail").findAllByText("Fantastic Wool Shirt").should("have.length", 3).and("be.visible");++ cy.log("Drill through on a primary key out of 2000 rows");+ H.visitDashboard(ORDERS_DASHBOARD_ID);+ cy.intercept("POST", "/api/dataset").as("pkDataset");+ H.tableHeaderClick("ID");++ cy.get(".test-Table-ID").contains(PK_VALUE).first().click();++ cy.wait("@pkDataset");++ cy.findByTestId("object-detail").within(() => {+ cy.findAllByText(PK_VALUE);+ });++ const pattern = new RegExp(`/question\\?objectId=${PK_VALUE}#*`);+ cy.url().should("match", pattern);});it("should keep card's display when doing zoom drill-through from dashboard (metabase#38307)", () => {cy.intercept("POST", "/api/dataset").as("dataset");- cy.intercept("/api/dashboard/*/dashcard/*/card/*/query").as(- "dashcardQuery",- );const questionDetails = {name: "38307",@@ -256,7 +223,7 @@ describe("scenarios > dashboard > dashboard drill", () => {// click the first bar on the card's graph and do a zoom drill-throughH.chartPathWithFillColor("#509EE3").eq(0).click();- cy.findByText("See this month by week").click();+ H.clickActionsPopover().findByText("See this month by week").click();cy.wait("@dataset");@@ -330,7 +297,7 @@ describe("scenarios > dashboard > dashboard drill", () => {});H.tableHeaderColumn("Quantity");cy.findByTestId("table-body")- .get("[data-dataset-index=0] > [data-column-id='ID']")+ .find("[data-dataset-index=0] > [data-column-id='ID']").should("have.text", "3") // Subject to change - sensitive to year shifting in the Sample Database.click();@@ -387,6 +354,7 @@ describe("scenarios > dashboard > dashboard drill", () => {H.chartPathWithFillColor("#88BF4D").first().trigger("mousemove");assertTooltipValues();+ H.echartsTriggerBlur();H.chartPathWithFillColor("#98D9D9").first()@@ -462,8 +430,15 @@ describe("scenarios > dashboard > dashboard drill", () => {H.visitDashboard(ORDERS_DASHBOARD_ID);});- it("should correctly drill-through on Orders and on Products filter (metabase#11503)", () => {+ it("should correctly drill-through on Orders and Products filters (metabase#11503)", () => {+ cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(+ "dashcardQuery",+ );++ cy.log("Orders filter (metabase#11503-1)");+ H.getDashboardCard().findByText("52.72").should("be.visible");setFilterValue(ordersIdFilter.name);+ cy.wait("@dashcardQuery");drillThroughCardTitle("Orders");@@ -477,13 +452,12 @@ describe("scenarios > dashboard > dashboard drill", () => {postDrillAssertion("ID is 2 selections");- cy.log(- "should correctly drill-through on Products filter (metabase#11503-2)",- );- cy.go("back");- H.filterWidget().eq(0).should("contain", "2 selections");+ cy.log("Products filter (metabase#11503-2)");+ H.visitDashboard(ORDERS_DASHBOARD_ID);+ H.filterWidget().should("contain", "2 selections");H.clearFilterWidget(0);- H.filterWidget().eq(0).should("contain", ordersIdFilter.name);+ H.filterWidget().should("not.contain", "2 selections");+setFilterValue(productsIdFilter.name);drillThroughCardTitle("Orders");@@ -519,7 +493,806 @@ describe("scenarios > dashboard > dashboard drill", () => {});});+describe("scenarios > dashboard > title drill", () => {+ describe("on a native question without connected dashboard parameters", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ const questionDetails = {+ name: "Q1",+ native: { query: 'SELECT 1 as "foo", 2 as "bar"' },+ display: "bar",+ visualization_settings: {+ "graph.dimensions": ["foo"],+ "graph.metrics": ["bar"],+ },+ };++ H.createNativeQuestionAndDashboard({ questionDetails }).then(+ ({ body: { dashboard_id }, questionId }) => {+ cy.wrap(questionId).as("questionId");+ cy.wrap(dashboard_id).as("dashboardId");+ },+ );+ });++ it("should let you click through the title to the query builder with and without access to underlying data (metabase#13042)", () => {+ cy.get("@questionId").then((questionId) => {+ cy.log("as a user with access to underlying data");+ H.visitDashboard("@dashboardId");+ // The title link is replaced when the chart renders, so hover only after the render.+ H.getDashboardCard()+ .findByTestId("chart-container")+ .should("be.visible");++ H.getDashboardCard().findByRole("link", { name: "Q1" }).as("title");+ cy.get("@title").realHover();+ cy.get("@title")+ .should("have.attr", "href")+ .and("include", `/question/${questionId}`);+ cy.get("@title").click();++ H.queryBuilderMain().within(() => {+ cy.findByText("This question is written in SQL.").should(+ "be.visible",+ );+ cy.findByText("foo").should("be.visible");+ cy.findByText("bar").should("be.visible");+ });++ cy.location("pathname").should("eq", `/question/${questionId}-q1`);++ cy.log("as a user without access to the underlying data");+ // Park the cursor off the grid, so only the mouseover below computes the title's href.+ cy.get("body").realHover({ position: "topLeft" });+ cy.signIn("nodata");+ H.visitDashboard("@dashboardId");+ H.getDashboardCard()+ .findByTestId("chart-container")+ .should("be.visible");++ H.getDashboardCard()+ .findByRole("link", { name: "Q1" })+ .as("nodataTitle");+ cy.get("@nodataTitle").trigger("mouseover");+ cy.get("@nodataTitle")+ .should("have.attr", "href")+ .and("include", `/question/${questionId}`);+ cy.get("@nodataTitle").click();++ H.queryBuilderMain().within(() => {+ cy.findByText("This question is written in SQL.").should(+ "be.visible",+ );+ cy.findByText("foo").should("be.visible");+ cy.findByText("bar").should("be.visible");+ });++ cy.location("pathname").should("eq", `/question/${questionId}-q1`);+ });+ });+ });++ describe("on a native question with a connected dashboard parameter", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ const filter = {+ name: "Text contains",+ slug: "text_contains",+ id: "98289b9b",+ type: "string/contains",+ sectionId: "string",+ };++ const questionDetails = {+ name: "16181",+ native: {+ query: "select count(*) from products where {{filter}}",+ "template-tags": {+ filter: {+ id: "0b004110-d64a-a413-5aa2-5a5314fc8fec",+ name: "filter",+ "display-name": "Filter",+ type: "dimension",+ dimension: ["field", PRODUCTS.TITLE, null],+ "widget-type": "string/contains",+ default: null,+ },+ },+ },+ display: "scalar",+ };++ const dashboardDetails = { parameters: [filter] };++ H.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: 11,+ size_y: 6,+ parameter_mappings: [+ {+ parameter_id: filter.id,+ card_id,+ target: ["dimension", ["template-tag", "filter"]],+ },+ ],+ },+ ],+ });++ cy.wrap(dashboard_id).as("dashboardId");+ });+ });++ it("'contains' filter should still work after title drill through IF the native question field filter's type matches exactly, with and without access to underlying data (metabase#16181)", () => {+ cy.log("as a user with access to underlying data");+ H.visitDashboard("@dashboardId");+ assertContainsFilterSurvivesTitleDrill();++ cy.log("as a user without access to underlying data");+ cy.signIn("nodata");+ H.visitDashboard("@dashboardId");+ assertContainsFilterSurvivesTitleDrill();+ });++ function assertContainsFilterSurvivesTitleDrill() {+ checkScalarResult("200");++ H.filterWidget().findByText("Text contains").click();+ cy.findByPlaceholderText("Enter some text").type("bb").blur();+ cy.button("Add filter").click();++ checkFilterLabelAndValue("Text contains", "bb");+ checkScalarResult("12");++ // Drill through on the question's title+ H.getDashboardCard().findByText("16181").click();++ checkFilterLabelAndValue("Filter", "bb");+ H.queryBuilderMain()+ .findByTestId("scalar-value")+ .invoke("text")+ .should("eq", "12");+ }+ });++ describe("on a simple question with a connected dashboard parameter", () => {+ const questionDetails = {+ name: "GUI Question",+ query: {+ "source-table": PRODUCTS_ID,+ aggregation: [["count"]],+ breakout: [["field", PRODUCTS.CATEGORY, null]],+ },+ display: "pie",+ };++ const filterWithDefaultValue = {+ name: "Category",+ slug: "category",+ id: "c32a49e1",+ type: "category",+ default: ["Doohickey"],+ };++ const filter = { name: "ID", slug: "id", id: "f2bf003c", type: "id" };++ const dashboardDetails = {+ parameters: [filterWithDefaultValue, filter],+ };++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(+ ({ body: dashboardCard, questionId }) => {+ const { card_id, dashboard_id } = dashboardCard;++ cy.wrap(questionId).as("questionId");+ cy.wrap(dashboard_id).as("dashboardId");+ cy.wrap(card_id).as("cardId");++ const mapFiltersToCard = {+ parameter_mappings: [+ {+ parameter_id: filterWithDefaultValue.id,+ card_id,+ target: ["dimension", ["field", PRODUCTS.CATEGORY, null]],+ },+ {+ parameter_id: filter.id,+ card_id,+ target: ["dimension", ["field", PRODUCTS.ID, null]],+ },+ ],+ };++ H.editDashboardCard(dashboardCard, mapFiltersToCard);+ },+ );+ });++ it("should let you click through the title to the query builder with the parameter applied as a filter, with and without access to underlying data", () => {+ cy.then(function () {+ const cardQueryUrl = `/api/dashboard/${this.dashboardId}/dashcard/*/card/${this.cardId}/query`;++ cy.log("as a user with access to underlying data");+ cy.intercept("POST", cardQueryUrl).as("cardQuery");+ H.visitDashboard(this.dashboardId);+ cy.wait("@cardQuery");++ // make sure query results are correct+ H.getDashboardCard().findByText("42");++ H.getDashboardCard()+ .findByRole("link", { name: "GUI Question" })+ .as("title");+ cy.get("@title").realHover();+ cy.get("@title")+ .should("have.attr", "href")+ .and("include", "/question#");+ cy.get("@title").click();++ // make sure the query builder filter is present+ cy.findByTestId("qb-filters-panel")+ .findByText("Category is Doohickey")+ .should("be.visible");++ // make sure the results match+ H.queryBuilderMain().findByText("42").should("be.visible");+ cy.location("href").should("include", "/question#");++ cy.log("as a user without access to underlying data");+ cy.signIn("nodata");+ cy.intercept("POST", cardQueryUrl).as("nodataCardQuery");+ H.visitDashboard(this.dashboardId);+ cy.wait("@nodataCardQuery");++ // make sure query results are correct+ H.getDashboardCard().findByText("42").should("be.visible");++ H.getDashboardCard()+ .findByRole("link", { name: "GUI Question" })+ .as("nodataTitle");+ cy.get("@nodataTitle").realHover();+ cy.get("@nodataTitle")+ .should("have.attr", "href")+ .and("include", "/question?category=Doohickey&id=#");+ cy.get("@nodataTitle").click();+ cy.wait("@nodataCardQuery");++ // make sure the results match+ H.queryBuilderMain().findByText("42").should("be.visible");+ cy.location("href").should(+ "include",+ `/question/${this.questionId}-gui-question?category=Doohickey&id=#`,+ );++ // update the parameter filter to a new value+ H.filterWidget().contains("Doohickey").click();+ H.dashboardParametersPopover().within(() => {+ cy.findByText("Doohickey").click();+ cy.findByText("Gadget").click();+ cy.findByText("Update filter").click();+ });++ // rerun the query with the newly set filter+ cy.findAllByTestId("run-button").first().click();+ cy.wait("@nodataCardQuery");++ // make sure the results reflect the new filter+ H.queryBuilderMain().findByText("53").should("be.visible");++ // make sure the set parameter filter persists after a page refresh+ cy.reload();+ cy.wait("@nodataCardQuery");++ H.queryBuilderMain().findByText("53").should("be.visible");++ // make sure the unset id parameter works+ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ H.filterWidget().last().click();+ H.dashboardParametersPopover().within(() => {+ H.fieldValuesCombobox().type("5");+ cy.findByText("Add filter").click();+ });++ // rerun the query with the newly set filter+ cy.findAllByTestId("run-button").first().click();+ cy.wait("@nodataCardQuery");++ H.queryBuilderMain().findByText("1").should("be.visible");+ });+ });+ });++ describe("on a nested simple question with a connected dashboard parameter", () => {+ const questionDetails = {+ name: "GUI Question",+ query: {+ "source-table": PRODUCTS_ID,+ },+ };+ const baseNestedQuestionDetails = {+ name: "Nested GUI Question",+ };++ const idFilter = { name: "ID", slug: "id", id: "f2bf003c", type: "id" };++ const dashboardDetails = {+ name: "Nested question dashboard",+ parameters: [idFilter],+ };++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ H.createQuestion(questionDetails, {+ wrapId: true,+ idAlias: "questionId",+ });++ cy.get("@questionId").then((questionId) => {+ const nestedQuestionDetails = {+ ...baseNestedQuestionDetails,+ query: {+ "source-table": `card__${questionId}`,+ },+ };+ H.createQuestion(nestedQuestionDetails, {+ wrapId: true,+ idAlias: "nestedQuestionId",+ });+ });++ H.createDashboard(dashboardDetails).then(+ ({ body: { id: dashboardId } }) => {+ cy.wrap(dashboardId).as("dashboardId");+ },+ );++ cy.then(function () {+ H.addOrUpdateDashboardCard({+ card_id: this.nestedQuestionId,+ dashboard_id: this.dashboardId,+ card: {+ parameter_mappings: [+ {+ parameter_id: idFilter.id,+ card_id: this.nestedQuestionId,+ target: ["dimension", ["field", PRODUCTS.ID, null]],+ },+ ],+ },+ });+ });+ });++ it("should lead you to a table question with filtered ID (metabase#17213)", () => {+ const productRecordId = 3;+ H.visitDashboard("@dashboardId", { params: { id: productRecordId } });++ H.getDashboardCard()+ .findByRole("link", { name: baseNestedQuestionDetails.name })+ .as("title");+ cy.get("@title").realHover();+ cy.get("@title").should("have.attr", "href").and("include", "/question#");+ cy.get("@title").click();++ H.appBar()+ .contains(`Started from ${baseNestedQuestionDetails.name}`)+ .should("be.visible");+ cy.findByTestId("question-row-count")+ .findByText("Showing 1 row")+ .should("be.visible");++ cy.findByTestId("object-detail").should("not.exist");+ cy.location("href").should("include", "/question#");+ });+ });++ describe("on various charts", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ it("titles become actual HTML anchors on focus and on hover", () => {+ H.createDashboardWithQuestions({+ dashboardName: "Dashboard with aggregated Q2",+ questions: [+ {+ name: "Line chart",+ display: "line",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],+ ],+ limit: 5,+ },+ },+ {+ name: "Row chart",+ display: "row",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],+ ],+ limit: 5,+ },+ },+ {+ name: "Map chart",+ display: "map",+ query: {+ "source-table": PEOPLE_ID,+ limit: 5,+ },+ },+ {+ name: "Funnel chart",+ display: "funnel",+ query: {+ "source-table": PEOPLE_ID,+ aggregation: [["count"]],+ breakout: [["field", PEOPLE.SOURCE]],+ limit: 5,+ },+ },+ ],+ cards: [+ { row: 0, col: 0, size_x: 6, size_y: 6 },+ { row: 0, col: 6, size_x: 6, size_y: 6 },+ { row: 6, col: 0, size_x: 6, size_y: 6 },+ { row: 6, col: 6, size_x: 6, size_y: 6 },+ ],+ }).then(({ dashboard, questions }) => {+ // Park the cursor off the grid before the dashcards render: a pointer+ // resting over a title computes that title's href before it is asserted.+ cy.get("body").realHover({ position: "topLeft" });++ H.visitDashboard(dashboard.id);+ H.waitForDashcardsToLoad({ count: 4 });++ H.getDashboardCard(0)+ .findByRole("link", { name: "Line chart" })+ .as("line-chart-title");+ H.getDashboardCard(1)+ .findByRole("link", { name: "Row chart" })+ .as("row-chart-title");+ H.getDashboardCard(2)+ .findByRole("link", { name: "Map chart" })+ .as("map-chart-title");+ H.getDashboardCard(3)+ .findByRole("link", { name: "Funnel chart" })+ .as("funnel-chart-title");++ const titles = [+ {+ elementAlias: "@line-chart-title",+ href: `/question/${questions[0].id}-line-chart`,+ trigger: focusTitle,+ },+ {+ elementAlias: "@row-chart-title",+ href: `/question/${questions[1].id}-row-chart`,+ trigger: focusTitle,+ },+ {+ elementAlias: "@map-chart-title",+ href: `/question/${questions[2].id}-map-chart`,+ trigger: hoverTitle,+ },+ {+ elementAlias: "@funnel-chart-title",+ href: `/question/${questions[3].id}-funnel-chart`,+ trigger: hoverTitle,+ },+ ];++ cy.log("every title is an inert placeholder before focus and hover");+ titles.forEach(({ elementAlias }) => {+ cy.get(elementAlias).should("have.attr", "href", "#");+ });++ cy.log("focusing or hovering a title turns it into a question anchor");+ titles.forEach(assertTitleBecomesQuestionAnchor);+ });+ });++ function focusTitle(element) {+ element.focus();+ }++ function hoverTitle(element) {+ const { MouseEvent } = element.ownerDocument.defaultView;+ element.dispatchEvent(new MouseEvent("mouseover", { bubbles: true }));+ }++ /**+ * The question href is computed lazily on focus/mouseenter, and the anchor+ * is replaced when it resolves. Re-evaluating the trigger on each retry+ * keeps the assertion anchored to the node currently in the DOM.+ */+ function assertTitleBecomesQuestionAnchor({ elementAlias, href, trigger }) {+ cy.get(elementAlias).should(($el) => {+ trigger($el[0]);+ expect($el).to.have.attr("href", href);+ });+ }+ });++ describe("multiple series", () => {+ const question1Details = {+ name: "Q1",+ query: {+ "source-table": PEOPLE_ID,+ aggregation: [["count"]],+ breakout: [["field", PEOPLE.CREATED_AT, { "temporal-unit": "year" }]],+ },+ display: "line",+ };++ const question2Details = {+ name: "Q2",+ query: {+ "source-table": PEOPLE_ID,+ aggregation: [["count"]],+ breakout: [["field", PEOPLE.BIRTH_DATE, { "temporal-unit": "year" }]],+ },+ display: "line",+ };++ const dateParameter = {+ id: "date",+ name: "Date",+ slug: "date",+ type: "date/all-options",+ default: "1970-01-01~2025-01-01",+ };++ const dashboardDetails = {+ parameters: [dateParameter],+ };++ function createMultiSeriesDashboard() {+ H.createQuestionAndDashboard({+ questionDetails: question1Details,+ dashboardDetails,+ }).then(({ body: { id, card_id, dashboard_id } }) => {+ H.createQuestion(question2Details).then(+ ({ body: { id: card_2_id } }) => {+ cy.request("PUT", `/api/dashboard/${dashboard_id}`, {+ dashcards: [+ {+ id,+ card_id,+ series: [{ id: card_2_id }],+ row: 0,+ col: 0,+ size_x: 16,+ size_y: 8,+ parameter_mappings: [+ {+ parameter_id: dateParameter.id,+ card_id,+ target: ["dimension", ["field", PEOPLE.CREATED_AT, null]],+ },+ {+ parameter_id: dateParameter.id,+ card_id: card_2_id,+ target: ["dimension", ["field", PEOPLE.BIRTH_DATE, null]],+ },+ ],+ },+ ],+ });+ },+ );+ H.visitDashboard(dashboard_id);+ });+ }++ beforeEach(() => {+ H.restore();+ cy.signInAsNormalUser();+ });++ it("should use parameters mapped to each card for a multi-series dashcard", () => {+ createMultiSeriesDashboard();++ cy.log("click on a dot in the second series and drill thru");+ H.cartesianChartCircle().eq(20).click();+ H.popover().findByText("See these People").click();++ cy.log("make sure the parameter mapping for the second series was used");+ H.queryBuilderFiltersPanel().within(() => {+ cy.findByText("Birth Date is Jan 1, 1970 – Jan 1, 2025").should(+ "be.visible",+ );+ cy.findByText(/Created At/).should("not.exist");+ });+ });+ });+});++describe("issue 29076", () => {+ beforeEach(() => {+ H.restore();++ cy.intercept("/api/dashboard/*/dashcard/*/card/*/query").as("cardQuery");++ cy.signInAsAdmin();+ H.activateToken("pro-self-hosted");++ cy.updatePermissionsGraph({+ [ALL_USERS_GROUP]: {+ [SAMPLE_DB_ID]: {+ "view-data": "blocked",+ "create-queries": "no",+ },+ },+ [COLLECTION_GROUP]: {+ [SAMPLE_DB_ID]: {+ "view-data": "unrestricted",+ "create-queries": "query-builder",+ },+ },+ });+ cy.sandboxTable({+ table_id: ORDERS_ID,+ attribute_remappings: {+ attr_uid: ["dimension", ["field", ORDERS.ID, null]],+ },+ });+ cy.signInAsSandboxedUser();+ });++ it("should be able to drilldown to a saved question in a dashboard with sandboxing (metabase#29076)", () => {+ H.visitDashboard(ORDERS_DASHBOARD_ID);+ cy.wait("@cardQuery");+ // test that user is sandboxed - normal users has over 2000 rows+ H.getDashboardCard()+ .findByTestId("table-body")+ .findAllByRole("row")+ .should("have.length", 1);+ H.assertDatasetReqIsSandboxed({+ requestAlias: "@cardQuery",+ columnId: ORDERS.ID,+ columnAssertion: Number(USERS.sandboxed.login_attributes.attr_uid),+ });++ cy.intercept("POST", "/api/card/*/query").as("questionQuery");+ H.getDashboardCard().findByRole("link", { name: "Orders" }).click();+ cy.wait("@questionQuery");++ cy.location("pathname").should(+ "eq",+ `/question/${ORDERS_QUESTION_ID}-orders`,+ );+ H.assertQueryBuilderRowCount(1); // test that user is sandboxed - normal users has over 2000 rows+ H.assertDatasetReqIsSandboxed({+ requestAlias: "@questionQuery",+ columnId: ORDERS.ID,+ columnAssertion: Number(USERS.sandboxed.login_attributes.attr_uid),+ });+ });+});++describe("issue 42165", () => {+ const peopleSourceFieldRef = [+ "field",+ PEOPLE.SOURCE,+ { "base-type": "type/Text", "source-field": ORDERS.USER_ID },+ ];+ const ordersCreatedAtFieldRef = [+ "field",+ ORDERS.CREATED_AT,+ { "base-type": "type/DateTime", "temporal-unit": "month" },+ ];++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ cy.intercept("POST", "/api/dataset").as("dataset");++ H.createDashboardWithQuestions({+ dashboardDetails: {+ parameters: [+ createMockParameter({+ id: "param-1",+ name: "Date",+ slug: "date",+ type: "date/all-options",+ }),+ ],+ },+ questions: [+ {+ name: "fooBarQuestion",+ display: "bar",+ query: {+ aggregation: [["count"]],+ breakout: [peopleSourceFieldRef, ordersCreatedAtFieldRef],+ "source-table": ORDERS_ID,+ },+ },+ ],+ }).then(({ dashboard: _dashboard }) => {+ cy.request("GET", `/api/dashboard/${_dashboard.id}`).then(+ ({ body: dashboard }) => {+ const [dashcard] = dashboard.dashcards;+ const [parameter] = dashboard.parameters;+ cy.request("PUT", `/api/dashboard/${dashboard.id}`, {+ dashcards: [+ {+ ...dashcard,+ parameter_mappings: [+ {+ card_id: dashcard.card_id,+ parameter_id: parameter.id,+ target: ["dimension", ordersCreatedAtFieldRef],+ },+ ],+ },+ ],+ }).then(() => {+ cy.wrap(_dashboard.id).as("dashboardId");+ });+ },+ );+ });+ });++ it("should use card name instead of series names when navigating to QB from dashcard title", () => {+ cy.get("@dashboardId").then((dashboardId) => {+ H.visitDashboard(dashboardId, { params: { date: "2027-01" } });+ H.filterWidget().should("contain", "2027");++ H.getDashboardCard(0).within(() => {+ cy.findAllByTestId("legend-item").should("have.length", 5);+ cy.findAllByTestId("legend-item")+ .first()+ .should("contain.text", "Affiliate");+ cy.findByText("fooBarQuestion").click();+ });++ cy.wait("@dataset");+ cy.title().should("eq", "fooBarQuestion · Metabase");+ });+ });+});+function drillThroughCardTitle(title) {cy.findByTestId("legend-caption").contains(title).click();cy.contains(`Started from ${title}`);}++function checkFilterLabelAndValue(label, value) {+ H.filterWidget().findByLabelText(label, { exact: false }).should("exist");+ H.filterWidget().contains(value);+}++function checkScalarResult(result) {+ cy.findByTestId("scalar-value").invoke("text").should("eq", result);+}diff --git a/e2e/test/scenarios/dashboard/title-drill.cy.spec.js b/e2e/test/scenarios/dashboard/title-drill.cy.spec.jsdeleted file mode 100644index 0a77181095f..00000000000--- a/e2e/test/scenarios/dashboard/title-drill.cy.spec.js+++ /dev/null@@ -1,678 +0,0 @@-const { H } = cy;-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";--const { ORDERS, ORDERS_ID, PEOPLE, PEOPLE_ID, PRODUCTS, PRODUCTS_ID } =- SAMPLE_DATABASE;--describe("scenarios > dashboard > title drill", () => {- describe("on a native question without connected dashboard parameters", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- const questionDetails = {- name: "Q1",- native: { query: 'SELECT 1 as "foo", 2 as "bar"' },- display: "bar",- visualization_settings: {- "graph.dimensions": ["foo"],- "graph.metrics": ["bar"],- },- };-- H.createNativeQuestionAndDashboard({ questionDetails }).then(- ({ body: { dashboard_id }, questionId }) => {- cy.wrap(questionId).as("questionId");- H.visitDashboard(dashboard_id);- },- );- });-- describe("as a user with access to underlying data", () => {- it("should let you click through the title to the query builder (metabase#13042)", () => {- cy.get("@questionId").then((questionId) => {- cy.findByTestId("loading-indicator").should("not.exist");-- H.getDashboardCard().findByRole("link", { name: "Q1" }).as("title");- cy.get("@title").realHover();- cy.get("@title")- .should("have.attr", "href")- .and("include", `/question/${questionId}`);- cy.get("@title").click();-- H.queryBuilderMain().within(() => {- cy.findByText("This question is written in SQL.").should(- "be.visible",- );- cy.findByText("foo").should("be.visible");- cy.findByText("bar").should("be.visible");- });-- cy.location("pathname").should("eq", `/question/${questionId}-q1`);- });- });- });-- describe("as a user without access to the underlying data", () => {- beforeEach(() => {- cy.signIn("nodata");- cy.reload();- });-- it("should let you click through the title to the query builder (metabase#13042)", () => {- cy.get("@questionId").then((questionId) => {- cy.findByTestId("loading-indicator").should("not.exist");-- H.getDashboardCard().findByRole("link", { name: "Q1" }).as("title");- cy.get("@title").trigger("mouseover");- cy.get("@title")- .should("have.attr", "href")- .and("include", `/question/${questionId}`);- cy.get("@title").click();-- H.queryBuilderMain().within(() => {- cy.findByText("This question is written in SQL.").should(- "be.visible",- );- cy.findByText("foo").should("be.visible");- cy.findByText("bar").should("be.visible");- });-- cy.location("pathname").should("eq", `/question/${questionId}-q1`);- });- });- });- });-- describe("on a native question with a connected dashboard parameter", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- const filter = {- name: "Text contains",- slug: "text_contains",- id: "98289b9b",- type: "string/contains",- sectionId: "string",- };-- const questionDetails = {- name: "16181",- native: {- query: "select count(*) from products where {{filter}}",- "template-tags": {- filter: {- id: "0b004110-d64a-a413-5aa2-5a5314fc8fec",- name: "filter",- "display-name": "Filter",- type: "dimension",- dimension: ["field", PRODUCTS.TITLE, null],- "widget-type": "string/contains",- default: null,- },- },- },- display: "scalar",- };-- const dashboardDetails = { parameters: [filter] };-- H.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: 11,- size_y: 6,- parameter_mappings: [- {- parameter_id: filter.id,- card_id,- target: ["dimension", ["template-tag", "filter"]],- },- ],- },- ],- });-- H.visitDashboard(dashboard_id);- checkScalarResult("200");- });- });-- describe("as a user with access to underlying data", () => {- it("'contains' filter should still work after title drill through IF the native question field filter's type matches exactly (metabase#16181)", () => {- checkScalarResult("200");-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Text contains").click();- cy.findByPlaceholderText("Enter some text").type("bb").blur();- cy.button("Add filter").click();-- checkFilterLabelAndValue("Text contains", "bb");- checkScalarResult("12");-- // Drill through on the question's title- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("16181").click();-- checkFilterLabelAndValue("Filter", "bb");- checkScalarResult("12");- });- });-- describe("as a user without access to underlying data", () => {- beforeEach(() => {- cy.signIn("nodata");- cy.reload();- });-- it("'contains' filter should still work after title drill through IF the native question field filter's type matches exactly (metabase#16181)", () => {- checkScalarResult("200");-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Text contains").click();- cy.findByPlaceholderText("Enter some text").type("bb").blur();- cy.button("Add filter").click();-- checkFilterLabelAndValue("Text contains", "bb");- checkScalarResult("12");-- // Drill through on the question's title- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("16181").click();-- checkFilterLabelAndValue("Filter", "bb");- checkScalarResult("12");- });- });- });-- describe("on a simple question with a connected dashboard parameter", () => {- const questionDetails = {- name: "GUI Question",- query: {- "source-table": PRODUCTS_ID,- aggregation: [["count"]],- breakout: [["field", PRODUCTS.CATEGORY, null]],- },- display: "pie",- };-- const filterWithDefaultValue = {- name: "Category",- slug: "category",- id: "c32a49e1",- type: "category",- default: ["Doohickey"],- };-- const filter = { name: "ID", slug: "id", id: "f2bf003c", type: "id" };-- const dashboardDetails = {- parameters: [filterWithDefaultValue, filter],- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(- ({ body: dashboardCard, questionId }) => {- const { card_id, dashboard_id } = dashboardCard;-- cy.wrap(questionId).as("questionId");-- const mapFiltersToCard = {- parameter_mappings: [- {- parameter_id: filterWithDefaultValue.id,- card_id,- target: ["dimension", ["field", PRODUCTS.CATEGORY, null]],- },- {- parameter_id: filter.id,- card_id,- target: ["dimension", ["field", PRODUCTS.ID, null]],- },- ],- };-- H.editDashboardCard(dashboardCard, mapFiltersToCard);-- cy.intercept(- "POST",- `/api/dashboard/${dashboard_id}/dashcard/*/card/${card_id}/query`,- ).as("cardQuery");-- H.visitDashboard(dashboard_id);- },- );- });-- describe("as a user with access to underlying data", () => {- it("should let you click through the title to the query builder with the parameter applied as a filter on the question", () => {- cy.wait("@cardQuery");-- // make sure query results are correct- H.getDashboardCard().findByText("42");-- H.getDashboardCard()- .findByRole("link", { name: "GUI Question" })- .as("title");- cy.get("@title").realHover();- cy.get("@title")- .should("have.attr", "href")- .and("include", "/question#");- cy.get("@title").click();-- // make sure the query builder filter is present- cy.findByTestId("qb-filters-panel")- .findByText("Category is Doohickey")- .should("be.visible");-- // make sure the results match- H.queryBuilderMain().findByText("42").should("be.visible");- cy.location("href").should("include", "/question#");- });- });-- describe("as a user without access to underlying data", () => {- beforeEach(() => {- cy.signIn("nodata");- cy.reload();- });-- it("should let you click through the title to the query builder with the parameter filter showing in the query builder", () => {- cy.wait("@cardQuery");-- // make sure query results are correct- H.getDashboardCard().findByText("42").should("be.visible");-- H.getDashboardCard()- .findByRole("link", { name: "GUI Question" })- .as("title");- cy.get("@title").realHover();- cy.get("@title")- .should("have.attr", "href")- .and("include", "/question?category=Doohickey&id=#");- cy.get("@title").click();-- // make sure the results match- H.queryBuilderMain().findByText("42").should("be.visible");- cy.get("@questionId").then((questionId) => {- cy.location("href").should(- "include",- `/question/${questionId}-gui-question?category=Doohickey&id=#`,- );- });-- // update the parameter filter to a new value- H.filterWidget().contains("Doohickey").click();- H.dashboardParametersPopover().within(() => {- cy.findByText("Doohickey").click();- cy.findByText("Gadget").click();- cy.findByText("Update filter").click();- });-- // rerun the query with the newly set filter- cy.findAllByTestId("run-button").first().click();- cy.wait("@cardQuery");-- // make sure the results reflect the new filter- H.queryBuilderMain().findByText("53").should("be.visible");-- // make sure the set parameter filter persists after a page refresh- cy.reload();- cy.wait("@cardQuery");-- H.queryBuilderMain().findByText("53").should("be.visible");-- // make sure the unset id parameter works- // eslint-disable-next-line metabase/no-unsafe-element-filtering- H.filterWidget().last().click();- H.dashboardParametersPopover().within(() => {- H.fieldValuesCombobox().type("5");- cy.findByText("Add filter").click();- });-- // rerun the query with the newly set filter- cy.findAllByTestId("run-button").first().click();- cy.wait("@cardQuery");-- H.queryBuilderMain().findByText("1").should("be.visible");- });- });- });-- describe("on a nested simple question with a connected dashboard parameter", () => {- const questionDetails = {- name: "GUI Question",- query: {- "source-table": PRODUCTS_ID,- },- };- const baseNestedQuestionDetails = {- name: "Nested GUI Question",- };-- const idFilter = { name: "ID", slug: "id", id: "f2bf003c", type: "id" };-- const dashboardDetails = {- name: "Nested question dashboard",- parameters: [idFilter],- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.createQuestion(questionDetails, {- wrapId: true,- idAlias: "questionId",- });-- cy.get("@questionId").then((questionId) => {- const nestedQuestionDetails = {- ...baseNestedQuestionDetails,- query: {- "source-table": `card__${questionId}`,- },- };- H.createQuestion(nestedQuestionDetails, {- wrapId: true,- idAlias: "nestedQuestionId",- });- });-- H.createDashboard(dashboardDetails).then(- ({ body: { id: dashboardId } }) => {- cy.wrap(dashboardId).as("dashboardId");- },- );-- cy.then(function () {- H.addOrUpdateDashboardCard({- card_id: this.nestedQuestionId,- dashboard_id: this.dashboardId,- card: {- parameter_mappings: [- {- parameter_id: idFilter.id,- card_id: this.nestedQuestionId,- target: ["dimension", ["field", PRODUCTS.ID, null]],- },- ],- },- });- });- });-- it("should lead you to a table question with filtered ID (metabase#17213)", () => {- const productRecordId = 3;- H.visitDashboard("@dashboardId", { params: { id: productRecordId } });-- H.getDashboardCard()- .findByRole("link", { name: baseNestedQuestionDetails.name })- .as("title");- cy.get("@title").realHover();- cy.get("@title").should("have.attr", "href").and("include", "/question#");- cy.get("@title").click();-- H.appBar()- .contains(`Started from ${baseNestedQuestionDetails.name}`)- .should("be.visible");- cy.findByTestId("question-row-count")- .findByText("Showing 1 row")- .should("be.visible");-- cy.findByTestId("object-detail").should("not.exist");- cy.location("href").should("include", "/question#");- });- });-- describe("on various charts", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("titles become actual HTML anchors on focus and on hover", () => {- H.createDashboardWithQuestions({- dashboardName: "Dashboard with aggregated Q2",- questions: [- {- name: "Line chart",- display: "line",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],- ],- limit: 5,- },- },- {- name: "Row chart",- display: "row",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],- ],- limit: 5,- },- },- {- name: "Map chart",- display: "map",- query: {- "source-table": PEOPLE_ID,- limit: 5,- },- },- {- name: "Funnel chart",- display: "funnel",- query: {- "source-table": PEOPLE_ID,- aggregation: [["count"]],- breakout: [["field", PEOPLE.SOURCE]],- limit: 5,- },- },- ],- cards: [- { row: 0, col: 0, size_x: 6, size_y: 6 },- { row: 0, col: 6, size_x: 6, size_y: 6 },- { row: 6, col: 0, size_x: 6, size_y: 6 },- { row: 6, col: 6, size_x: 6, size_y: 6 },- ],- }).then(({ dashboard, questions }) => {- // Park the cursor off the grid before the dashcards render: a pointer- // resting over a title computes that title's href before it is asserted.- cy.get("body").realHover({ position: "topLeft" });-- H.visitDashboard(dashboard.id);- H.waitForDashcardsToLoad({ count: 4 });-- H.getDashboardCard(0)- .findByRole("link", { name: "Line chart" })- .as("line-chart-title");- H.getDashboardCard(1)- .findByRole("link", { name: "Row chart" })- .as("row-chart-title");- H.getDashboardCard(2)- .findByRole("link", { name: "Map chart" })- .as("map-chart-title");- H.getDashboardCard(3)- .findByRole("link", { name: "Funnel chart" })- .as("funnel-chart-title");-- const titles = [- {- elementAlias: "@line-chart-title",- href: `/question/${questions[0].id}-line-chart`,- trigger: focusTitle,- },- {- elementAlias: "@row-chart-title",- href: `/question/${questions[1].id}-row-chart`,- trigger: focusTitle,- },- {- elementAlias: "@map-chart-title",- href: `/question/${questions[2].id}-map-chart`,- trigger: hoverTitle,- },- {- elementAlias: "@funnel-chart-title",- href: `/question/${questions[3].id}-funnel-chart`,- trigger: hoverTitle,- },- ];-- cy.log("every title is an inert placeholder before focus and hover");- titles.forEach(({ elementAlias }) => {- cy.get(elementAlias).should("have.attr", "href", "#");- });-- cy.log("focusing or hovering a title turns it into a question anchor");- titles.forEach(assertTitleBecomesQuestionAnchor);- });- });-- function focusTitle(element) {- element.focus();- }-- function hoverTitle(element) {- const { MouseEvent } = element.ownerDocument.defaultView;- element.dispatchEvent(new MouseEvent("mouseover", { bubbles: true }));- }-- /**- * The question href is computed lazily on focus/mouseenter, and the anchor- * is replaced when it resolves. Re-evaluating the trigger on each retry- * keeps the assertion anchored to the node currently in the DOM.- */- function assertTitleBecomesQuestionAnchor({ elementAlias, href, trigger }) {- cy.get(elementAlias).should(($el) => {- trigger($el[0]);- expect($el).to.have.attr("href", href);- });- }- });-- describe("multiple series", () => {- const question1Details = {- name: "Q1",- query: {- "source-table": PEOPLE_ID,- aggregation: [["count"]],- breakout: [["field", PEOPLE.CREATED_AT, { "temporal-unit": "year" }]],- },- display: "line",- };-- const question2Details = {- name: "Q2",- query: {- "source-table": PEOPLE_ID,- aggregation: [["count"]],- breakout: [["field", PEOPLE.BIRTH_DATE, { "temporal-unit": "year" }]],- },- display: "line",- };-- const dateParameter = {- id: "date",- name: "Date",- slug: "date",- type: "date/all-options",- default: "1970-01-01~2025-01-01",- };-- const dashboardDetails = {- parameters: [dateParameter],- };-- function createDashboard() {- H.createQuestionAndDashboard({- questionDetails: question1Details,- dashboardDetails,- }).then(({ body: { id, card_id, dashboard_id } }) => {- H.createQuestion(question2Details).then(- ({ body: { id: card_2_id } }) => {- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {- dashcards: [- {- id,- card_id,- series: [{ id: card_2_id }],- row: 0,- col: 0,- size_x: 16,- size_y: 8,- parameter_mappings: [- {- parameter_id: dateParameter.id,- card_id,- target: ["dimension", ["field", PEOPLE.CREATED_AT, null]],- },- {- parameter_id: dateParameter.id,- card_id: card_2_id,- target: ["dimension", ["field", PEOPLE.BIRTH_DATE, null]],- },- ],- },- ],- });- },- );- H.visitDashboard(dashboard_id);- });- }-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should use parameters mapped to each card for a multi-series dashcard", () => {- createDashboard();-- cy.log("click on a dot in the second series and drill thru");- H.cartesianChartCircle().eq(20).click();- H.popover().findByText("See these People").click();-- cy.log("make sure the parameter mapping for the second series was used");- H.queryBuilderFiltersPanel().within(() => {- cy.findByText("Birth Date is Jan 1, 1970 – Jan 1, 2025").should(- "be.visible",- );- cy.findByText(/Created At/).should("not.exist");- });- });- });-});--function checkFilterLabelAndValue(label, value) {- H.filterWidget().findByLabelText(label, { exact: false }).should("exist");- H.filterWidget().contains(value);-}--function checkScalarResult(result) {- cy.findByTestId("scalar-value").invoke("text").should("eq", result);-}