Skip to content

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

Consolidate dashboard click behavior e2e tests (#84035)

Nemanja Glumac3311c2e2dec5
diff --git a/e2e/support/helpers/e2e-misc-helpers.js b/e2e/support/helpers/e2e-misc-helpers.js
index 7af1aa7c6a8..886d307443c 100644
--- a/e2e/support/helpers/e2e-misc-helpers.js
+++ b/e2e/support/helpers/e2e-misc-helpers.js
@@ -462,3 +462,32 @@ export const onNextAnchorClick = (callback) => {
};
});
};
+
+/**
+ * Replaces anchor clicks with a stub, so the app does not open the link.
+ * Call `assertAnchorClicked` after the click to examine the anchor.
+ */
+export const stubAnchorClick = () => {
+ cy.window().then((window) => {
+ cy.stub(window.HTMLAnchorElement.prototype, "click").as("anchorClick");
+ });
+};
+
+/**
+ * Makes sure that the app clicked one anchor with these attributes.
+ * Use it after `stubAnchorClick`.
+ */
+export const assertAnchorClicked = ({
+ href,
+ target = "_blank",
+ rel = "noopener",
+}) => {
+ cy.get("@anchorClick").should((stub) => {
+ expect(stub).to.have.been.calledOnce;
+
+ const anchor = stub.firstCall.thisValue;
+ expect(anchor.getAttribute("href")).to.equal(href);
+ expect(anchor.getAttribute("target")).to.equal(target);
+ expect(anchor.getAttribute("rel")).to.equal(rel);
+ });
+};
diff --git a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js b/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js
index 9640c2fcc15..212a3036782 100644
--- a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js
@@ -19,10 +19,6 @@ const { ALL_USERS_GROUP, COLLECTION_GROUP } = USER_GROUPS;
const { ORDERS_ID, ORDERS, PRODUCTS_ID, PRODUCTS, PEOPLE, PEOPLE_ID } =
SAMPLE_DATABASE;
-function capitalize(string) {
- return string.charAt(0).toUpperCase() + string.slice(1);
-}
-
const ORDERS_QUESTION = {
name: "Orders question",
query: {
@@ -363,131 +359,6 @@ describe("issue 16559", () => {
});
});
-describe("issue 17879", () => {
- function setupDashcardAndDrillToQuestion({
- sourceDateUnit,
- expectedFilterText,
- targetDateUnit = "default",
- }) {
- if (targetDateUnit === "default") {
- H.createQuestion({
- name: "Q1 - 17879",
- query: {
- "source-table": ORDERS_ID,
- limit: 5,
- },
- });
- } else {
- H.createQuestion({
- name: "Q1 - 17879",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", ORDERS.CREATED_AT, { "temporal-unit": targetDateUnit }],
- ],
- limit: 5,
- },
- });
- }
-
- H.createDashboardWithQuestions({
- dashboardName: "Dashboard with aggregated Q2",
- questions: [
- {
- name: "Q2",
- display: "line",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", ORDERS.CREATED_AT, { "temporal-unit": sourceDateUnit }],
- ],
- limit: 5,
- },
- },
- ],
- }).then(({ dashboard }) => {
- cy.intercept(
- "POST",
- `/api/dashboard/${dashboard.id}/dashcard/*/card/*/query`,
- ).as("getCardQuery");
-
- H.visitDashboard(dashboard.id);
- H.editDashboard(dashboard.id);
-
- H.showDashboardCardActions();
- cy.findByTestId("dashboardcard-actions-panel").icon("click").click();
-
- cy.findByText("Go to a custom destination").click();
- cy.findByText("Saved question").click();
- cy.findByText("Q1 - 17879").click();
- cy.findByText("Created At").click();
-
- H.popover().within(() => {
- cy.findByText(
- "Created At: " + capitalize(sourceDateUnit.replace(/-/g, " ")),
- ).click();
- });
-
- cy.findByText("Done").click();
-
- H.saveDashboard();
-
- cy.wait("@getCardQuery");
-
- cy.findByTestId("visualization-root").within(() => {
- H.cartesianChartCircle().first().click({ force: true });
- });
-
- cy.url().should("include", "/question");
-
- cy.findByTestId("qb-filters-panel").should(
- "have.text",
- expectedFilterText,
- );
- });
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashcardQuery",
- );
- });
-
- it("should map dashcard date parameter to correct date range filter in target question - month -> day (metabase#17879)", () => {
- setupDashcardAndDrillToQuestion({
- sourceDateUnit: "month",
- expectedFilterText: "Created At is Apr 1–30, 2025",
- });
- });
-
- it("should map dashcard date parameter to correct date range filter in target question - week -> day (metabase#17879)", () => {
- setupDashcardAndDrillToQuestion({
- sourceDateUnit: "week",
- expectedFilterText: "Created At is Apr 27 – May 3, 2025",
- });
- });
-
- it("should map dashcard date parameter to correct date range filter in target question - year -> day (metabase#17879)", () => {
- setupDashcardAndDrillToQuestion({
- sourceDateUnit: "year",
- expectedFilterText: "Created At is Jan 1 – Dec 31, 2025",
- });
- });
-
- it("should map dashcard date parameter to correct date range filter in target question - year -> month (metabase#17879)", () => {
- setupDashcardAndDrillToQuestion({
- sourceDateUnit: "year",
- expectedFilterText: "Created At is Jan 1 – Dec 31, 2025",
- targetDateUnit: "month",
- });
- });
-});
-
describe("issue 28756", () => {
const UNRESTRICTED_COLLECTION_NAME = "Unrestricted collection";
const RESTRICTED_COLLECTION_NAME = "Restricted collection";
@@ -1265,89 +1136,6 @@ describe("issue 44937", () => {
);
});
});
-
-describe("issue 56716", () => {
- function setupDashboard() {
- const questionDetails = {
- query: {
- "source-table": PRODUCTS_ID,
- fields: [
- ["field", PRODUCTS.ID, null],
- ["field", PRODUCTS.RATING, null],
- ],
- },
- };
-
- const parameterDetails = {
- id: "b22a5ce2-fe1d-44e3-8df4-f8951f7921bc",
- type: "number/=",
- target: ["dimension", ["field", PRODUCTS.RATING, null]],
- name: "Number",
- slug: "number",
- };
-
- const dashboardDetails = {
- parameters: [parameterDetails],
- };
-
- const vizSettings = {
- column_settings: {
- '["name","RATING"]': {
- click_behavior: {
- type: "crossfilter",
- parameterMapping: {
- [parameterDetails.id]: {
- id: parameterDetails.id,
- source: { id: "RATING", name: "RATING", type: "column" },
- target: {
- id: parameterDetails.id,
- type: "parameter",
- },
- },
- },
- },
- },
- },
- };
-
- const getParameterMapping = (cardId) => ({
- card_id: cardId,
- parameter_id: parameterDetails.id,
- target: ["dimension", ["field", PRODUCTS.RATING, null]],
- });
-
- H.createQuestionAndDashboard({
- questionDetails,
- dashboardDetails,
- }).then(({ body: dashcard, questionId }) => {
- const { dashboard_id } = dashcard;
-
- H.editDashboardCard(dashcard, {
- parameter_mappings: [getParameterMapping(questionId)],
- visualization_settings: vizSettings,
- });
-
- H.visitDashboard(dashboard_id);
- });
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should reset the filter when clicking on a column value twice with a click behavior enabled (metabase#56716)", () => {
- setupDashboard();
-
- H.getDashboardCard().findByText("4.6").click();
- H.filterWidget().should("contain.text", "4.6");
- H.getDashboardCard().findByText("4 rows").should("be.visible");
-
- H.getDashboardCard().findAllByText("4.6").first().click();
- H.filterWidget().should("not.contain.text", "4.6");
- H.getDashboardCard().findByText("200 rows").should("be.visible");
- });
-});
describe("issue 62170", () => {
beforeEach(() => {
H.restore();
@@ -1589,132 +1377,6 @@ describe("issue 64138", () => {
}
});
-describe("issue 58556, issue 66277", () => {
- const QUESTION = {
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "hour" }]],
- },
- display: "table",
- };
-
- const PARAMETER = createMockParameter({
- id: "date-param",
- name: "Date",
- slug: "date",
- type: "date/all-options",
- });
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
-
- H.createDashboardWithQuestions({
- questions: [QUESTION],
- dashboardDetails: {
- parameters: [PARAMETER],
- },
- }).then(({ dashboard }) => {
- cy.request("GET", `/api/dashboard/${dashboard.id}`).then(
- ({ body: dashboard }) => {
- const [dashcard] = dashboard.dashcards;
-
- cy.request("PUT", `/api/dashboard/${dashboard.id}`, {
- dashcards: [
- {
- ...dashcard,
- parameter_mappings: [
- {
- card_id: dashcard.card_id,
- parameter_id: PARAMETER.id,
- target: [
- "dimension",
- [
- "field",
- "CREATED_AT",
- {
- "base-type": "type/DateTime",
- "inherited-temporal-unit": "hour",
- },
- ],
- {
- "stage-number": 1,
- },
- ],
- },
- ],
- },
- ],
- });
- },
- );
-
- H.visitDashboard(dashboard.id);
- });
-
- H.editDashboard();
- H.showDashboardCardActions();
- });
-
- it("should be possible to add a click action on a time column with hour granularity and have the time be present in the resulting parameter (metabase#58556)", () => {
- H.clickBehaviorSidebar().within(() => {
- cy.findByText("Created At: Hour").click();
- cy.findByText("Update a dashboard filter").click();
- cy.findByText("Date").click();
- });
-
- H.popover().findByText("Created At: Hour").click();
- H.sidebar().button("Done").click();
-
- H.saveDashboard();
-
- cy.log("click a row");
- H.dashboardCards()
- .findByTestId("table-body")
- .findAllByTestId("link-formatted-text")
- .eq(0)
- .click();
-
- cy.log("ensure the filter contains a time value");
- cy.location().then((location) => {
- const url = new URL(location.href);
- const date = url.searchParams.get("date");
- cy.wrap(date).should("match", /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/);
- });
- });
-
- it("should pass hour or minutes to linked questions from click actions (metabase#66277)", () => {
- H.clickBehaviorSidebar().within(() => {
- cy.findByText("Created At: Hour").click();
- cy.findByText("Go to a custom destination").click();
- cy.findByText("Saved question").click();
- });
-
- H.entityPickerModal().findByText("Orders").click();
-
- H.sidebar().findByText("Created At").scrollIntoView().click();
-
- H.popover().findByText("Created At: Hour").click();
- H.sidebar().button("Done").click();
-
- H.saveDashboard();
-
- cy.log("click a row");
- H.dashboardCards()
- .findByTestId("table-body")
- .findAllByTestId("link-formatted-text")
- .eq(0)
- .click();
-
- H.queryBuilderFiltersPanel()
- .findByText(
- /Created At is .* \d{1,2}:\d{2} (AM|PM) – \d{1,2}:\d{2} (AM|PM)/,
- )
- .should("be.visible");
- });
-});
-
describe("issue 65908", () => {
const dateParameters = {
default: "2030-01-01~",
diff --git a/e2e/test/scenarios/dashboard/dashboard.cy.spec.js b/e2e/test/scenarios/dashboard/dashboard.cy.spec.js
index 05146d0934c..3e8d0826ebb 100644
--- a/e2e/test/scenarios/dashboard/dashboard.cy.spec.js
+++ b/e2e/test/scenarios/dashboard/dashboard.cy.spec.js
@@ -17,7 +17,7 @@ import {
const { H } = cy;
-const { ORDERS, ORDERS_ID, PRODUCTS, PEOPLE, PEOPLE_ID } = SAMPLE_DATABASE;
+const { ORDERS, ORDERS_ID, PRODUCTS } = SAMPLE_DATABASE;
// There's a race condition when saving a dashboard
// and then immediately editing it again. After saving,
@@ -682,115 +682,6 @@ describe("scenarios > dashboard", () => {
cy.findByText("You're editing this dashboard.").should("not.exist");
});
- it("should update a dashboard filter by clicking on a map pin (metabase#13597)", () => {
- H.createQuestion({
- name: "13597",
- query: {
- "source-table": PEOPLE_ID,
- limit: 2,
- },
- display: "map",
- }).then(({ body: { id: questionId } }) => {
- H.createDashboard().then(({ body: { id: dashboardId } }) => {
- // add filter (ID) to the dashboard
- cy.request("PUT", `/api/dashboard/${dashboardId}`, {
- parameters: [
- {
- id: "92eb69ea",
- name: "ID",
- sectionId: "id",
- slug: "id",
- type: "id",
- },
- ],
- });
-
- H.addOrUpdateDashboardCard({
- card_id: questionId,
- dashboard_id: dashboardId,
- card: {
- parameter_mappings: [
- {
- parameter_id: "92eb69ea",
- card_id: questionId,
- target: ["dimension", ["field", PEOPLE.ID, null]],
- },
- ],
- visualization_settings: {
- // set click behavior to update filter (ID)
- click_behavior: {
- type: "crossfilter",
- parameterMapping: {
- "92eb69ea": {
- id: "92eb69ea",
- source: { id: "ID", name: "ID", type: "column" },
- target: {
- id: "92eb69ea",
- type: "parameter",
- },
- },
- },
- },
- },
- },
- });
-
- H.visitDashboard(dashboardId);
- H.mapPinIcon().eq(0).click({ force: true });
- cy.url().should("include", `/dashboard/${dashboardId}?id=1`);
- cy.contains("Hudson Borer - 1");
- });
- });
- });
-
- it("should display column options for cross-filter (metabase#14473)", () => {
- const questionDetails = {
- name: "14473",
- native: { query: "SELECT COUNT(*) FROM PRODUCTS", "template-tags": {} },
- };
-
- H.createNativeQuestionAndDashboard({ questionDetails }).then(
- ({ body: { dashboard_id } }) => {
- cy.log("Add 4 filters to the dashboard");
-
- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {
- parameters: [
- { name: "ID", slug: "id", id: "729b6456", type: "id" },
- { name: "ID 1", slug: "id_1", id: "bb20f59e", type: "id" },
- {
- name: "Category",
- slug: "category",
- id: "89873480",
- type: "category",
- },
- {
- name: "Category 1",
- slug: "category_1",
- id: "cbc045f2",
- type: "category",
- },
- ],
- });
-
- H.visitDashboard(dashboard_id);
- },
- );
-
- // Add cross-filter click behavior manually
- cy.icon("pencil").click();
- H.showDashboardCardActions();
- cy.findByTestId("dashboardcard-actions-panel").within(() => {
- cy.icon("click").click();
- });
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("COUNT(*)").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Update a dashboard filter").click();
-
- checkOptionsForFilter("ID");
- checkOptionsForFilter("Category");
- });
-
it("should not get the parameter values from the field API", () => {
// In this test we're using already present dashboard ("Orders in a dashboard")
const FILTER_ID = "d7988e02";
@@ -859,60 +750,6 @@ describe("scenarios > dashboard", () => {
cy.get("@fetchFieldValues").should("not.have.been.called");
});
- it("should be possible to visit a dashboard with click-behavior linked to the dashboard without permissions (metabase#15368)", () => {
- cy.request("GET", "/api/user/current").then(
- ({ body: { personal_collection_id } }) => {
- // Save new dashboard in admin's personal collection
- cy.request("POST", "/api/dashboard", {
- name: "15368D",
- collection_id: personal_collection_id,
- }).then(({ body: { id: NEW_DASHBOARD_ID } }) => {
- const COLUMN_REF = `["ref",["field-id",${ORDERS.ID}]]`;
- // Add click behavior to the existing "Orders in a dashboard" dashboard
- 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,
- series: [],
- visualization_settings: {
- column_settings: {
- [COLUMN_REF]: {
- click_behavior: {
- type: "link",
- linkType: "dashboard",
- parameterMapping: {},
- targetId: NEW_DASHBOARD_ID,
- },
- },
- },
- },
- parameter_mappings: [],
- },
- ],
- });
-
- cy.intercept(
- "GET",
- `/api/dashboard/${ORDERS_DASHBOARD_ID}/query_metadata*`,
- ).as("queryMetadata");
- });
- },
- );
- cy.signInAsNormalUser();
- H.visitDashboard(ORDERS_DASHBOARD_ID);
-
- cy.wait("@queryMetadata");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Orders in a dashboard");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("37.65");
- });
-
it("should be possible to scroll vertically after fullscreen layer is closed (metabase#15596)", () => {
// Make this dashboard card extremely tall so that it spans outside of visible viewport
cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {
@@ -1464,18 +1301,6 @@ describe("scenarios > dashboard", () => {
});
});
-function checkOptionsForFilter(filter) {
- cy.findByText("Available filters").parent().contains(filter).click();
- H.selectDropdown()
- .should("contain", "Columns")
- .and("contain", "COUNT(*)")
- .and("not.contain", "Dashboard filters");
-
- // Get rid of the open popover to be able to select another filter
- // Uses force: true because the popover is covering this text.
- cy.findByText("Pick one or more filters to update").click({ force: true });
-}
-
function assertScrollBarExists() {
cy.get("body").then(($body) => {
const bodyWidth = $body[0].getBoundingClientRect().width;
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.ts
index f26f3ef9d26..6b82574b600 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
@@ -1,10 +1,39 @@
const { H } = cy;
+import { WRITABLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-import type { StructuredQuestionDetails } from "e2e/support/helpers";
-import { createMockActionParameter } from "metabase-types/api/mocks";
+import {
+ ORDERS_DASHBOARD_DASHCARD_ID,
+ ORDERS_DASHBOARD_ID,
+ ORDERS_QUESTION_ID,
+} from "e2e/support/cypress_sample_instance_data";
+import type {
+ DashboardDetails,
+ StructuredQuestionDetails,
+} from "e2e/support/helpers";
+import type {
+ CardId,
+ DashboardId,
+ DashboardParameterMapping,
+ Parameter,
+ Table,
+ VisualizationSettings,
+} from "metabase-types/api";
+import {
+ createMockActionParameter,
+ createMockParameter,
+} from "metabase-types/api/mocks";
-const { PRODUCTS_ID, PRODUCTS, ORDERS_ID, ORDERS } = SAMPLE_DATABASE;
+const {
+ ORDERS,
+ ORDERS_ID,
+ PEOPLE,
+ PEOPLE_ID,
+ PRODUCTS,
+ PRODUCTS_ID,
+ REVIEWS,
+ REVIEWS_ID,
+} = SAMPLE_DATABASE;
describe("issue 59049", () => {
const questionDetails: StructuredQuestionDetails = {
@@ -421,3 +450,1229 @@ describe("table and chart click behavior", () => {
cy.findByTestId("click-behavior-sidebar").button("Done").click();
}
});
+
+describe("issue 16334", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ cy.intercept("POST", "/api/dataset").as("dataset");
+ cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
+ "dashcardQuery",
+ );
+ });
+
+ it("should not change the visualization type in a targetted question with mapped filter (metabase#16334)", () => {
+ // Question 2, that we're adding to the dashboard
+ const questionDetails = {
+ query: {
+ "source-table": REVIEWS_ID,
+ },
+ };
+
+ H.createQuestion({
+ name: "16334",
+ query: {
+ "source-table": PRODUCTS_ID,
+ aggregation: [["count"]],
+ breakout: [["field", PRODUCTS.CATEGORY, null]],
+ },
+ display: "pie",
+ }).then(({ body: { id: question1Id } }) => {
+ H.createQuestionAndDashboard({ questionDetails }).then(
+ ({ body: { id, dashboard_id }, questionId }) => {
+ cy.request("PUT", `/api/dashboard/${dashboard_id}`, {
+ dashcards: [
+ {
+ id,
+ card_id: questionId,
+ row: 0,
+ col: 0,
+ size_x: 11,
+ size_y: 8,
+ visualization_settings: getVisualizationSettings(question1Id),
+ },
+ ],
+ });
+
+ H.visitDashboard(dashboard_id);
+ cy.wait("@dashcardQuery");
+ },
+ );
+ });
+
+ cy.findAllByTestId("cell-data").contains("5").first().click();
+ cy.wait("@dataset");
+
+ // Make sure filter is set
+ cy.findByTestId("qb-filters-panel").should(
+ "contain.text",
+ "Rating is equal to 5",
+ );
+
+ // Make sure it's connected to the original question
+ cy.findByTestId("app-bar").should("contain.text", "Started from 16334");
+
+ // Make sure the original visualization didn't change
+ H.pieSlices().should("have.length", 2);
+
+ // The legacy click behavior shape doesn't match `VisualizationSettings`
+ const getVisualizationSettings = (targetId: CardId) => ({
+ column_settings: {
+ [`["ref",["field",${REVIEWS.RATING},null]]`]: {
+ click_behavior: {
+ targetId,
+ parameterMapping: {
+ [`["dimension",["field",${PRODUCTS.RATING},null],{"stage-number":0}]`]:
+ {
+ source: {
+ type: "column",
+ id: "RATING",
+ name: "Rating",
+ },
+ target: {
+ type: "dimension",
+ id: [
+ `["dimension",["field",${PRODUCTS.RATING},null],{"stage-number":0}]`,
+ ],
+ dimension: [
+ "dimension",
+ ["field", PRODUCTS.RATING, null],
+ { "stage-number": 0 },
+ ],
+ },
+ id: [
+ `["dimension",["field",${PRODUCTS.RATING},null],{"stage-number":0}]`,
+ ],
+ },
+ },
+ linkType: "question",
+ type: "link",
+ },
+ },
+ },
+ });
+ });
+});
+
+describe("issue 17160", () => {
+ const TARGET_DASHBOARD_NAME = "Target dashboard";
+ const CATEGORY_FILTER_PARAMETER_ID = "7c9ege62";
+
+ function assertMultipleValuesFilterState() {
+ cy.findByText("2 selections").click();
+
+ cy.findByLabelText("Doohickey").should("be.checked");
+ cy.findByLabelText("Gadget").should("be.checked");
+ }
+
+ function setup() {
+ H.createNativeQuestion({
+ name: "17160Q",
+ native: {
+ query: "SELECT * FROM products WHERE {{CATEGORY}}",
+ "template-tags": {
+ CATEGORY: {
+ id: "6b8b10ef-0104-1047-1e1b-2492d5954322",
+ name: "CATEGORY",
+ "display-name": "CATEGORY",
+ type: "dimension",
+ dimension: ["field", PRODUCTS.CATEGORY, null],
+ "widget-type": "category",
+ default: null,
+ },
+ },
+ },
+ }).then(({ body: { id: questionId } }) => {
+ H.createDashboard({ name: "17160D" }).then(
+ ({ body: { id: dashboardId } }) => {
+ cy.wrap(dashboardId).as("sourceDashboardId");
+
+ // Add the question to the dashboard
+ H.addOrUpdateDashboardCard({
+ dashboard_id: dashboardId,
+ card_id: questionId,
+ card: {},
+ }).then(({ body: { id: dashCardId } }) => {
+ // Add dashboard filter
+ cy.request("PUT", `/api/dashboard/${dashboardId}`, {
+ parameters: [
+ {
+ default: ["Doohickey", "Gadget"],
+ id: CATEGORY_FILTER_PARAMETER_ID,
+ name: "Category",
+ slug: "category",
+ sectionId: "string",
+ type: "string/=",
+ },
+ ],
+ });
+
+ createTargetDashboard().then((targetDashboardId) => {
+ cy.wrap(targetDashboardId).as("targetDashboardId");
+
+ // Create a click behaviour for the question card
+ cy.request("PUT", `/api/dashboard/${dashboardId}`, {
+ dashcards: [
+ {
+ id: dashCardId,
+ card_id: questionId,
+ row: 0,
+ col: 0,
+ size_x: 16,
+ size_y: 10,
+ parameter_mappings: [
+ {
+ parameter_id: CATEGORY_FILTER_PARAMETER_ID,
+ card_id: 4,
+ target: ["dimension", ["template-tag", "CATEGORY"]],
+ },
+ ],
+ visualization_settings: getVisualSettingsWithClickBehavior(
+ questionId,
+ targetDashboardId,
+ ),
+ },
+ ],
+ });
+ });
+ });
+ },
+ );
+ });
+ }
+
+ function getVisualSettingsWithClickBehavior(
+ questionTarget: CardId,
+ dashboardTarget: DashboardId,
+ ): VisualizationSettings {
+ return {
+ column_settings: {
+ '["name","ID"]': {
+ click_behavior: {
+ targetId: questionTarget,
+ parameterMapping: {
+ "6b8b10ef-0104-1047-1e1b-2492d5954322": {
+ source: {
+ type: "parameter",
+ id: CATEGORY_FILTER_PARAMETER_ID,
+ name: "Category",
+ },
+ target: {
+ type: "variable",
+ id: "CATEGORY",
+ },
+ id: "6b8b10ef-0104-1047-1e1b-2492d5954322",
+ },
+ },
+ linkType: "question",
+ type: "link",
+ linkTextTemplate: "click-behavior-question-label",
+ },
+ },
+
+ '["name","EAN"]': {
+ click_behavior: {
+ targetId: dashboardTarget,
+ parameterMapping: {
+ dd19ec03: {
+ source: {
+ type: "parameter",
+ id: CATEGORY_FILTER_PARAMETER_ID,
+ name: "Category",
+ },
+ target: {
+ type: "parameter",
+ id: "dd19ec03",
+ },
+ id: "dd19ec03",
+ },
+ },
+ linkType: "dashboard",
+ type: "link",
+ linkTextTemplate: "click-behavior-dashboard-label",
+ },
+ },
+ },
+ };
+ }
+
+ function createTargetDashboard() {
+ return H.createQuestionAndDashboard({
+ dashboardDetails: {
+ name: TARGET_DASHBOARD_NAME,
+ },
+ questionDetails: {
+ query: {
+ "source-table": PRODUCTS_ID,
+ },
+ },
+ }).then(({ body: { id, card_id, dashboard_id } }) => {
+ // Add a filter
+ cy.request("PUT", `/api/dashboard/${dashboard_id}`, {
+ parameters: [
+ {
+ name: "Category",
+ slug: "category",
+ id: "dd19ec03",
+ type: "string/=",
+ sectionId: "string",
+ },
+ ],
+ });
+
+ // Resize the question card and connect the filter to it
+ return cy
+ .request("PUT", `/api/dashboard/${dashboard_id}`, {
+ dashcards: [
+ {
+ id,
+ card_id,
+ row: 0,
+ col: 0,
+ size_x: 16,
+ size_y: 10,
+ parameter_mappings: [
+ {
+ parameter_id: "dd19ec03",
+ card_id,
+ target: ["dimension", ["field", PRODUCTS.CATEGORY, null]],
+ },
+ ],
+ },
+ ],
+ })
+ .then(() => {
+ return dashboard_id;
+ });
+ });
+ }
+
+ function visitSourceDashboard() {
+ cy.get<DashboardId>("@sourceDashboardId").then((id) => {
+ H.visitDashboard(id);
+ });
+ }
+
+ beforeEach(() => {
+ cy.intercept("POST", "/api/card/*/query").as("cardQuery");
+
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it("should pass multiple filter values to questions and dashboards (metabase#17160-1)", () => {
+ setup();
+
+ // 1. Check click behavior connected to a question
+ visitSourceDashboard();
+
+ cy.findAllByText("click-behavior-question-label").eq(0).click();
+ cy.wait("@cardQuery");
+
+ cy.url().should("include", "/question");
+
+ assertMultipleValuesFilterState();
+
+ // 2. Check click behavior connected to a dashboard
+ visitSourceDashboard();
+
+ cy.get("@targetDashboardId").then((id) => {
+ cy.intercept("POST", `/api/dashboard/${id}/dashcard/*/card/*/query`).as(
+ "targetDashcardQuery",
+ );
+
+ cy.findAllByText("click-behavior-dashboard-label").eq(0).click();
+ cy.wait("@targetDashcardQuery");
+ });
+
+ cy.url().should("include", "/dashboard");
+ cy.location("search").should("eq", "?category=Doohickey&category=Gadget");
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText(TARGET_DASHBOARD_NAME);
+
+ assertMultipleValuesFilterState();
+ });
+});
+
+describe("issue 23137", () => {
+ const GAUGE_QUESTION_DETAILS: StructuredQuestionDetails = {
+ display: "gauge",
+ query: {
+ "source-table": REVIEWS_ID,
+ aggregation: [["count"]],
+ },
+ };
+
+ const PROGRESS_QUESTION_DETAILS: StructuredQuestionDetails = {
+ display: "progress",
+ query: {
+ "source-table": REVIEWS_ID,
+ aggregation: [["count"]],
+ },
+ };
+
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ cy.intercept("POST", "/api/card/*/query").as("cardQuery");
+ });
+
+ it("should navigate to a target from gauge and progress cards (metabase#23137)", () => {
+ const visualization_settings: VisualizationSettings = {
+ click_behavior: {
+ type: "link",
+ linkType: "question",
+ targetId: ORDERS_QUESTION_ID,
+ parameterMapping: {},
+ },
+ };
+
+ H.createDashboardWithQuestions({
+ questions: [GAUGE_QUESTION_DETAILS, PROGRESS_QUESTION_DETAILS],
+ cards: [
+ { row: 0, col: 0, visualization_settings },
+ { row: 0, col: 12, visualization_settings },
+ ],
+ }).then(({ dashboard }) => {
+ H.visitDashboard(dashboard.id);
+ });
+
+ cy.log("gauge");
+ H.getDashboardCard(0).findByTestId("gauge-arc-1").click();
+ cy.wait("@cardQuery");
+ H.queryBuilderHeader().findByDisplayValue("Orders").should("be.visible");
+
+ cy.go("back");
+
+ cy.log("progress");
+ cy.intercept("POST", "/api/card/*/query").as("cardQuery");
+ H.getDashboardCard(1).findByTestId("progress-bar").click();
+ cy.wait("@cardQuery");
+ H.queryBuilderHeader().findByDisplayValue("Orders").should("be.visible");
+ });
+});
+
+describe("issue 46318", () => {
+ const query = `SELECT 'group_1' AS main_group, 'sub_group_1' AS sub_group, 111 AS value_sum, 'group_1__sub_group_1' AS group_name
+UNION ALL
+SELECT 'group_1', 'sub_group_2', 68, 'group_1__sub_group_2'
+UNION ALL
+SELECT 'group_2', 'sub_group_1', 79, 'group_2__sub_group_1'
+UNION ALL
+SELECT 'group_2', 'sub_group_2', 52, 'group_2__sub_group_2';
+`;
+
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+
+ H.createNativeQuestionAndDashboard({
+ questionDetails: {
+ name: "46318",
+ native: { query },
+ display: "row",
+ visualization_settings: {
+ "graph.dimensions": ["MAIN_GROUP", "SUB_GROUP"],
+ "graph.series_order_dimension": null,
+ "graph.metrics": ["VALUE_SUM"],
+ },
+ },
+ }).then((response) => {
+ H.visitDashboard(response.body.dashboard_id);
+ });
+
+ H.editDashboard();
+ H.getDashboardCard().realHover().icon("click").click();
+ cy.get("aside").within(() => {
+ cy.findByText("Go to a custom destination").click();
+ cy.findByText("URL").click();
+ });
+ H.modal().within(() => {
+ cy.findByPlaceholderText("e.g. http://acme.com/id/{{user_id}}").type(
+ `${Cypress.config("baseUrl")}/?q={{group_name}}`,
+ { parseSpecialCharSequences: false },
+ );
+ cy.button("Done").click();
+ });
+ H.saveDashboard();
+ });
+
+ it("passes values from unused columns of row visualization to click behavior (metabase#46318)", () => {
+ cy.findAllByRole("graphics-symbol").eq(0).click();
+ cy.location("href").should(
+ "eq",
+ `${Cypress.config("baseUrl")}/?q=group_1__sub_group_1`,
+ );
+
+ cy.go("back");
+
+ cy.findAllByRole("graphics-symbol").eq(2).click(); // intentionally eq(2), not eq(1) - that's how row viz works
+ cy.location("href").should(
+ "eq",
+ `${Cypress.config("baseUrl")}/?q=group_1__sub_group_2`,
+ );
+
+ cy.go("back");
+
+ cy.findAllByRole("graphics-symbol").eq(1).click(); // intentionally eq(1), not eq(2) - that's how row viz works
+ cy.location("href").should(
+ "eq",
+ `${Cypress.config("baseUrl")}/?q=group_2__sub_group_1`,
+ );
+ cy.go("back");
+
+ cy.findAllByRole("graphics-symbol").eq(3).click();
+ cy.location("href").should(
+ "eq",
+ `${Cypress.config("baseUrl")}/?q=group_2__sub_group_2`,
+ );
+ });
+});
+
+describe("issue 17879", () => {
+ const RAW_TARGET_NAME = "Q1 raw - 17879";
+ const MONTH_TARGET_NAME = "Q1 month - 17879";
+
+ const CASES = [
+ {
+ sourceDateUnit: "month",
+ targetName: RAW_TARGET_NAME,
+ expectedFilterText: "Created At is Apr 1–30, 2025",
+ },
+ {
+ sourceDateUnit: "week",
+ targetName: RAW_TARGET_NAME,
+ expectedFilterText: "Created At is Apr 27 – May 3, 2025",
+ },
+ {
+ sourceDateUnit: "year",
+ targetName: RAW_TARGET_NAME,
+ expectedFilterText: "Created At is Jan 1 – Dec 31, 2025",
+ },
+ {
+ sourceDateUnit: "year",
+ targetName: MONTH_TARGET_NAME,
+ expectedFilterText: "Created At is Jan 1 – Dec 31, 2025",
+ },
+ ] as const;
+
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it("should map dashcard date parameter to correct date range filter in target question (metabase#17879)", () => {
+ H.createQuestion({
+ name: RAW_TARGET_NAME,
+ query: {
+ "source-table": ORDERS_ID,
+ limit: 5,
+ },
+ });
+ H.createQuestion({
+ name: MONTH_TARGET_NAME,
+ query: {
+ "source-table": ORDERS_ID,
+ aggregation: [["count"]],
+ breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],
+ limit: 5,
+ },
+ });
+
+ H.createDashboardWithQuestions({
+ dashboardName: "Dashboard with aggregated Q2",
+ questions: CASES.map(({ sourceDateUnit, targetName }) => ({
+ name: `Q2 ${sourceDateUnit} to ${targetName}`,
+ display: "line",
+ query: {
+ "source-table": ORDERS_ID,
+ aggregation: [["count"]],
+ breakout: [
+ ["field", ORDERS.CREATED_AT, { "temporal-unit": sourceDateUnit }],
+ ],
+ limit: 5,
+ },
+ })),
+ cards: [
+ { row: 0, col: 0 },
+ { row: 0, col: 12 },
+ { row: 8, col: 0 },
+ { row: 8, col: 12 },
+ ],
+ }).then(({ dashboard }) => {
+ cy.wrap(dashboard.id).as("dashboardId");
+ H.visitDashboard(dashboard.id);
+ });
+
+ H.editDashboard();
+
+ CASES.forEach(({ sourceDateUnit, targetName }, index) => {
+ H.clickBehaviorSidebar(index).within(() => {
+ cy.findByText("Go to a custom destination").click();
+ cy.findByText("Saved question").click();
+ });
+ H.entityPickerModal().findByText(targetName).click();
+ H.sidebar().findByText("Created At").click();
+ H.popover()
+ .findByText(`Created At: ${capitalize(sourceDateUnit)}`)
+ .click();
+ H.sidebar().button("Done").click();
+ });
+
+ H.saveDashboard();
+
+ CASES.forEach(({ expectedFilterText }, index) => {
+ if (index > 0) {
+ H.visitDashboard("@dashboardId");
+ }
+ H.getDashboardCard(index)
+ .scrollIntoView()
+ .within(() => {
+ H.cartesianChartCircle().first().click({ force: true });
+ });
+
+ cy.url().should("include", "/question");
+ cy.findByTestId("qb-filters-panel").should(
+ "have.text",
+ expectedFilterText,
+ );
+ });
+ });
+});
+
+describe("issue 56716", () => {
+ function setupDashboard() {
+ const questionDetails: StructuredQuestionDetails = {
+ query: {
+ "source-table": PRODUCTS_ID,
+ fields: [
+ ["field", PRODUCTS.ID, null],
+ ["field", PRODUCTS.RATING, null],
+ ],
+ },
+ };
+
+ const parameterDetails: Parameter = {
+ id: "b22a5ce2-fe1d-44e3-8df4-f8951f7921bc",
+ type: "number/=",
+ target: ["dimension", ["field", PRODUCTS.RATING, null]],
+ name: "Number",
+ slug: "number",
+ };
+
+ const dashboardDetails: DashboardDetails = {
+ parameters: [parameterDetails],
+ };
+
+ const vizSettings: VisualizationSettings = {
+ column_settings: {
+ '["name","RATING"]': {
+ click_behavior: {
+ type: "crossfilter",
+ parameterMapping: {
+ [parameterDetails.id]: {
+ id: parameterDetails.id,
+ source: { id: "RATING", name: "RATING", type: "column" },
+ target: {
+ id: parameterDetails.id,
+ type: "parameter",
+ },
+ },
+ },
+ },
+ },
+ },
+ };
+
+ const getParameterMapping = (
+ cardId: CardId,
+ ): DashboardParameterMapping => ({
+ card_id: cardId,
+ parameter_id: parameterDetails.id,
+ target: ["dimension", ["field", PRODUCTS.RATING, null]],
+ });
+
+ H.createQuestionAndDashboard({
+ questionDetails,
+ dashboardDetails,
+ }).then(({ body: dashcard, questionId }) => {
+ const { dashboard_id } = dashcard;
+
+ H.editDashboardCard(dashcard, {
+ parameter_mappings: [getParameterMapping(questionId)],
+ visualization_settings: vizSettings,
+ });
+
+ H.visitDashboard(dashboard_id);
+ });
+ }
+
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it("should reset the filter when clicking on a column value twice with a click behavior enabled (metabase#56716)", () => {
+ setupDashboard();
+
+ H.getDashboardCard().findByText("4.6").click();
+ H.filterWidget().should("contain.text", "4.6");
+ H.getDashboardCard().findByText("4 rows").should("be.visible");
+
+ H.getDashboardCard().findAllByText("4.6").first().click();
+ H.filterWidget().should("not.contain.text", "4.6");
+ H.getDashboardCard().findByText("200 rows").should("be.visible");
+ });
+});
+
+describe("issue 58556, issue 66277", () => {
+ const QUESTION: StructuredQuestionDetails = {
+ query: {
+ "source-table": ORDERS_ID,
+ aggregation: [["count"]],
+ breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "hour" }]],
+ },
+ display: "table",
+ };
+
+ const PARAMETER = createMockParameter({
+ id: "date-param",
+ name: "Date",
+ slug: "date",
+ type: "date/all-options",
+ });
+
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsNormalUser();
+
+ H.createDashboardWithQuestions({
+ questions: [QUESTION],
+ dashboardDetails: {
+ parameters: [PARAMETER],
+ },
+ }).then(({ dashboard }) => {
+ cy.request("GET", `/api/dashboard/${dashboard.id}`).then(
+ ({ body: dashboard }) => {
+ const [dashcard] = dashboard.dashcards;
+ const parameter_mappings = [
+ {
+ card_id: dashcard.card_id,
+ parameter_id: PARAMETER.id,
+ target: [
+ "dimension",
+ [
+ "field",
+ "CREATED_AT",
+ {
+ "base-type": "type/DateTime",
+ "inherited-temporal-unit": "hour",
+ },
+ ],
+ {
+ "stage-number": 1,
+ },
+ ],
+ },
+ ];
+
+ cy.request("PUT", `/api/dashboard/${dashboard.id}`, {
+ dashcards: [
+ {
+ ...dashcard,
+ col: 0,
+ size_x: 12,
+ parameter_mappings,
+ },
+ {
+ ...dashcard,
+ id: -1,
+ col: 12,
+ size_x: 12,
+ parameter_mappings,
+ },
+ ],
+ });
+ },
+ );
+
+ H.visitDashboard(dashboard.id);
+ });
+
+ H.editDashboard();
+ });
+
+ it("should keep the time of an hour column in click behavior parameters (metabase#58556, metabase#66277)", () => {
+ cy.log("metabase#66277: go to a saved question");
+ H.clickBehaviorSidebar(1).within(() => {
+ cy.findByText("Created At: Hour").click();
+ cy.findByText("Go to a custom destination").click();
+ cy.findByText("Saved question").click();
+ });
+
+ H.entityPickerModal().findByText("Orders").click();
+
+ H.sidebar().findByText("Created At").scrollIntoView().click();
+
+ H.popover().findByText("Created At: Hour").click();
+ H.sidebar().button("Done").click();
+
+ cy.log("metabase#58556: update a dashboard filter");
+ H.clickBehaviorSidebar(0).within(() => {
+ cy.findByText("Created At: Hour").click();
+ cy.findByText("Update a dashboard filter").click();
+ cy.findByText("Date").click();
+ });
+
+ H.popover().findByText("Created At: Hour").click();
+ H.sidebar().button("Done").click();
+
+ H.saveDashboard();
+
+ cy.log("metabase#66277: click a row of the second card");
+ H.getDashboardCard(1)
+ .findByTestId("table-body")
+ .findAllByTestId("link-formatted-text")
+ .eq(0)
+ .click();
+
+ H.queryBuilderFiltersPanel()
+ .findByText(
+ /Created At is .* \d{1,2}:\d{2} (AM|PM) – \d{1,2}:\d{2} (AM|PM)/,
+ )
+ .should("be.visible");
+
+ cy.go("back");
+
+ cy.log("metabase#58556: click a row of the first card");
+ H.getDashboardCard(0)
+ .findByTestId("table-body")
+ .findAllByTestId("link-formatted-text")
+ .eq(0)
+ .click();
+
+ cy.log("ensure the filter contains a time value");
+ cy.location("search").should((search) => {
+ expect(new URLSearchParams(search).get("date")).to.match(
+ /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,
+ );
+ });
+ });
+});
+
+describe("issue 15368", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it("should be possible to visit a dashboard with click-behavior linked to the dashboard without permissions (metabase#15368)", () => {
+ cy.request("GET", "/api/user/current").then(
+ ({ body: { personal_collection_id } }) => {
+ // Save new dashboard in admin's personal collection
+ cy.request("POST", "/api/dashboard", {
+ name: "15368D",
+ collection_id: personal_collection_id,
+ }).then(({ body: { id: NEW_DASHBOARD_ID } }) => {
+ const COLUMN_REF = `["ref",["field-id",${ORDERS.ID}]]`;
+ // Add click behavior to the existing "Orders in a dashboard" dashboard
+ 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,
+ series: [],
+ visualization_settings: {
+ column_settings: {
+ [COLUMN_REF]: {
+ click_behavior: {
+ type: "link",
+ linkType: "dashboard",
+ parameterMapping: {},
+ targetId: NEW_DASHBOARD_ID,
+ },
+ },
+ },
+ },
+ parameter_mappings: [],
+ },
+ ],
+ });
+
+ cy.intercept(
+ "GET",
+ `/api/dashboard/${ORDERS_DASHBOARD_ID}/query_metadata*`,
+ ).as("queryMetadata");
+ });
+ },
+ );
+ cy.signInAsNormalUser();
+ H.visitDashboard(ORDERS_DASHBOARD_ID);
+
+ cy.wait("@queryMetadata");
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("Orders in a dashboard");
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.contains("37.65");
+ });
+});
+
+describe("issue 13597", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it("should update a dashboard filter by clicking on a map pin (metabase#13597)", () => {
+ H.createQuestion({
+ name: "13597",
+ query: {
+ "source-table": PEOPLE_ID,
+ limit: 2,
+ },
+ display: "map",
+ }).then(({ body: { id: questionId } }) => {
+ H.createDashboard().then(({ body: { id: dashboardId } }) => {
+ // add filter (ID) to the dashboard
+ cy.request("PUT", `/api/dashboard/${dashboardId}`, {
+ parameters: [
+ {
+ id: "92eb69ea",
+ name: "ID",
+ sectionId: "id",
+ slug: "id",
+ type: "id",
+ },
+ ],
+ });
+
+ H.addOrUpdateDashboardCard({
+ card_id: questionId,
+ dashboard_id: dashboardId,
+ card: {
+ parameter_mappings: [
+ {
+ parameter_id: "92eb69ea",
+ card_id: questionId,
+ target: ["dimension", ["field", PEOPLE.ID, null]],
+ },
+ ],
+ visualization_settings: {
+ // set click behavior to update filter (ID)
+ click_behavior: {
+ type: "crossfilter",
+ parameterMapping: {
+ "92eb69ea": {
+ id: "92eb69ea",
+ source: { id: "ID", name: "ID", type: "column" },
+ target: {
+ id: "92eb69ea",
+ type: "parameter",
+ },
+ },
+ },
+ },
+ },
+ },
+ });
+
+ H.visitDashboard(dashboardId);
+ H.mapPinIcon().eq(0).click({ force: true });
+ cy.url().should("include", `/dashboard/${dashboardId}?id=1`);
+ cy.contains("Hudson Borer - 1");
+ });
+ });
+ });
+});
+
+describe("issue 14473", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it("should display column options for cross-filter (metabase#14473)", () => {
+ const questionDetails = {
+ name: "14473",
+ native: { query: "SELECT COUNT(*) FROM PRODUCTS", "template-tags": {} },
+ };
+
+ H.createNativeQuestionAndDashboard({ questionDetails }).then(
+ ({ body: { dashboard_id } }) => {
+ cy.log("Add 4 filters to the dashboard");
+
+ cy.request("PUT", `/api/dashboard/${dashboard_id}`, {
+ parameters: [
+ { name: "ID", slug: "id", id: "729b6456", type: "id" },
+ { name: "ID 1", slug: "id_1", id: "bb20f59e", type: "id" },
+ {
+ name: "Category",
+ slug: "category",
+ id: "89873480",
+ type: "category",
+ },
+ {
+ name: "Category 1",
+ slug: "category_1",
+ id: "cbc045f2",
+ type: "category",
+ },
+ ],
+ });
+
+ H.visitDashboard(dashboard_id);
+ },
+ );
+
+ // Add cross-filter click behavior manually
+ cy.icon("pencil").click();
+ H.showDashboardCardActions();
+ cy.findByTestId("dashboardcard-actions-panel").within(() => {
+ cy.icon("click").click();
+ });
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("COUNT(*)").click();
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("Update a dashboard filter").click();
+
+ checkOptionsForFilter("ID");
+ checkOptionsForFilter("Category");
+ });
+});
+
+describe("issue 18067", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it(
+ "should allow settings click behavior on boolean fields (metabase#18067)",
+ { tags: "@external" },
+ () => {
+ const dialect = "mysql";
+ const TEST_TABLE = "many_data_types";
+ H.restore(`${dialect}-writable`);
+ H.resetTestTable({ type: dialect, table: TEST_TABLE });
+ cy.signInAsAdmin();
+ H.resyncDatabase({
+ dbId: WRITABLE_DB_ID,
+ tableName: TEST_TABLE,
+ tableAlias: "testTable",
+ });
+
+ cy.get<Table>("@testTable").then((testTable) => {
+ const dashboardDetails = {
+ name: "18067 dashboard",
+ };
+ const questionDetails: StructuredQuestionDetails = {
+ name: "18067 question",
+ database: WRITABLE_DB_ID,
+ query: { "source-table": testTable.id },
+ };
+ H.createQuestionAndDashboard({
+ dashboardDetails,
+ questionDetails,
+ }).then(({ body: { dashboard_id } }) => {
+ H.visitDashboard(dashboard_id);
+ });
+ });
+
+ H.editDashboard();
+
+ cy.log('Select "click behavior" option');
+ H.showDashboardCardActions();
+ cy.findByTestId("dashboardcard-actions-panel").icon("click").click();
+
+ H.sidebar().within(() => {
+ cy.findByText("Boolean").scrollIntoView().click();
+ cy.contains("Click behavior for Boolean").should("be.visible");
+ });
+ },
+ );
+});
+
+describe("issue 15993", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it("should show filters defined on a question with filter pass-thru (metabase#15993)", () => {
+ H.createQuestion({
+ name: "15993",
+ query: {
+ "source-table": ORDERS_ID,
+ },
+ }).then(({ body: { id: question1Id } }) => {
+ H.createNativeQuestion({ native: { query: "select 0" } }).then(
+ ({ body: { id: nativeId } }) => {
+ H.createDashboard().then(({ body: { id: dashboardId } }) => {
+ // Add native question to the dashboard
+ cy.request("PUT", `/api/dashboard/${dashboardId}`, {
+ dashcards: [
+ {
+ id: -1,
+ card_id: nativeId,
+ row: 0,
+ col: 0,
+ size_x: 11,
+ size_y: 8,
+ // Add click behavior to the dashboard card and point it to the question 1
+ visualization_settings: getVisualizationSettings(question1Id),
+ },
+ ],
+ });
+ H.visitDashboard(dashboardId);
+ });
+ },
+ );
+ });
+
+ // Drill-through
+ cy.findAllByRole("gridcell").contains("0").realClick();
+
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.contains("117.03").should("not.exist"); // Total for the order in which quantity wasn't 0
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("Quantity is equal to 0");
+
+ // The legacy click behavior shape doesn't match `VisualizationSettings`
+ const getVisualizationSettings = (targetId: CardId) => ({
+ column_settings: {
+ '["name","0"]': {
+ click_behavior: {
+ targetId,
+ parameterMapping: {
+ [`["dimension",["field",${ORDERS.QUANTITY},null]]`]: {
+ source: {
+ type: "column",
+ id: "0",
+ name: "0",
+ },
+ target: {
+ type: "dimension",
+ id: [`["dimension",["field",${ORDERS.QUANTITY},null]]`],
+ dimension: ["dimension", ["field", ORDERS.QUANTITY, null]],
+ },
+ id: [`["dimension",["field",${ORDERS.QUANTITY},null]]`],
+ },
+ },
+ linkType: "question",
+ type: "link",
+ },
+ },
+ },
+ });
+ });
+});
+
+describe("issue 13785", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it("should apply correct date range on a graph drill-through (metabase#13785)", () => {
+ cy.log("Create a question");
+
+ H.createQuestion({
+ name: "13785",
+ query: {
+ "source-table": REVIEWS_ID,
+ aggregation: [["count"]],
+ breakout: [["field", REVIEWS.CREATED_AT, { "temporal-unit": "month" }]],
+ },
+ display: "bar",
+ }).then(({ body: { id: QUESTION_ID } }) => {
+ H.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => {
+ cy.log("Add filter to the dashboard");
+
+ cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, {
+ parameters: [
+ {
+ id: "4ff53514",
+ name: "Date Filter",
+ slug: "date_filter",
+ type: "date/all-options",
+ },
+ ],
+ });
+
+ cy.log("Add question to the dashboard");
+ H.addOrUpdateDashboardCard({
+ card_id: QUESTION_ID,
+ dashboard_id: DASHBOARD_ID,
+ card: {
+ // Set "Click behavior"
+ visualization_settings: {
+ click_behavior: {
+ type: "crossfilter",
+ parameterMapping: {
+ "4ff53514": {
+ source: {
+ type: "column",
+ id: "CREATED_AT",
+ name: "Created At",
+ },
+ target: {
+ type: "parameter",
+ id: "4ff53514",
+ },
+ id: "4ff53514",
+ },
+ },
+ },
+ },
+ // Connect filter and card
+ parameter_mappings: [
+ {
+ parameter_id: "4ff53514",
+ card_id: QUESTION_ID,
+ target: ["dimension", ["field", REVIEWS.CREATED_AT, null]],
+ },
+ ],
+ },
+ });
+
+ H.visitDashboard(DASHBOARD_ID);
+
+ cy.intercept(
+ "POST",
+ `/api/dashboard/${DASHBOARD_ID}/dashcard/*/card/${QUESTION_ID}/query`,
+ ).as("cardQuery");
+
+ H.chartPathWithFillColor("#509EE3")
+ .eq(14) // August 2026 (Total of 12 reviews, 9 unique days)
+ .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");
+ });
+ });
+ });
+});
+
+function capitalize(string: string) {
+ return string.charAt(0).toUpperCase() + string.slice(1);
+}
+
+function checkOptionsForFilter(filter: string) {
+ cy.findByText("Available filters").parent().contains(filter).click();
+ H.selectDropdown()
+ .should("contain", "Columns")
+ .and("contain", "COUNT(*)")
+ .and("not.contain", "Dashboard filters");
+
+ // Get rid of the open popover to be able to select another filter
+ // Uses force: true because the popover is covering this text.
+ cy.findByText("Pick one or more filters to update").click({ force: true });
+}
diff --git a/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.js
index 74aedc0d7b6..b631e6b82f9 100644
--- a/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.js
+++ b/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.js
@@ -26,7 +26,9 @@ const CREATED_AT_COLUMN_SOURCE = {
id: CREATED_AT_COLUMN_ID,
name: CREATED_AT_COLUMN_NAME,
};
-const FILTER_VALUE = "123";
+const FILTER_VALUE = "Dell Adams";
+const FILTERED_POINT_COUNT = 1;
+const FILTERED_POINT_CREATED_AT = "2026-10";
const POINT_COUNT = 64;
const POINT_CREATED_AT = "2025-07";
const POINT_CREATED_AT_FORMATTED = "July 2025";
@@ -42,8 +44,15 @@ const FIRST_TAB = { id: 900, name: "first" };
const SECOND_TAB = { id: 901, name: "second" };
const THIRD_TAB = { id: 902, name: "third" };
-const { ORDERS, ORDERS_ID, PEOPLE, PRODUCTS, REVIEWS, REVIEWS_ID } =
- SAMPLE_DATABASE;
+const {
+ ORDERS,
+ ORDERS_ID,
+ PEOPLE,
+ PRODUCTS,
+ PRODUCTS_ID,
+ REVIEWS,
+ REVIEWS_ID,
+} = SAMPLE_DATABASE;
const TARGET_DASHBOARD = {
name: "Target dashboard",
@@ -117,14 +126,17 @@ const DASHBOARD_FILTER_TEXT_WITH_DEFAULT = createMockActionParameter({
default: "Hello",
});
-const URL = "https://metabase.com/";
-const URL_WITH_PARAMS = `${URL}{{${DASHBOARD_FILTER_TEXT.slug}}}/{{${COUNT_COLUMN_ID}}}/{{${CREATED_AT_COLUMN_ID}}}`;
+const URL_BASE = "https://metabase.com/";
+const URL_WITH_PARAMS = `${URL_BASE}{{${DASHBOARD_FILTER_TEXT.slug}}}/{{${COUNT_COLUMN_ID}}}/{{${CREATED_AT_COLUMN_ID}}}`;
const URL_WITH_FILLED_PARAMS = URL_WITH_PARAMS.replace(
`{{${COUNT_COLUMN_ID}}}`,
- POINT_COUNT,
+ FILTERED_POINT_COUNT,
)
- .replace(`{{${CREATED_AT_COLUMN_ID}}}`, POINT_CREATED_AT)
- .replace(`{{${DASHBOARD_FILTER_TEXT.slug}}}`, FILTER_VALUE);
+ .replace(`{{${CREATED_AT_COLUMN_ID}}}`, FILTERED_POINT_CREATED_AT)
+ .replace(
+ `{{${DASHBOARD_FILTER_TEXT.slug}}}`,
+ encodeURIComponent(FILTER_VALUE),
+ );
describe("scenarios > dashboard > dashboard cards > click behavior", () => {
beforeEach(() => {
@@ -135,17 +147,29 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
});
describe("dashcards without click behavior", () => {
- it("does not allow to set click behavior for virtual dashcards", () => {
+ it("does not allow to set click behavior for virtual and object detail dashcards", () => {
const textCard = H.getTextCardDetails({ size_y: 1 });
const headingCard = H.getHeadingCardDetails({ text: "Heading card" });
const actionCard = H.getActionCardDetails();
const linkCard = H.getLinkCardDetails();
const cards = [textCard, headingCard, actionCard, linkCard];
- H.createDashboard().then(({ body: dashboard }) => {
- H.updateDashboardCards({ dashboard_id: dashboard.id, cards });
- H.visitDashboard(dashboard.id);
- });
+ H.createQuestion(OBJECT_DETAIL_CHART).then(
+ ({ body: { id: objectDetailCardId } }) => {
+ H.createDashboard().then(({ body: dashboard }) => {
+ H.updateDashboardCards({
+ dashboard_id: dashboard.id,
+ // The card helpers count ids across test retries, so give
+ // every dashcard a unique id here
+ cards: [
+ ...cards,
+ { card_id: objectDetailCardId, row: 12, col: 0 },
+ ].map((card, index) => ({ ...card, id: -(index + 1) })),
+ });
+ H.visitDashboard(dashboard.id);
+ });
+ },
+ );
H.editDashboard();
@@ -153,37 +177,24 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
const display = card.visualization_settings.virtual_card.display;
cy.log(`does not allow to set click behavior for "${display}" card`);
- H.getDashboardCard(index).realHover().icon("click").should("not.exist");
- });
- });
-
- it("does not allow to set click behavior for object detail dashcard", () => {
- H.createQuestionAndDashboard({
- questionDetails: OBJECT_DETAIL_CHART,
- }).then(({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
+ H.getDashboardCard(index).realHover();
+ // The actions panel of a short card can be clipped above the grid
+ H.getDashboardCard(index).findByLabelText("Duplicate").should("exist");
+ H.getDashboardCard(index).icon("click").should("not.exist");
});
- H.editDashboard();
-
- H.getDashboardCard().realHover().icon("click").should("not.exist");
+ cy.log('does not allow to set click behavior for "object" card');
+ H.getDashboardCard(cards.length).realHover();
+ H.getDashboardCard(cards.length)
+ .findByLabelText("Duplicate")
+ .should("be.visible");
+ H.getDashboardCard(cards.length).icon("click").should("not.exist");
});
});
describe("line chart", () => {
const questionDetails = QUESTION_LINE_CHART;
- it("should open drill-through menu as a default click-behavior", () => {
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
- },
- );
-
- clickLineChartPoint();
- assertDrillThroughMenuOpen();
- });
-
it("should open drill-through menu for native query based dashcard", () => {
H.createNativeQuestionAndDashboard({
questionDetails: {
@@ -211,8 +222,9 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
});
clickLineChartPoint();
- // TODO: fix it, currently we drill down to the question on dot click
- // assertDrillThroughMenuOpen();
+ H.popover()
+ .should("contain", "Filter by this value")
+ .and("not.contain", "See this");
});
it("allows setting dashboard without filters as custom destination and changing it back to default click behavior", () => {
@@ -222,15 +234,23 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
});
H.createQuestionAndDashboard({ questionDetails }).then(
({ body: card }) => {
+ cy.wrap(card.dashboard_id).as("sourceDashboardId");
H.visitDashboard(card.dashboard_id);
},
);
+ cy.log("drill-through menu is the default click behavior");
+ clickLineChartPoint();
+ assertDrillThroughMenuOpen();
+
H.editDashboard();
cy.log("doesn't throw when setting default behavior (metabase#35354)");
- cy.on("uncaught:exception", (err) => {
- expect(err.name.includes("TypeError")).to.be.false;
+ const typeErrors = [];
+ cy.on("uncaught:exception", (error) => {
+ if (error.name.includes("TypeError")) {
+ typeErrors.push(error);
+ }
});
H.getDashboardCard().realHover().icon("click").click();
@@ -244,8 +264,8 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
.should("have.css", "background-color", "rgb(80, 158, 226)");
addDashboardDestination();
- cy.get("aside").findByText("Select a dashboard tab").should("not.exist");
cy.get("aside").findByText("No available targets").should("exist");
+ cy.get("aside").findByText("Select a dashboard tab").should("not.exist");
cy.get("aside").button("Done").click();
H.saveDashboard();
@@ -273,13 +293,22 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
// calls are 2 of those.
cy.get("@rootCollection").should("not.have.been.called");
cy.get("@collections").should("not.have.been.called");
+
+ cy.go("back");
+ cy.get("@sourceDashboardId").then((sourceDashboardId) => {
+ cy.location("pathname").should("eq", `/dashboard/${sourceDashboardId}`);
+ });
+ testChangingBackToDefaultBehavior();
+ cy.then(() => {
+ expect(typeErrors).to.have.length(0);
+ });
});
- it("allows setting dashboard with single parameter as custom destination", () => {
+ it("allows setting dashboard with multiple parameters as custom destination, and handles the target filters being removed (metabase#35444)", () => {
H.createDashboard(
{
...TARGET_DASHBOARD,
- parameters: [DASHBOARD_FILTER_TEXT],
+ parameters: [DASHBOARD_FILTER_TEXT, DASHBOARD_FILTER_TIME],
},
{
wrapId: true,
@@ -292,6 +321,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
card_id: ORDERS_QUESTION_ID,
parameter_mappings: [
createTextFilterMapping({ card_id: ORDERS_QUESTION_ID }),
+ createTimeFilterMapping({ card_id: ORDERS_QUESTION_ID }),
],
}),
],
@@ -300,6 +330,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
H.createQuestionAndDashboard({ questionDetails }).then(
({ body: card }) => {
+ cy.wrap(card.dashboard_id).as("sourceDashboardId");
H.visitDashboard(card.dashboard_id);
},
);
@@ -308,80 +339,65 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
H.getDashboardCard().realHover().icon("click").click();
addDashboardDestination();
+ addTextParameter();
cy.get("aside").findByText("Select a dashboard tab").should("not.exist");
cy.get("aside").findByText("No available targets").should("not.exist");
- addTextParameter();
+ addTimeParameter();
cy.get("aside").button("Done").click();
H.saveDashboard();
clickLineChartPoint();
cy.findAllByTestId("parameter-widget")
- .should("have.length", 1)
- .should("contain.text", POINT_COUNT);
+ .should("have.length", 2)
+ .should("contain.text", POINT_COUNT)
+ .should("contain.text", POINT_CREATED_AT_FORMATTED);
cy.get("@targetDashboardId").then((targetDashboardId) => {
cy.location().should(({ pathname, search }) => {
expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
expect(search).to.equal(
- `?${DASHBOARD_FILTER_TEXT.slug}=${POINT_COUNT}`,
+ `?${DASHBOARD_FILTER_TEXT.slug}=${POINT_COUNT}&${DASHBOARD_FILTER_TIME.slug}=${POINT_CREATED_AT}`,
);
});
});
- });
- it("allows setting dashboard with multiple parameters as custom destination", () => {
- H.createDashboard(
- {
- ...TARGET_DASHBOARD,
- parameters: [DASHBOARD_FILTER_TEXT, DASHBOARD_FILTER_TIME],
- },
- {
- wrapId: true,
- idAlias: "targetDashboardId",
- },
- ).then((dashboardId) => {
- cy.request("PUT", `/api/dashboard/${dashboardId}`, {
- dashcards: [
- createMockDashboardCard({
- card_id: ORDERS_QUESTION_ID,
- parameter_mappings: [
- createTextFilterMapping({ card_id: ORDERS_QUESTION_ID }),
- createTimeFilterMapping({ card_id: ORDERS_QUESTION_ID }),
- ],
- }),
- ],
+ cy.go("back");
+ assertOnSourceDashboard();
+
+ cy.log("remove the filters from the target dashboard (metabase#35444)");
+ cy.get("@targetDashboardId").then((targetDashboardId) => {
+ cy.request("PUT", `/api/dashboard/${targetDashboardId}`, {
+ parameters: [],
});
});
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
- },
+ cy.log(
+ "reload source dashboard to apply removed filter of target dashboard in the mappings",
);
+ cy.reload();
H.editDashboard();
H.getDashboardCard().realHover().icon("click").click();
- addDashboardDestination();
- cy.get("aside").findByText("Select a dashboard tab").should("not.exist");
- cy.get("aside").findByText("No available targets").should("not.exist");
- addTextParameter();
- addTimeParameter();
+
+ cy.get("aside").should("contain", "No available targets");
cy.get("aside").button("Done").click();
- H.saveDashboard();
+ H.saveDashboard({ awaitRequest: false });
+ cy.wait("@saveDashboard-getDashboardMetadata");
clickLineChartPoint();
- cy.findAllByTestId("parameter-widget")
- .should("have.length", 2)
- .should("contain.text", POINT_COUNT)
- .should("contain.text", POINT_CREATED_AT_FORMATTED);
+
+ cy.findByTestId("dashboard-header").should(
+ "contain",
+ TARGET_DASHBOARD.name,
+ );
+
+ cy.log("search shouldn't contain `undefined=`");
cy.get("@targetDashboardId").then((targetDashboardId) => {
cy.location().should(({ pathname, search }) => {
expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
- expect(search).to.equal(
- `?${DASHBOARD_FILTER_TEXT.slug}=${POINT_COUNT}&${DASHBOARD_FILTER_TIME.slug}=${POINT_CREATED_AT}`,
- );
+ expect(search).to.equal("");
});
});
});
@@ -425,7 +441,6 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
H.createQuestionAndDashboard({ questionDetails }).then(
({ body: card }) => {
H.visitDashboard(card.dashboard_id);
- cy.wrap(card.dashboard_id).as("dashboardId");
},
);
@@ -458,77 +473,6 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
});
});
- it("should show error and disable the form after target dashboard tab has been removed and there is more than 1 tab left", () => {
- const options = {
- wrapId: true,
- idAlias: "targetDashboardId",
- };
- const tabs = [FIRST_TAB, SECOND_TAB, THIRD_TAB];
-
- createDashboardWithTabsLocal({
- dashboard: TARGET_DASHBOARD,
- tabs,
- options,
- });
-
- const TAB_SLUG_MAP = {};
- tabs.forEach((tab) => {
- cy.get(`@${tab.name}-id`).then((tabId) => {
- TAB_SLUG_MAP[tab.name] = `${tabId}-${tab.name}`;
- });
- });
-
- cy.get("@targetDashboardId").then((targetDashboardId) => {
- const inexistingTabId = 999;
- const cardDetails = {
- visualization_settings: {
- click_behavior: {
- parameterMapping: {},
- targetId: targetDashboardId,
- tabId: inexistingTabId,
- linkType: "dashboard",
- type: "link",
- },
- },
- };
- H.createQuestionAndDashboard({
- questionDetails,
- cardDetails,
- }).then(({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
- });
- });
-
- H.editDashboard();
- H.getDashboardCard().realHover().icon("click").click();
-
- cy.get("aside")
- .findByText("The selected tab is no longer available")
- .should("exist");
- cy.button("Done").should("be.disabled");
-
- cy.get("aside")
- .findByLabelText("Select a dashboard tab")
- .should("not.have.value")
- .click();
- cy.findByRole("listbox").findByText(SECOND_TAB.name).click();
-
- cy.get("aside")
- .findByText("The selected tab is no longer available")
- .should("not.exist");
- cy.button("Done").should("be.enabled").click();
-
- H.saveDashboard();
-
- clickLineChartPoint();
- cy.get("@targetDashboardId").then((targetDashboardId) => {
- cy.location().should(({ pathname, search }) => {
- expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
- expect(search).to.equal(`?tab=${TAB_SLUG_MAP[SECOND_TAB.name]}`);
- });
- });
- });
-
it("should fall back to the first tab after target dashboard tab has been removed and there is only 1 tab left", () => {
H.createDashboard(TARGET_DASHBOARD, {
wrapId: true,
@@ -582,7 +526,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
});
});
- it("dashboard click behavior works without tabId previously saved", () => {
+ it("dashboard click behavior works without tabId previously saved, and shows an error after target dashboard tab has been removed and there is more than 1 tab left", () => {
const tabs = [FIRST_TAB, SECOND_TAB, THIRD_TAB];
const options = {
@@ -620,7 +564,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
cardDetails,
}).then(({ body: card }) => {
H.visitDashboard(card.dashboard_id);
- cy.wrap(card.dashboard_id).as("dashboardId");
+ cy.wrap(card).as("sourceDashcard");
});
});
@@ -645,88 +589,62 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
expect(search).to.equal(`?tab=${TAB_SLUG_MAP[FIRST_TAB.name]}`);
});
});
- });
- it("sets non-specified parameters to default values when accessed from a click action", () => {
- H.createDashboard(
- {
- ...TARGET_DASHBOARD,
- parameters: [
- DASHBOARD_FILTER_TEXT,
- DASHBOARD_FILTER_TEXT_WITH_DEFAULT,
- ],
- },
- {
- wrapId: true,
- idAlias: "targetDashboardId",
- },
- )
- .then((dashboardId) => {
- return cy
- .request("PUT", `/api/dashboard/${dashboardId}`, {
- dashcards: [
- createMockDashboardCard({
- card_id: ORDERS_QUESTION_ID,
- parameter_mappings: [
- createTextFilterMapping({ card_id: ORDERS_QUESTION_ID }),
- createTextFilterWithDefaultMapping({
- card_id: ORDERS_QUESTION_ID,
- }),
- ],
- }),
- ],
- })
- .then(() => dashboardId);
- })
- .then((dashboardId) => {
- H.visitDashboard(dashboardId);
+ cy.log("target dashboard tab has been removed, more than 1 tab left");
+ cy.get("@sourceDashcard").then((dashcard) => {
+ cy.get("@targetDashboardId").then((targetDashboardId) => {
+ const inexistingTabId = 999;
+ H.addOrUpdateDashboardCard({
+ dashboard_id: dashcard.dashboard_id,
+ card_id: dashcard.card_id,
+ card: {
+ id: dashcard.id,
+ visualization_settings: {
+ click_behavior: {
+ parameterMapping: {},
+ targetId: targetDashboardId,
+ tabId: inexistingTabId,
+ linkType: "dashboard",
+ type: "link",
+ },
+ },
+ },
+ });
+ H.visitDashboard(dashcard.dashboard_id);
});
-
- H.filterWidget().contains("Hello").click();
- H.dashboardParametersPopover().within(() => {
- H.fieldValuesCombobox().type("{backspace}World{enter}{esc}");
- cy.button("Update filter").click();
});
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
- },
- );
-
H.editDashboard();
-
H.getDashboardCard().realHover().icon("click").click();
- addDashboardDestination();
- cy.get("aside").findByText("Select a dashboard tab").should("not.exist");
- cy.get("aside").findByText("No available targets").should("not.exist");
- addTextParameter();
- cy.get("aside").button("Done").click();
- H.saveDashboard();
+ cy.get("aside")
+ .findByText("The selected tab is no longer available")
+ .should("exist");
+ cy.button("Done").should("be.disabled");
- clickLineChartPoint();
+ cy.get("aside")
+ .findByLabelText("Select a dashboard tab")
+ .should("have.value", "")
+ .click();
+ cy.findByRole("listbox").findByText(SECOND_TAB.name).click();
- cy.findAllByTestId("parameter-widget")
- .contains(DASHBOARD_FILTER_TEXT.name)
- .parent()
- .should("contain.text", POINT_COUNT);
- cy.findAllByTestId("parameter-widget")
- .contains(DASHBOARD_FILTER_TEXT_WITH_DEFAULT.name)
- .parent()
- .should("contain.text", DASHBOARD_FILTER_TEXT_WITH_DEFAULT.default);
+ cy.get("aside")
+ .findByText("The selected tab is no longer available")
+ .should("not.exist");
+ cy.button("Done").should("be.enabled").click();
+ H.saveDashboard();
+
+ clickLineChartPoint();
cy.get("@targetDashboardId").then((targetDashboardId) => {
cy.location().should(({ pathname, search }) => {
expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
- expect(search).to.equal(
- `?${DASHBOARD_FILTER_TEXT.slug}=${POINT_COUNT}&${DASHBOARD_FILTER_TEXT_WITH_DEFAULT.slug}=Hello`,
- );
+ expect(search).to.equal(`?tab=${TAB_SLUG_MAP[SECOND_TAB.name]}`);
});
});
});
- it("sets parameters with default values to the correct value when accessed via click action", () => {
+ it("sets non-specified parameters to default values and parameters with default values to the mapped value when accessed from a click action", () => {
H.createDashboard(
{
...TARGET_DASHBOARD,
@@ -761,6 +679,10 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
H.visitDashboard(dashboardId);
});
+ cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
+ "targetDashcardQuery",
+ );
+
cy.findAllByTestId("parameter-widget")
.contains(DASHBOARD_FILTER_TEXT.name)
.parent()
@@ -769,6 +691,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
H.fieldValuesCombobox().type("John Doe{enter}{esc}");
cy.button("Add filter").click();
});
+ cy.wait("@targetDashcardQuery");
cy.findAllByTestId("parameter-widget")
.contains(DASHBOARD_FILTER_TEXT_WITH_DEFAULT.name)
@@ -778,25 +701,39 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
H.fieldValuesCombobox().type("{backspace}World{enter}{esc}");
cy.button("Update filter").click();
});
+ cy.wait("@targetDashcardQuery");
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
- },
- );
+ H.createDashboardWithQuestions({
+ questions: [questionDetails, questionDetails],
+ cards: [
+ { row: 0, col: 0 },
+ { row: 0, col: 12 },
+ ],
+ }).then(({ dashboard }) => {
+ cy.wrap(dashboard.id).as("sourceDashboardId");
+ H.visitDashboard(dashboard.id);
+ });
H.editDashboard();
- H.getDashboardCard().realHover().icon("click").click();
+ H.getDashboardCard(0).realHover().icon("click").click();
addDashboardDestination();
+ addTextParameter();
cy.get("aside").findByText("Select a dashboard tab").should("not.exist");
cy.get("aside").findByText("No available targets").should("not.exist");
+ cy.get("aside").button("Done").click();
+
+ H.getDashboardCard(1).realHover().icon("click").click();
+ addDashboardDestination();
addTextWithDefaultParameter();
+ cy.get("aside").findByText("Select a dashboard tab").should("not.exist");
+ cy.get("aside").findByText("No available targets").should("not.exist");
cy.get("aside").button("Done").click();
H.saveDashboard();
- clickLineChartPoint();
+ cy.log("parameters with default values get the mapped value");
+ clickLineChartPoint({ dashcardIndex: 1 });
cy.findAllByTestId("parameter-widget")
.contains(DASHBOARD_FILTER_TEXT_WITH_DEFAULT.name)
.parent()
@@ -810,9 +747,35 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
);
});
});
+
+ cy.go("back");
+ cy.get("@sourceDashboardId").then((sourceDashboardId) => {
+ cy.location("pathname").should("eq", `/dashboard/${sourceDashboardId}`);
+ });
+
+ cy.log("non-specified parameters get their default values");
+ clickLineChartPoint({ dashcardIndex: 0 });
+
+ cy.findAllByTestId("parameter-widget")
+ .contains(DASHBOARD_FILTER_TEXT.name)
+ .parent()
+ .should("contain.text", POINT_COUNT);
+ cy.findAllByTestId("parameter-widget")
+ .contains(DASHBOARD_FILTER_TEXT_WITH_DEFAULT.name)
+ .parent()
+ .should("contain.text", DASHBOARD_FILTER_TEXT_WITH_DEFAULT.default);
+
+ cy.get("@targetDashboardId").then((targetDashboardId) => {
+ cy.location().should(({ pathname, search }) => {
+ expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
+ expect(search).to.equal(
+ `?${DASHBOARD_FILTER_TEXT.slug}=${POINT_COUNT}&${DASHBOARD_FILTER_TEXT_WITH_DEFAULT.slug}=Hello`,
+ );
+ });
+ });
});
- it("does not allow setting dashboard as custom destination if user has no permissions to it", () => {
+ it("does not allow setting dashboard or saved question as custom destination if user has no permissions to it", () => {
H.createCollection({ name: RESTRICTED_COLLECTION_NAME }).then(
({ body: restrictedCollection }) => {
cy.updateCollectionGraph({
@@ -825,6 +788,10 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
...TARGET_DASHBOARD,
collection_id: restrictedCollection.id,
});
+ H.createQuestion({
+ ...TARGET_QUESTION,
+ collection_id: restrictedCollection.id,
+ });
},
);
@@ -843,13 +810,28 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
cy.get("aside").findByText("Go to a custom destination").click();
cy.get("aside").findByText("Dashboard").click();
+ H.modal().findByText("Orders in a dashboard").should("be.visible");
+ H.modal().findByText(RESTRICTED_COLLECTION_NAME).should("not.exist");
+
+ cy.log("reset the link type and pick a saved question");
+ cy.realPress("Escape");
+ cy.get("aside")
+ .findByText("Pick a dashboard…")
+ .closest("button")
+ .parent()
+ .icon("close")
+ .click();
+ cy.get("aside").findByText("Saved question").click();
+
+ H.modal().findByText("Orders").should("be.visible");
H.modal().findByText(RESTRICTED_COLLECTION_NAME).should("not.exist");
});
- it("allows setting saved question as custom destination and changing it back to default click behavior", () => {
+ it("allows setting saved question with no, one and multiple parameters as custom destination and changing it back to default click behavior, but not updating dashboard filters if there are none", () => {
H.createQuestion(TARGET_QUESTION, { wrapId: true });
H.createQuestionAndDashboard({ questionDetails }).then(
({ body: card }) => {
+ cy.wrap(card.dashboard_id).as("sourceDashboardId");
H.visitDashboard(card.dashboard_id);
},
);
@@ -857,6 +839,11 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
H.editDashboard();
H.getDashboardCard().realHover().icon("click").click();
+ cy.log("does not allow updating dashboard filters if there are none");
+ cy.get("aside")
+ .findByText("Update a dashboard filter")
+ .invoke("css", "pointer-events")
+ .should("equal", "none");
addSavedQuestionDestination();
cy.get("aside").button("Done").click();
@@ -887,24 +874,13 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
cy.get("@collections").should("not.have.been.called");
cy.go("back");
- testChangingBackToDefaultBehavior();
- });
-
- it("allows setting saved question with single parameter as custom destination", () => {
- H.createQuestion(TARGET_QUESTION);
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
- },
- );
+ assertOnSourceDashboard();
+ cy.log("saved question with a single parameter");
H.editDashboard();
-
H.getDashboardCard().realHover().icon("click").click();
- addSavedQuestionDestination();
addSavedQuestionCreatedAtParameter();
cy.get("aside").button("Done").click();
-
H.saveDashboard();
clickLineChartPoint();
@@ -912,7 +888,6 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
"have.text",
"Created At is Jul 1–31, 2025",
);
-
cy.location("pathname").should("equal", "/question");
cy.findByTestId("app-bar").should(
"contain.text",
@@ -931,27 +906,15 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
]);
cy.go("back");
- cy.log("return to the dashboard");
- cy.go("back");
- testChangingBackToDefaultBehavior();
- });
-
- it("allows setting saved question with multiple parameters as custom destination", () => {
- H.createQuestion(TARGET_QUESTION);
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
- },
- );
+ cy.log("return to the dashboard");
+ cy.go("back");
+ assertOnSourceDashboard();
+ cy.log("saved question with multiple parameters");
H.editDashboard();
-
H.getDashboardCard().realHover().icon("click").click();
- addSavedQuestionDestination();
- addSavedQuestionCreatedAtParameter();
addSavedQuestionQuantityParameter();
cy.get("aside").button("Done").click();
-
H.saveDashboard();
clickLineChartPoint();
@@ -976,86 +939,32 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
limit: 5,
},
]);
- });
-
- it("does not allow setting saved question as custom destination if user has no permissions to it", () => {
- H.createCollection({ name: RESTRICTED_COLLECTION_NAME }).then(
- ({ body: restrictedCollection }) => {
- cy.updateCollectionGraph({
- [USER_GROUPS.COLLECTION_GROUP]: {
- [restrictedCollection.id]: "none",
- },
- });
-
- H.createQuestion({
- ...TARGET_QUESTION,
- collection_id: restrictedCollection.id,
- });
- },
- );
-
- cy.signOut();
- cy.signInAsNormalUser();
-
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
- },
- );
-
- H.editDashboard();
-
- H.getDashboardCard().realHover().icon("click").click();
- cy.get("aside").findByText("Go to a custom destination").click();
- cy.get("aside").findByText("Saved question").click();
-
- H.modal().findByText(RESTRICTED_COLLECTION_NAME).should("not.exist");
- });
-
- it("allows setting URL as custom destination and changing it back to default click behavior", () => {
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
- },
- );
-
- H.editDashboard();
-
- H.getDashboardCard().realHover().icon("click").click();
- addUrlDestination();
- H.modal().within(() => {
- cy.findByRole("textbox").type(URL);
- cy.button("Done").click();
- });
- cy.get("aside").button("Done").click();
-
- H.saveDashboard();
-
- H.onNextAnchorClick((anchor) => {
- expect(anchor).to.have.attr("href", URL);
- expect(anchor).to.have.attr("rel", "noopener");
- expect(anchor).to.have.attr("target", "_blank");
- });
- clickLineChartPoint();
+ cy.go("back");
+ cy.log("return to the dashboard");
+ cy.go("back");
+ assertOnSourceDashboard();
testChangingBackToDefaultBehavior();
});
- it("allows setting URL with parameters as custom destination", () => {
+ it("allows setting URL with and without parameters as custom destination and changing it back to default click behavior", () => {
const dashboardDetails = {
parameters: [DASHBOARD_FILTER_TEXT],
};
H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(
({ body: dashcard }) => {
- H.addOrUpdateDashboardCard({
+ H.updateDashboardCards({
dashboard_id: dashcard.dashboard_id,
- card_id: dashcard.card_id,
- card: {
- parameter_mappings: [
- createTextFilterMapping({ card_id: dashcard.card_id }),
- ],
- },
+ cards: [
+ {
+ card_id: dashcard.card_id,
+ parameter_mappings: [
+ createTextFilterMapping({ card_id: dashcard.card_id }),
+ ],
+ },
+ { card_id: dashcard.card_id, col: 12 },
+ ],
});
H.visitDashboard(dashcard.dashboard_id);
},
@@ -1080,36 +989,34 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
});
cy.get("aside").button("Done").click();
+ H.getDashboardCard(1).realHover().icon("click").click();
+ addUrlDestination();
+ H.modal().within(() => {
+ cy.findByRole("textbox").type(URL_BASE);
+ cy.button("Done").click();
+ });
+ cy.get("aside").button("Done").click();
+
H.saveDashboard();
+ cy.log("URL without parameters");
+ H.stubAnchorClick();
+ clickLineChartPoint({ dashcardIndex: 1 });
+ H.assertAnchorClicked({ href: URL_BASE });
+ cy.get("@anchorClick").invoke("resetHistory");
+
+ cy.log("URL with parameters");
cy.button(DASHBOARD_FILTER_TEXT.name).click();
H.dashboardParametersPopover().within(() => {
- cy.findByPlaceholderText("Search the list").type("Dell Adams");
+ cy.findByPlaceholderText("Search the list").type(FILTER_VALUE);
cy.button("Add filter").click();
});
- H.onNextAnchorClick((anchor) => {
- expect(anchor).to.have.attr("href", URL_WITH_FILLED_PARAMS);
- expect(anchor).to.have.attr("rel", "noopener");
- expect(anchor).to.have.attr("target", "_blank");
- });
- clickLineChartPoint();
- });
-
- it("does not allow updating dashboard filters if there are none", () => {
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
- },
- );
-
- H.editDashboard();
+ clickLineChartPoint({ dashcardIndex: 0 });
+ H.assertAnchorClicked({ href: URL_WITH_FILLED_PARAMS });
- H.getDashboardCard().realHover().icon("click").click();
- cy.get("aside")
- .findByText("Update a dashboard filter")
- .invoke("css", "pointer-events")
- .should("equal", "none");
+ H.clearFilterWidget();
+ testChangingBackToDefaultBehavior();
});
it("allows updating single dashboard filter and changing it back to default click behavior", () => {
@@ -1164,7 +1071,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
testChangingBackToDefaultBehavior();
});
- it("behavior is updated after linked dashboard filter has been removed", () => {
+ it("allows updating multiple dashboard filters and updates behavior after a linked dashboard filter has been removed", () => {
const dashboardDetails = {
parameters: [DASHBOARD_FILTER_TEXT, DASHBOARD_FILTER_TIME],
};
@@ -1201,82 +1108,58 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
H.saveDashboard();
- H.editDashboard();
- cy.findByTestId("edit-dashboard-parameters-widget-container")
- .findByText(DASHBOARD_FILTER_TEXT.name)
- .click();
- cy.get("aside").button("Remove").click();
-
- H.saveDashboard();
-
clickLineChartPoint();
cy.findAllByTestId("parameter-widget")
- .should("have.length", 1)
+ .should("have.length", 2)
+ .should("contain.text", POINT_COUNT)
.should("contain.text", POINT_CREATED_AT_FORMATTED);
cy.get("@originalPathname").then((originalPathname) => {
cy.location().should(({ pathname, search }) => {
expect(pathname).to.equal(originalPathname);
expect(search).to.equal(
- `?${DASHBOARD_FILTER_TIME.slug}=${POINT_CREATED_AT}`,
+ `?${DASHBOARD_FILTER_TEXT.slug}=${POINT_COUNT}&${DASHBOARD_FILTER_TIME.slug}=${POINT_CREATED_AT}`,
);
});
});
- H.editDashboard();
-
- H.getDashboardCard().realHover().icon("click").click();
- cy.get("aside")
- .should("not.contain.text", DASHBOARD_FILTER_TEXT.name)
- .should("not.contain.text", COUNT_COLUMN_NAME);
- });
-
- it("allows updating multiple dashboard filters", () => {
- const dashboardDetails = {
- parameters: [DASHBOARD_FILTER_TEXT, DASHBOARD_FILTER_TIME],
- };
-
- H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(
- ({ body: dashcard }) => {
- H.addOrUpdateDashboardCard({
- dashboard_id: dashcard.dashboard_id,
- card_id: dashcard.card_id,
- card: {
- parameter_mappings: [
- createTextFilterMapping({ card_id: dashcard.card_id }),
- createTimeFilterMapping({ card_id: dashcard.card_id }),
- ],
- },
- });
- H.visitDashboard(dashcard.dashboard_id);
- cy.location().then(({ pathname }) => {
- cy.wrap(pathname).as("originalPathname");
- });
- },
+ H.clearFilterWidget(0);
+ H.clearFilterWidget(1);
+ cy.location("search").should(
+ "eq",
+ `?${DASHBOARD_FILTER_TEXT.slug}=&${DASHBOARD_FILTER_TIME.slug}=`,
);
H.editDashboard();
-
- H.getDashboardCard().realHover().icon("click").click();
- cy.get("aside").findByText("Update a dashboard filter").click();
- addTextParameter();
- addTimeParameter();
- cy.get("aside").button("Done").click();
+ cy.findByTestId("edit-dashboard-parameters-widget-container")
+ .findByText(DASHBOARD_FILTER_TEXT.name)
+ .click();
+ cy.get("aside").button("Remove").click();
H.saveDashboard();
+ cy.findAllByTestId("parameter-widget")
+ .should("have.length", 1)
+ .and("contain.text", DASHBOARD_FILTER_TIME.name);
clickLineChartPoint();
cy.findAllByTestId("parameter-widget")
- .should("have.length", 2)
- .should("contain.text", POINT_COUNT)
+ .should("have.length", 1)
.should("contain.text", POINT_CREATED_AT_FORMATTED);
cy.get("@originalPathname").then((originalPathname) => {
cy.location().should(({ pathname, search }) => {
expect(pathname).to.equal(originalPathname);
expect(search).to.equal(
- `?${DASHBOARD_FILTER_TEXT.slug}=${POINT_COUNT}&${DASHBOARD_FILTER_TIME.slug}=${POINT_CREATED_AT}`,
+ `?${DASHBOARD_FILTER_TIME.slug}=${POINT_CREATED_AT}`,
);
});
});
+
+ H.editDashboard();
+
+ H.getDashboardCard().realHover().icon("click").click();
+ cy.get("aside")
+ .should("contain.text", DASHBOARD_FILTER_TIME.name)
+ .should("not.contain.text", DASHBOARD_FILTER_TEXT.name)
+ .should("not.contain.text", COUNT_COLUMN_NAME);
});
});
@@ -1286,28 +1169,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
parameters: [DASHBOARD_FILTER_TEXT],
};
- it("should open drill-through menu as a default click-behavior", () => {
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
- },
- );
-
- getTableCell(COLUMN_INDEX.COUNT).click();
- H.popover().should("contain.text", "Filter by this value");
-
- getTableCell(COLUMN_INDEX.CREATED_AT).click();
- H.popover().should("contain.text", "Filter by this date and time");
-
- H.editDashboard();
-
- H.getDashboardCard().realHover().icon("click").click();
- H.getDashboardCard()
- .button()
- .should("have.text", "Open the drill-through menu");
- });
-
- it("should allow setting dashboard and saved question as custom destination for different columns", () => {
+ it("should open drill-through menu by default and allow setting dashboard and saved question as custom destination for different columns", () => {
H.createQuestion(TARGET_QUESTION);
H.createDashboard(
{
@@ -1334,21 +1196,32 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
},
);
+ cy.log("drill-through menu is the default click behavior");
+ getTableCell(COLUMN_INDEX.COUNT).click();
+ H.popover().should("contain.text", "Filter by this value");
+
+ getTableCell(COLUMN_INDEX.CREATED_AT).click();
+ H.popover().should("contain.text", "Filter by this date and time");
+
H.editDashboard();
H.getDashboardCard().realHover().icon("click").click();
+ H.getDashboardCard()
+ .button()
+ .should("have.text", "Open the drill-through menu");
(function addCustomDashboardDestination() {
cy.log("custom destination (dashboard) behavior for 'Count' column");
+ cy.get("aside").findByText(COUNT_COLUMN_NAME).should("be.visible");
getCountToDashboardMapping().should("not.exist");
cy.get("aside").findByText(COUNT_COLUMN_NAME).click();
addDashboardDestination();
+ addTextParameter();
cy.get("aside")
.findByText("Select a dashboard tab")
.should("not.exist");
cy.get("aside").findByText("No available targets").should("not.exist");
- addTextParameter();
addTimeParameter();
customizeLinkText(`Count: {{${COUNT_COLUMN_ID}}}`);
@@ -1365,6 +1238,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
"custom destination (question) behavior for 'Created at' column",
);
+ cy.get("aside").findByText(CREATED_AT_COLUMN_NAME).should("be.visible");
getCreatedAtToQuestionMapping().should("not.exist");
cy.get("aside").findByText(CREATED_AT_COLUMN_NAME).click();
addSavedQuestionDestination();
@@ -1441,8 +1315,6 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
});
it("should allow setting dashboard tab with parameter for a column", () => {
- H.createQuestion(TARGET_QUESTION);
-
const dashboard = {
...TARGET_DASHBOARD,
parameters: [DASHBOARD_FILTER_TEXT, DASHBOARD_FILTER_TIME],
@@ -1528,26 +1400,6 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
});
it("should allow setting URL as custom destination and updating dashboard filters for different columns", () => {
- H.createQuestion(TARGET_QUESTION);
- H.createDashboard(
- {
- ...TARGET_DASHBOARD,
- parameters: [DASHBOARD_FILTER_TEXT, DASHBOARD_FILTER_TIME],
- dashcards: [
- createMockDashboardCard({
- card_id: ORDERS_QUESTION_ID,
- parameter_mappings: [
- createTextFilterMapping({ card_id: ORDERS_QUESTION_ID }),
- createTimeFilterMapping({ card_id: ORDERS_QUESTION_ID }),
- ],
- }),
- ],
- },
- {
- wrapId: true,
- idAlias: "targetDashboardId",
- },
- );
H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(
({ body: dashcard }) => {
H.addOrUpdateDashboardCard({
@@ -1574,6 +1426,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
(function addUpdateDashboardFilters() {
cy.log("update dashboard filters behavior for 'Count' column");
+ cy.get("aside").findByText(COUNT_COLUMN_NAME).should("be.visible");
getCountToDashboardFilterMapping().should("not.exist");
cy.get("aside").findByText(COUNT_COLUMN_NAME).click();
cy.get("aside").findByText("Update a dashboard filter").click();
@@ -1592,6 +1445,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
(function addCustomUrlDestination() {
cy.log("custom destination (URL) behavior for 'Created At' column");
+ cy.get("aside").findByText(CREATED_AT_COLUMN_NAME).should("be.visible");
getCreatedAtToUrlMapping().should("not.exist");
cy.get("aside").findByText(CREATED_AT_COLUMN_NAME).click();
addUrlDestination();
@@ -1648,22 +1502,19 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
cy.button(DASHBOARD_FILTER_TEXT.name).click();
H.dashboardParametersPopover().within(() => {
H.removeFieldValuesValue(0);
- cy.findByPlaceholderText("Search the list").type("Dell Adams");
+ cy.findByPlaceholderText("Search the list").type(FILTER_VALUE);
cy.button("Update filter").click();
});
- H.onNextAnchorClick((anchor) => {
- expect(anchor).to.have.attr("href", URL_WITH_FILLED_PARAMS);
- expect(anchor).to.have.attr("rel", "noopener");
- expect(anchor).to.have.attr("target", "_blank");
- });
+ H.stubAnchorClick();
getTableCell(COLUMN_INDEX.CREATED_AT)
.should("have.text", "Created at: October 2026")
.click();
+ H.assertAnchorClicked({ href: URL_WITH_FILLED_PARAMS });
})();
});
});
- describe("interactive embedding", () => {
+ describe("static embedding", () => {
const questionDetails = QUESTION_LINE_CHART;
beforeEach(() => {
@@ -1671,8 +1522,9 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
cy.intercept("GET", "/api/embed/dashboard/**/card/*").as("cardQuery");
});
- it("does not allow opening custom dashboard destination", () => {
+ it("does not allow opening custom dashboard and question destinations", () => {
const dashboardDetails = {
+ name: "Embedded dashboard",
enable_embedding: true,
embedding_params: {},
};
@@ -1682,55 +1534,12 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
...TARGET_DASHBOARD,
enable_embedding: true,
embedding_params: {},
- },
- {
- wrapId: true,
- idAlias: "targetDashboardId",
- },
- );
- cy.get("@targetDashboardId").then((targetDashboardId) => {
- H.createQuestionAndDashboard({
- questionDetails,
- dashboardDetails,
- }).then(({ body: card }) => {
- H.addOrUpdateDashboardCard({
- dashboard_id: card.dashboard_id,
- card_id: card.card_id,
- card: {
- id: card.id,
- visualization_settings: {
- click_behavior: {
- parameterMapping: {},
- targetId: targetDashboardId,
- linkType: "dashboard",
- type: "link",
- },
- },
- },
- });
-
- H.visitEmbeddedPage({
- resource: { dashboard: card.dashboard_id },
- params: {},
- });
- cy.wait("@dashboard");
- cy.wait("@cardQuery");
- });
- });
-
- cy.url().then((originalUrl) => {
- clickLineChartPoint();
- cy.url().should("eq", originalUrl);
- });
- cy.get("header").findByText(TARGET_DASHBOARD.name).should("not.exist");
- });
-
- it("does not allow opening custom question destination", () => {
- const dashboardDetails = {
- enable_embedding: true,
- embedding_params: {},
- };
-
+ },
+ {
+ wrapId: true,
+ idAlias: "targetDashboardId",
+ },
+ );
H.createQuestion(
{
...TARGET_QUESTION,
@@ -1742,72 +1551,124 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
idAlias: "targetQuestionId",
},
);
- cy.get("@targetQuestionId").then((targetQuestionId) => {
- H.createQuestionAndDashboard({
- questionDetails,
- dashboardDetails,
- }).then(({ body: card }) => {
- H.addOrUpdateDashboardCard({
- dashboard_id: card.dashboard_id,
- card_id: card.card_id,
- card: {
- id: card.id,
- visualization_settings: {
- click_behavior: {
- parameterMapping: {},
- targetId: targetQuestionId,
- linkType: "question",
- type: "link",
+
+ cy.get("@targetDashboardId").then((targetDashboardId) => {
+ cy.get("@targetQuestionId").then((targetQuestionId) => {
+ H.createDashboardWithQuestions({
+ dashboardDetails,
+ questions: [questionDetails, questionDetails],
+ cards: [
+ {
+ row: 0,
+ col: 0,
+ visualization_settings: {
+ click_behavior: {
+ parameterMapping: {},
+ targetId: targetDashboardId,
+ linkType: "dashboard",
+ type: "link",
+ },
},
},
- },
- });
-
- H.visitEmbeddedPage({
- resource: { dashboard: card.dashboard_id },
- params: {},
+ {
+ row: 0,
+ col: 12,
+ visualization_settings: {
+ click_behavior: {
+ parameterMapping: {},
+ targetId: targetQuestionId,
+ linkType: "question",
+ type: "link",
+ },
+ },
+ },
+ ],
+ }).then(({ dashboard }) => {
+ H.visitEmbeddedPage({
+ resource: { dashboard: dashboard.id },
+ params: {},
+ });
+ cy.wait("@dashboard");
+ cy.wait(["@cardQuery", "@cardQuery"]);
});
- cy.wait("@dashboard");
- cy.wait("@cardQuery");
});
});
+ cy.log("dashboard destination");
+ cy.url().then((originalUrl) => {
+ clickLineChartPoint({ dashcardIndex: 0 });
+ cy.url().should("eq", originalUrl);
+ });
+ cy.get("header").findByText(dashboardDetails.name).should("be.visible");
+ cy.get("header").findByText(TARGET_DASHBOARD.name).should("not.exist");
+
+ cy.log("question destination");
cy.url().then((originalUrl) => {
- clickLineChartPoint();
+ clickLineChartPoint({ dashcardIndex: 1 });
cy.url().should("eq", originalUrl);
});
+ cy.get("header").findByText(dashboardDetails.name).should("be.visible");
cy.get("header").findByText(TARGET_QUESTION.name).should("not.exist");
});
- it("allows opening custom URL destination with parameters", () => {
+ it("allows opening custom URL destination with parameters and updating multiple dashboard filters", () => {
const dashboardDetails = {
- parameters: [DASHBOARD_FILTER_TEXT],
+ parameters: [DASHBOARD_FILTER_TEXT, DASHBOARD_FILTER_TIME],
enable_embedding: true,
embedding_params: {
[DASHBOARD_FILTER_TEXT.slug]: "enabled",
+ [DASHBOARD_FILTER_TIME.slug]: "enabled",
},
};
+ const countParameterId = "1";
+ const createdAtParameterId = "2";
H.createQuestionAndDashboard({
questionDetails,
dashboardDetails,
}).then(({ body: dashCard }) => {
- H.addOrUpdateDashboardCard({
+ H.updateDashboardCards({
dashboard_id: dashCard.dashboard_id,
- card_id: dashCard.card_id,
- card: {
- id: dashCard.id,
- parameter_mappings: [
- createTextFilterMapping({ card_id: dashCard.card_id }),
- ],
- visualization_settings: {
- click_behavior: {
- type: "link",
- linkType: "url",
- linkTemplate: URL_WITH_PARAMS,
+ cards: [
+ {
+ card_id: dashCard.card_id,
+ parameter_mappings: [
+ createTextFilterMapping({ card_id: dashCard.card_id }),
+ createTimeFilterMapping({ card_id: dashCard.card_id }),
+ ],
+ visualization_settings: {
+ click_behavior: {
+ type: "crossfilter",
+ parameterMapping: {
+ [countParameterId]: {
+ source: COUNT_COLUMN_SOURCE,
+ target: { type: "parameter", id: countParameterId },
+ id: countParameterId,
+ },
+ [createdAtParameterId]: {
+ source: CREATED_AT_COLUMN_SOURCE,
+ target: { type: "parameter", id: createdAtParameterId },
+ id: createdAtParameterId,
+ },
+ },
+ },
},
},
- },
+ {
+ card_id: dashCard.card_id,
+ col: 12,
+ parameter_mappings: [
+ createTextFilterMapping({ card_id: dashCard.card_id }),
+ ],
+ visualization_settings: {
+ click_behavior: {
+ type: "link",
+ linkType: "url",
+ linkTemplate: URL_WITH_PARAMS,
+ },
+ },
+ },
+ ],
});
H.visitEmbeddedPage({
@@ -1815,29 +1676,37 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
params: {},
});
cy.wait("@dashboard");
- cy.wait("@cardQuery");
+ cy.wait(["@cardQuery", "@cardQuery"]);
});
+ cy.log("custom URL destination with parameters");
cy.button(DASHBOARD_FILTER_TEXT.name).click();
H.dashboardParametersPopover().within(() => {
- cy.findByPlaceholderText("Search the list").type("Dell Adams");
+ cy.findByPlaceholderText("Search the list").type(FILTER_VALUE);
cy.button("Add filter").click();
});
- H.onNextAnchorClick((anchor) => {
- expect(anchor).to.have.attr("href", URL_WITH_FILLED_PARAMS);
- expect(anchor).to.have.attr("rel", "noopener");
- expect(anchor).to.have.attr("target", "_blank");
- });
- clickLineChartPoint();
+ H.stubAnchorClick();
+ clickLineChartPoint({ dashcardIndex: 1 });
+ H.assertAnchorClicked({ href: URL_WITH_FILLED_PARAMS });
+
+ cy.log("update multiple dashboard filters");
+ H.clearFilterWidget(0);
+ cy.button(DASHBOARD_FILTER_TEXT.name).should("be.visible");
+ clickLineChartPoint({ dashcardIndex: 0 });
+ cy.findAllByTestId("parameter-widget")
+ .should("have.length", 2)
+ .should("contain.text", POINT_COUNT)
+ .should("contain.text", POINT_CREATED_AT_FORMATTED);
});
it("allows opening custom URL destination that is not a Metabase instance URL using link (metabase#33379)", () => {
- H.updateSetting("site-url", "https://localhost:4000/subpath");
+ const { host } = new URL(Cypress.config("baseUrl"));
+ H.updateSetting("site-url", `https://${host}/subpath`);
const dashboardDetails = {
enable_embedding: true,
};
- const metabaseInstanceUrl = "http://localhost:4000";
+ const metabaseInstanceUrl = `http://${host}`;
H.createQuestionAndDashboard({
questionDetails,
dashboardDetails,
@@ -1875,68 +1744,6 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
.should("be.visible");
});
- it("allows updating multiple dashboard filters", () => {
- const dashboardDetails = {
- parameters: [DASHBOARD_FILTER_TEXT, DASHBOARD_FILTER_TIME],
- enable_embedding: true,
- embedding_params: {
- [DASHBOARD_FILTER_TEXT.slug]: "enabled",
- [DASHBOARD_FILTER_TIME.slug]: "enabled",
- },
- };
- const countParameterId = "1";
- const createdAtParameterId = "2";
-
- H.createQuestionAndDashboard({
- questionDetails,
- dashboardDetails,
- }).then(({ body: dashCard }) => {
- H.addOrUpdateDashboardCard({
- dashboard_id: dashCard.dashboard_id,
- card_id: dashCard.card_id,
- card: {
- id: dashCard.id,
- parameter_mappings: [
- createTextFilterMapping({ card_id: dashCard.card_id }),
- createTimeFilterMapping({ card_id: dashCard.card_id }),
- ],
- visualization_settings: {
- click_behavior: {
- type: "crossfilter",
- parameterMapping: {
- [countParameterId]: {
- source: COUNT_COLUMN_SOURCE,
- target: { type: "parameter", id: countParameterId },
- id: countParameterId,
- },
- [createdAtParameterId]: {
- source: CREATED_AT_COLUMN_SOURCE,
- target: { type: "parameter", id: createdAtParameterId },
- id: createdAtParameterId,
- },
- },
- },
- },
- },
- });
-
- H.visitEmbeddedPage({
- resource: { dashboard: dashCard.dashboard_id },
- params: {},
- });
- cy.wait("@dashboard");
- cy.wait("@cardQuery");
- });
-
- clickLineChartPoint();
- cy.findAllByTestId("parameter-widget")
- .should("have.length", 2)
- .should("contain.text", POINT_COUNT)
- .should("contain.text", POINT_CREATED_AT_FORMATTED);
- });
- });
-
- describe("static embedding", () => {
it("should navigate to public link URL (metabase#38640)", () => {
H.createDashboard(TARGET_DASHBOARD)
.then(({ body: { id: dashboardId } }) => {
@@ -1960,7 +1767,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
click_behavior: {
type: "link",
linkType: "url",
- linkTemplate: `http://localhost:4000/public/dashboard/${uuid}`,
+ linkTemplate: `${Cypress.config("baseUrl")}/public/dashboard/${uuid}`,
},
},
},
@@ -2173,10 +1980,10 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
`Started from ${targetQuestion.name}`,
);
+ H.queryBuilderMain().findByText("No results").should("be.visible");
H.queryBuilderMain()
.findByText("There was a problem with your question")
.should("not.exist");
- H.queryBuilderMain().findByText("No results").should("be.visible");
H.openNotebook();
H.verifyNotebookQuery("Orders", [
@@ -2335,245 +2142,129 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
});
});
- it("should allow click behavior on left/top header rows on a pivot table (metabase#25203)", () => {
- const QUESTION_NAME = "Cypress Pivot Table";
- const DASHBOARD_NAME = "Pivot Table Dashboard";
- const testQuery = {
- type: "query",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- [
- "field",
- PEOPLE.SOURCE,
- { "base-type": "type/Text", "source-field": ORDERS.USER_ID },
- ],
- [
- "field",
- PRODUCTS.CATEGORY,
- { "base-type": "type/Text", "source-field": ORDERS.PRODUCT_ID },
- ],
+ it("should pass pivot headers and non-null values to custom URL click behavior (metabase#25203)", () => {
+ const pivotQuery = {
+ "source-table": ORDERS_ID,
+ aggregation: [["count"]],
+ breakout: [
+ [
+ "field",
+ PEOPLE.SOURCE,
+ { "base-type": "type/Text", "source-field": ORDERS.USER_ID },
],
- },
- database: SAMPLE_DB_ID,
+ [
+ "field",
+ PRODUCTS.CATEGORY,
+ { "base-type": "type/Text", "source-field": ORDERS.PRODUCT_ID },
+ ],
+ ],
};
- H.createQuestionAndDashboard({
- questionDetails: {
- name: QUESTION_NAME,
- query: testQuery.query,
- display: "pivot",
- },
- dashboardDetails: {
- name: DASHBOARD_NAME,
- },
- cardDetails: {
- size_x: 16,
- size_y: 8,
- },
- }).then(({ body: { dashboard_id } }) => {
- cy.wrap(dashboard_id).as("targetDashboardId");
- H.visitDashboard(dashboard_id);
- });
-
- H.editDashboard();
-
- H.getDashboardCard().realHover().icon("click").click();
- addUrlDestination();
-
- H.modal().within(() => {
- cy.get("@targetDashboardId").then((targetDashboardId) => {
- cy.findAllByRole("textbox")
- .eq(0)
- .as("urlInput")
- .type(
- `http://localhost:4000/dashboard/${targetDashboardId}?source={{source}}&category={{category}}&count={{count}}`,
- {
- parseSpecialCharSequences: false,
- },
- );
- });
- cy.button("Done").click();
- });
-
- cy.get("aside").button("Done").click();
-
- H.saveDashboard();
-
- // test top header row
- H.getDashboardCard().findByText("Doohickey").click();
- cy.get("@targetDashboardId").then((targetDashboardId) => {
- cy.location().should(({ pathname, search }) => {
- expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
- expect(search).to.equal("?category=Doohickey&count=&source=");
- });
+ H.createDashboardWithQuestions({
+ dashboardName: "Click Behavior Custom URL Dashboard",
+ questions: [
+ {
+ name: "Cypress Pivot Table",
+ query: pivotQuery,
+ display: "pivot",
+ },
+ {
+ name: "Cypress Table Pivoted",
+ query: pivotQuery,
+ display: "table",
+ },
+ {
+ name: "Orders",
+ query: {
+ "source-table": ORDERS_ID,
+ aggregation: [
+ ["sum", ["field", ORDERS.TOTAL, null]],
+ ["sum", ["field", ORDERS.DISCOUNT, null]],
+ ],
+ breakout: [
+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }],
+ ],
+ filter: ["=", ["field", ORDERS.USER_ID, null], 1],
+ },
+ display: "bar",
+ },
+ ],
+ cards: [
+ { row: 0, col: 0, size_x: 16, size_y: 8 },
+ { row: 8, col: 0, size_x: 16, size_y: 8 },
+ { row: 16, col: 0, size_x: 16, size_y: 8 },
+ ],
+ }).then(({ dashboard }) => {
+ cy.wrap(dashboard.id).as("targetDashboardId");
+ H.visitDashboard(dashboard.id);
});
- // test left header row
- H.getDashboardCard().findByText("Affiliate").click();
- cy.get("@targetDashboardId").then((targetDashboardId) => {
- cy.location().should(({ pathname, search }) => {
- expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
- expect(search).to.equal("?category=&count=&source=Affiliate");
+ const setUrl = (template) => {
+ addUrlDestination();
+ H.modal().within(() => {
+ cy.get("@targetDashboardId").then((targetDashboardId) => {
+ cy.findAllByRole("textbox")
+ .eq(0)
+ .type(
+ `${Cypress.config("baseUrl")}/dashboard/${targetDashboardId}${template}`,
+ {
+ parseSpecialCharSequences: false,
+ },
+ );
+ });
+ cy.button("Done").click();
});
- });
- });
-
- it("should allow click through on the pivot column of a regular table that has been pivoted (metabase#25203)", () => {
- const QUESTION_NAME = "Cypress Table Pivoted";
- const DASHBOARD_NAME = "Table Pivoted Dashboard";
- const testQuery = {
- type: "query",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- [
- "field",
- PEOPLE.SOURCE,
- { "base-type": "type/Text", "source-field": ORDERS.USER_ID },
- ],
- [
- "field",
- PRODUCTS.CATEGORY,
- { "base-type": "type/Text", "source-field": ORDERS.PRODUCT_ID },
- ],
- ],
- },
- database: SAMPLE_DB_ID,
+ cy.get("aside").button("Done").click();
};
- H.createQuestionAndDashboard({
- questionDetails: {
- name: QUESTION_NAME,
- query: testQuery.query,
- display: "table",
- },
- dashboardDetails: {
- name: DASHBOARD_NAME,
- },
- cardDetails: {
- size_x: 16,
- size_y: 8,
- },
- }).then(({ body: { dashboard_id } }) => {
- cy.wrap(dashboard_id).as("targetDashboardId");
- H.visitDashboard(dashboard_id);
- });
-
- H.editDashboard();
-
- H.getDashboardCard().realHover().icon("click").click();
- cy.get("aside").findByText("User → Source").click();
- addUrlDestination();
-
- H.modal().within(() => {
+ const assertLocationSearch = (expectedSearch) => {
cy.get("@targetDashboardId").then((targetDashboardId) => {
- cy.findAllByRole("textbox")
- .eq(0)
- .as("urlInput")
- .type(
- `http://localhost:4000/dashboard/${targetDashboardId}?source={{source}}`,
- {
- parseSpecialCharSequences: false,
- },
- );
- });
- cy.button("Done").click();
- });
-
- cy.get("aside").button("Done").click();
-
- H.saveDashboard();
-
- // test pivoted column
- H.getDashboardCard().findByText("Organic").click();
- cy.get("@targetDashboardId").then((targetDashboardId) => {
- cy.location().should(({ pathname, search }) => {
- expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
- expect(search).to.equal("?source=Organic");
+ cy.location().should(({ pathname, search }) => {
+ expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
+ expect(search).to.equal(expectedSearch);
+ });
});
- });
- });
-
- it("should not pass through null values to filters in custom url click behavior (metabase#25203)", () => {
- const DASHBOARD_NAME = "Click Behavior Custom URL Dashboard";
- const questionDetails = {
- name: "Orders",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [
- ["sum", ["field", ORDERS.TOTAL, null]],
- ["sum", ["field", ORDERS.DISCOUNT, null]],
- ],
- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }]],
- filter: ["=", ["field", ORDERS.USER_ID, null], 1],
- },
- display: "bar",
};
- H.createQuestionAndDashboard({
- questionDetails,
- dashboardDetails: {
- name: DASHBOARD_NAME,
- },
- cardDetails: {
- size_x: 16,
- size_y: 8,
- },
- }).then(({ body: { dashboard_id } }) => {
- cy.wrap(dashboard_id).as("targetDashboardId");
- H.visitDashboard(dashboard_id);
- });
-
H.editDashboard();
- H.getDashboardCard().realHover().icon("click").click();
- addUrlDestination();
+ H.getDashboardCard(0).realHover().icon("click").click();
+ setUrl("?source={{source}}&category={{category}}&count={{count}}");
- H.modal().within(() => {
- cy.get("@targetDashboardId").then((targetDashboardId) => {
- cy.findAllByRole("textbox")
- .eq(0)
- .as("urlInput")
- .type(
- `http://localhost:4000/dashboard/${targetDashboardId}?discount={{sum_2}}&total={{sum}}`,
- {
- parseSpecialCharSequences: false,
- },
- );
- });
- cy.button("Done").click();
- });
+ H.getDashboardCard(1).realHover().icon("click").click();
+ cy.get("aside").findByText("User → Source").click();
+ setUrl("?source={{source}}");
- cy.get("aside").button("Done").click();
+ H.getDashboardCard(2).realHover().icon("click").click();
+ setUrl("?discount={{sum_2}}&total={{sum}}");
H.saveDashboard();
- // test that normal values still work properly
- H.getDashboardCard().within(() => {
+ cy.log("pivot table: top header row");
+ H.getDashboardCard(0).findByText("Doohickey").click();
+ assertLocationSearch("?category=Doohickey&count=&source=");
+
+ cy.log("pivot table: left header row");
+ H.getDashboardCard(0).findByText("Affiliate").click();
+ assertLocationSearch("?category=&count=&source=Affiliate");
+
+ cy.log("pivoted regular table: pivot column");
+ H.getDashboardCard(1).findByText("Organic").click();
+ assertLocationSearch("?source=Organic");
+
+ cy.log("bar chart: normal values still work properly");
+ H.getDashboardCard(2).within(() => {
H.chartPathWithFillColor("#88BF4D").eq(2).click();
});
- cy.get("@targetDashboardId").then((targetDashboardId) => {
- cy.location().should(({ pathname, search }) => {
- expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
- expect(search).to.equal(
- "?discount=15.070632139056723&total=298.9195210424866",
- );
- });
- });
+ assertLocationSearch(
+ "?discount=15.070632139056723&total=298.9195210424866",
+ );
- // test that null and "empty"s do not get passed through
- H.getDashboardCard().within(() => {
+ cy.log("bar chart: null and empty values do not get passed through");
+ H.getDashboardCard(2).within(() => {
H.chartPathWithFillColor("#88BF4D").eq(1).click();
});
- cy.get("@targetDashboardId").then((targetDashboardId) => {
- cy.location().should(({ pathname, search }) => {
- expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
- expect(search).to.equal("?discount=&total=420.3189231596888");
- });
- });
+ assertLocationSearch("?discount=&total=420.3189231596888");
});
it("should navigate to correct dashboard tab via custom destination click behavior (metabase#34447 metabase#44106)", () => {
@@ -2658,82 +2349,6 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
});
});
- it("should handle redirect to a dashboard with a filter, when filter was removed (metabase#35444)", () => {
- const questionDetails = QUESTION_LINE_CHART;
- H.createDashboard(
- {
- ...TARGET_DASHBOARD,
- parameters: [DASHBOARD_FILTER_TEXT],
- },
- {
- wrapId: true,
- idAlias: "targetDashboardId",
- },
- ).then((dashboardId) => {
- cy.request("PUT", `/api/dashboard/${dashboardId}`, {
- dashcards: [
- createMockDashboardCard({
- card_id: ORDERS_QUESTION_ID,
- parameter_mappings: [
- createTextFilterMapping({ card_id: ORDERS_QUESTION_ID }),
- ],
- }),
- ],
- });
- });
-
- H.createQuestionAndDashboard({ questionDetails }).then(({ body: card }) => {
- H.visitDashboard(card.dashboard_id);
-
- H.editDashboard();
-
- H.getDashboardCard().realHover().icon("click").click();
- addDashboardDestination();
- getClickMapping("Text filter").click();
-
- H.popover().findByText("Count").click();
- H.saveDashboard();
- });
-
- cy.get("@targetDashboardId").then((targetDashboardId) => {
- cy.log("remove filter from the target dashboard");
-
- cy.request("PUT", `/api/dashboard/${targetDashboardId}`, {
- parameters: [],
- });
-
- cy.log(
- "reload source dashboard to apply removed filter of target dashboard in the mappings",
- );
-
- cy.reload();
-
- H.editDashboard();
-
- H.getDashboardCard().realHover().icon("click").click();
-
- cy.get("aside").should("contain", "No available targets");
- cy.get("aside").button("Done").click();
-
- H.saveDashboard({ awaitRequest: false });
- cy.wait("@saveDashboard-getDashboardMetadata");
-
- clickLineChartPoint();
-
- cy.findByTestId("dashboard-header").should(
- "contain",
- TARGET_DASHBOARD.name,
- );
-
- cy.log("search shouldn't contain `undefined=`");
-
- cy.location().should(({ pathname, search }) => {
- expect(pathname).to.equal(`/dashboard/${targetDashboardId}`);
- expect(search).to.equal("");
- });
- });
- });
-
it("should allow to map numeric columns to user attributes", () => {
cy.log("set user attributes");
cy.request("PUT", `/api/user/${NORMAL_USER_ID}`, {
@@ -2769,10 +2384,392 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
});
});
-const clickLineChartPoint = () => {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.cartesianChartCircle()
- .eq(POINT_INDEX)
+describe("scenarios > dashboard > dashboard cards > click behavior > native question", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it("should handle URL click through with hidden columns, pivot tables and custom formatting (metabase#13927, metabase#17920, metabase#14597)", () => {
+ const hiddenColumnQuestion = {
+ name: "13927",
+ native: { query: "SELECT PEOPLE.STATE, PEOPLE.CITY from PEOPLE;" },
+ };
+ const hiddenColumnDashcardSettings = {
+ "table.cell_column": "CITY",
+ "table.pivot_column": "STATE",
+ column_settings: {
+ '["name","CITY"]': {
+ click_behavior: {
+ type: "link",
+ linkType: "url",
+ linkTextTemplate:
+ "Click to find out which state does {{CITY}} belong to.",
+ linkTemplate: "/test/{{STATE}}",
+ },
+ },
+ },
+ "table.columns": [
+ {
+ name: "STATE",
+ fieldRef: ["field", "STATE", { "base-type": "type/Text" }],
+ enabled: false,
+ },
+ {
+ name: "CITY",
+ fieldRef: ["field", "CITY", { "base-type": "type/Text" }],
+ enabled: true,
+ },
+ ],
+ };
+
+ const pivotQuestion = {
+ name: "17920",
+ native: {
+ query:
+ "SELECT STATE, SOURCE, COUNT(*) AS CNT from PEOPLE GROUP BY STATE, SOURCE",
+ },
+ display: "table",
+ visualization_settings: {
+ "table.pivot": true,
+ "table.pivot_column": "SOURCE",
+ "table.cell_column": "CNT",
+ },
+ };
+ const pivotDashcardSettings = {
+ column_settings: {
+ [JSON.stringify(["name", "CNT"])]: {
+ click_behavior: {
+ type: "link",
+ linkType: "url",
+ linkTemplate: "/test/{{CNT}}/{{STATE}}/{{SOURCE}}",
+ },
+ },
+ },
+ };
+
+ const formattedColumnKey = JSON.stringify(["name", "MY_NUMBER"]);
+ const formattedQuestion = {
+ name: "14597",
+ native: { query: "select 111 as my_number, 'foo' as my_string" },
+ display: "table",
+ visualization_settings: {
+ column_settings: {
+ [formattedColumnKey]: {
+ number_style: "currency",
+ currency_style: "code",
+ currency_in_header: false,
+ },
+ },
+ },
+ };
+ const formattedDashcardSettings = {
+ column_settings: {
+ [formattedColumnKey]: {
+ click_behavior: {
+ type: "link",
+ linkType: "url",
+ linkTemplate: "/it/worked",
+ },
+ },
+ },
+ };
+
+ H.createNativeQuestion(hiddenColumnQuestion).then(
+ ({ body: { id: hiddenColumnQuestionId } }) => {
+ H.createNativeQuestion(pivotQuestion).then(
+ ({ body: { id: pivotQuestionId } }) => {
+ H.createNativeQuestion(formattedQuestion).then(
+ ({ body: { id: formattedQuestionId } }) => {
+ H.createDashboard().then(({ body: { id: dashboardId } }) => {
+ H.updateDashboardCards({
+ dashboard_id: dashboardId,
+ cards: [
+ {
+ card_id: hiddenColumnQuestionId,
+ row: 0,
+ col: 0,
+ size_x: 11,
+ size_y: 6,
+ visualization_settings: hiddenColumnDashcardSettings,
+ },
+ {
+ card_id: pivotQuestionId,
+ row: 0,
+ col: 12,
+ visualization_settings: pivotDashcardSettings,
+ },
+ {
+ card_id: formattedQuestionId,
+ row: 8,
+ col: 0,
+ visualization_settings: formattedDashcardSettings,
+ },
+ ],
+ });
+ H.visitDashboard(dashboardId);
+ });
+ },
+ );
+ },
+ );
+ },
+ );
+
+ cy.log("metabase#13927: insert values from a hidden column");
+ H.getDashboardCard(0)
+ .findByText("Click to find out which state does Rye belong to.")
+ .click();
+ cy.location("pathname").should("eq", "/test/CO");
+
+ cy.go("back");
+
+ cy.log("metabase#17920: insert data from the correct row of a pivot table");
+ H.getDashboardCard(1).within(() => {
+ H.tableInteractiveBody()
+ .findAllByRole("row")
+ .eq(5)
+ .findByText("18")
+ .as("targetCell");
+ });
+ // querying the element before clicking to ensure its stability
+ cy.get("@targetCell").click({ force: true });
+ cy.location("pathname").should("eq", "/test/18/CO/Organic");
+
+ cy.go("back");
+
+ cy.log("metabase#14597: keep custom formatting");
+ H.getDashboardCard(2).findByText("USD 111.00").click();
+ cy.location("pathname").should("eq", "/it/worked");
+ });
+
+ it("should handle dashboard, question and URL click through on a table, including a URL to the same dashboard (metabase#22702)", () => {
+ createQuestion((questionId) => {
+ createDashboard(
+ { dashboardName: "start dash", questionId, dashcardCount: 4 },
+ (dashboardIdA) => {
+ cy.wrap(dashboardIdA).as("dashboardIdA");
+ createDashboardWithQuestion(
+ { dashboardName: "end dash" },
+ (dashboardIdB) => {
+ cy.wrap(dashboardIdB).as("dashboardIdB");
+ H.visitDashboard(dashboardIdA);
+ },
+ );
+ },
+ );
+ });
+ cy.icon("pencil").click();
+
+ cy.log("configure clicks on MY_NUMBER to go to a dashboard");
+ H.clickBehaviorSidebar(0);
+ H.sidebar()
+ .findByText("On-click behavior for each column")
+ .parent()
+ .parent()
+ .within(() => {
+ cy.findByText("MY_NUMBER").click();
+ });
+ H.sidebar().findByText("Go to a custom destination").click();
+ H.sidebar()
+ .findByText("Link to")
+ .parent()
+ .within(() => {
+ cy.findByText("Dashboard").click();
+ });
+ H.entityPickerModal().within(() => {
+ cy.findByText("end dash").click();
+ });
+ H.sidebar()
+ .findByText("Available filters")
+ .parent()
+ .within(() => {
+ cy.findByText("My Param").click();
+ });
+ H.selectDropdown().findByText("MY_STRING").click();
+
+ cy.log("set the text template");
+ H.sidebar()
+ .findByPlaceholderText("E.x. Details for {{Column Name}}")
+ .type("text: {{my_string}}", { parseSpecialCharSequences: false });
+ H.sidebar().button("Done").click();
+
+ cy.log("configure clicks on MY_NUMBER to go to a saved question");
+ H.clickBehaviorSidebar(1).within(() => {
+ cy.findByText("MY_NUMBER").click();
+ cy.findByText("Go to a custom destination").click();
+ cy.findByText("Saved question").click();
+ });
+
+ H.modal().findByText("Orders").click();
+
+ H.sidebar().findByText("User ID").click();
+ H.popover().findByText("MY_NUMBER").click();
+
+ H.sidebar().findByText("Product → Category").click();
+ H.popover().findByText("My Param").click();
+
+ H.sidebar()
+ .findByLabelText(/Customize link text/)
+ .type("num: {{my_number}}", {
+ parseSpecialCharSequences: false,
+ });
+ H.sidebar().button("Done").click();
+
+ cy.log("configure a URL click through on the MY_NUMBER column");
+ H.clickBehaviorSidebar(2).within(() => {
+ cy.findByText("MY_NUMBER").click();
+ cy.findByText("Go to a custom destination").click();
+ cy.findByText("URL").click();
+ });
+
+ H.modal().within(() => {
+ cy.get("input").first().type("/foo/{{my_number}}/{{my_param}}", {
+ parseSpecialCharSequences: false,
+ });
+ // eslint-disable-next-line metabase/no-unsafe-element-filtering
+ cy.get("input")
+ .last()
+ .type("column value: {{my_number}}", {
+ parseSpecialCharSequences: false,
+ })
+ .blur();
+ cy.findByText("Done").click();
+ });
+ H.sidebar().button("Done").click();
+
+ cy.log("configure a URL to the same dashboard on the fourth card");
+ H.clickBehaviorSidebar(3).within(() => {
+ cy.findByText("MY_NUMBER").click();
+ cy.findByText("Go to a custom destination").click();
+ cy.findByText("URL").click();
+ });
+
+ H.modal().within(() => {
+ cy.get("@dashboardIdA").then((dashboardIdA) => {
+ cy.get("input")
+ .first()
+ .type(`/dashboard/${dashboardIdA}?my_param=Aaron Hand`, { delay: 0 });
+ });
+ // eslint-disable-next-line metabase/no-unsafe-element-filtering
+ cy.get("input").last().type("Click behavior", { delay: 0 }).blur();
+ cy.button("Done").click();
+ });
+
+ H.saveDashboard();
+
+ cy.log("dashboard click through");
+ H.getDashboardCard(0).findByText("text: foo").click();
+
+ cy.get("@dashboardIdB").then((dashboardIdB) => {
+ cy.location("pathname").should("eq", `/dashboard/${dashboardIdB}`);
+ });
+ H.dashboardHeader().findByText("end dash").should("be.visible");
+ cy.location("search").should("eq", "?my_param=foo");
+ H.filterWidget().findByText("foo");
+
+ cy.go("back");
+ cy.get("@dashboardIdA").then((dashboardIdA) => {
+ cy.location("pathname").should("eq", `/dashboard/${dashboardIdA}`);
+ });
+ cy.location("search").should("eq", "?my_param=");
+
+ cy.log("question click through");
+ setParamValue("My Param", "Widget");
+ H.getDashboardCard(1).findByText("num: 111").click();
+
+ H.queryBuilderHeader().findByText("Orders").should("be.visible");
+ cy.findByTestId("qb-filters-panel").within(() => {
+ cy.findByText("User ID is 111").should("be.visible");
+ cy.findByText("Product → Category is Widget").should("be.visible");
+ });
+ H.assertQueryBuilderRowCount(5);
+
+ cy.go("back");
+ cy.get("@dashboardIdA").then((dashboardIdA) => {
+ cy.location("pathname").should("eq", `/dashboard/${dashboardIdA}`);
+ });
+
+ cy.log("metabase#22702: open the same dashboard");
+ H.getDashboardCard(3).findByText("Click behavior").click();
+ H.filterWidget().findByText("Aaron Hand").should("be.visible");
+ cy.get("@dashboardIdA").then((dashboardIdA) => {
+ cy.location("pathname").should("eq", `/dashboard/${dashboardIdA}`);
+ });
+ cy.location("search").should("eq", "?my_param=Aaron+Hand");
+
+ H.clearFilterWidget();
+ cy.location("search").should("eq", "?my_param=");
+
+ setParamValue("My Param", "param-value");
+
+ cy.log("click value and confirm url updates");
+ H.getDashboardCard(2).findByText("column value: 111").click();
+ cy.location("pathname").should("eq", "/foo/111/param-value");
+ });
+
+ it("should not remove click behavior on 'reset to defaults' (metabase#14919)", () => {
+ const LINK_NAME = "Home";
+
+ H.createQuestion({
+ name: "14919",
+ query: { "source-table": PRODUCTS_ID },
+ }).then(({ body: { id: QUESTION_ID } }) => {
+ H.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => {
+ // Add previously added question to the dashboard
+ H.addOrUpdateDashboardCard({
+ card_id: QUESTION_ID,
+ dashboard_id: DASHBOARD_ID,
+ card: {
+ // Add click through behavior to that question
+ visualization_settings: {
+ column_settings: {
+ [`["ref",["field-id",${PRODUCTS.CATEGORY}]]`]: {
+ click_behavior: {
+ type: "link",
+ linkType: "url",
+ linkTemplate: "/",
+ linkTextTemplate: LINK_NAME,
+ },
+ },
+ },
+ },
+ },
+ });
+
+ H.visitDashboard(DASHBOARD_ID);
+ cy.icon("pencil").click();
+ // Edit "Visualization options"
+ H.showDashboardCardActions();
+ cy.icon("palette").click();
+ H.modal().within(() => {
+ cy.findByText("Reset to defaults").click();
+ cy.button("Done").click();
+ });
+ // Save the whole dashboard
+ cy.button("Save").click();
+ cy.findByText("You're editing this dashboard.").should("not.exist");
+ cy.log("Reported failing on v0.38.0 - link gets dropped");
+ cy.findByTestId("dashcard-container").findAllByText(LINK_NAME);
+ });
+ });
+ });
+});
+
+const clickLineChartPoint = ({ dashcardIndex } = {}) => {
+ if (dashcardIndex === undefined) {
+ // eslint-disable-next-line metabase/no-unsafe-element-filtering
+ H.cartesianChartCircle().eq(POINT_INDEX).as("linePoint");
+ } else {
+ H.getDashboardCard(dashcardIndex)
+ .scrollIntoView()
+ .within(() => {
+ // eslint-disable-next-line metabase/no-unsafe-element-filtering
+ H.cartesianChartCircle().eq(POINT_INDEX).as("linePoint");
+ });
+ }
+
+ cy.get("@linePoint")
/**
* calling .click() here will result in clicking both
* g.voronoi > path[POINT_INDEX]
@@ -2812,16 +2809,18 @@ const addSavedQuestionCreatedAtParameter = () => {
.findByText("Created At")
.click();
H.popover().within(() => {
+ cy.findByText(CREATED_AT_COLUMN_NAME).should("exist");
cy.findByText(COUNT_COLUMN_NAME).should("not.exist");
- cy.findByText(CREATED_AT_COLUMN_NAME).should("exist").click();
+ cy.findByText(CREATED_AT_COLUMN_NAME).click();
});
};
const addSavedQuestionQuantityParameter = () => {
cy.get("aside").findByTestId("click-mappings").findByText("Quantity").click();
H.popover().within(() => {
+ cy.findByText(COUNT_COLUMN_NAME).should("exist");
cy.findByText(CREATED_AT_COLUMN_NAME).should("not.exist");
- cy.findByText(COUNT_COLUMN_NAME).should("exist").click();
+ cy.findByText(COUNT_COLUMN_NAME).click();
});
};
@@ -2844,8 +2843,9 @@ const addTextWithDefaultParameter = () => {
const addTimeParameter = () => {
cy.get("aside").findByText(DASHBOARD_FILTER_TIME.name).click();
H.popover().within(() => {
+ cy.findByText(CREATED_AT_COLUMN_NAME).should("exist");
cy.findByText(COUNT_COLUMN_NAME).should("not.exist");
- cy.findByText(CREATED_AT_COLUMN_NAME).should("exist").click();
+ cy.findByText(CREATED_AT_COLUMN_NAME).click();
});
};
@@ -2924,6 +2924,12 @@ const assertDrillThroughMenuOpen = () => {
.and("contain", "Filter by this value");
};
+const assertOnSourceDashboard = () => {
+ cy.get("@sourceDashboardId").then((sourceDashboardId) => {
+ cy.location("pathname").should("eq", `/dashboard/${sourceDashboardId}`);
+ });
+};
+
const testChangingBackToDefaultBehavior = () => {
cy.log("allows to change click behavior back to the default");
@@ -2936,7 +2942,7 @@ const testChangingBackToDefaultBehavior = () => {
H.saveDashboard();
- clickLineChartPoint();
+ clickLineChartPoint({ dashcardIndex: 0 });
assertDrillThroughMenuOpen();
};
@@ -3208,3 +3214,79 @@ function createMultiStageQuery() {
],
};
}
+
+function createDashboardWithQuestion(
+ { dashboardName = "dashboard", dashcardCount = 1 } = {},
+ callback,
+) {
+ createQuestion((questionId) => {
+ createDashboard({ dashboardName, questionId, dashcardCount }, callback);
+ });
+}
+
+function createQuestion(callback) {
+ cy.request("POST", "/api/card", {
+ dataset_query: {
+ database: SAMPLE_DB_ID,
+ type: "native",
+ native: {
+ query: "select 111 as my_number, 'foo' as my_string",
+ },
+ },
+ display: "table",
+ visualization_settings: {},
+ name: "Question",
+ collection_id: null,
+ }).then(({ body: { id: questionId } }) => {
+ callback(questionId);
+ });
+}
+
+function createDashboard(
+ { dashboardName = "dashboard", questionId, dashcardCount = 1 },
+ callback,
+) {
+ H.createDashboard({ name: dashboardName }).then(
+ ({ body: { id: dashboardId } }) => {
+ cy.request("PUT", `/api/dashboard/${dashboardId}`, {
+ parameters: [
+ {
+ name: "My Param",
+ slug: "my_param",
+ id: "e8f79be9",
+ type: "category",
+ },
+ ],
+ });
+
+ H.updateDashboardCards({
+ dashboard_id: dashboardId,
+ cards: Array.from({ length: dashcardCount }, (_item, index) => ({
+ card_id: questionId,
+ col: (index % 2) * 12,
+ row: Math.floor(index / 2) * 8,
+ parameter_mappings: [
+ {
+ parameter_id: "e8f79be9",
+ card_id: questionId,
+ target: [
+ "dimension",
+ ["field", PEOPLE.NAME, { "source-field": ORDERS.USER_ID }],
+ ],
+ },
+ ],
+ })),
+ }).then(() => callback(dashboardId));
+ },
+ );
+}
+
+function setParamValue(paramName, text) {
+ // wait to leave editing mode and set a param value
+ cy.findByText("You're editing this dashboard.").should("not.exist");
+ cy.findByText(paramName).click();
+ H.dashboardParametersPopover().within(() => {
+ cy.findByPlaceholderText("Search the list").type(text);
+ cy.findByText("Add filter").click();
+ });
+}
diff --git a/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.js
index 54cce53eeca..1b69e1edbd5 100644
--- a/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.js
+++ b/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.js
@@ -1,5 +1,4 @@
const { H } = cy;
-import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import {
ORDERS_DASHBOARD_DASHCARD_ID,
@@ -7,15 +6,8 @@ import {
ORDERS_QUESTION_ID,
} from "e2e/support/cypress_sample_instance_data";
-const {
- ORDERS,
- ORDERS_ID,
- PRODUCTS,
- PRODUCTS_ID,
- REVIEWS,
- REVIEWS_ID,
- PEOPLE,
-} = SAMPLE_DATABASE;
+const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID, REVIEWS, REVIEWS_ID } =
+ SAMPLE_DATABASE;
describe("scenarios > dashboard > dashboard drill", () => {
beforeEach(() => {
@@ -23,285 +15,6 @@ describe("scenarios > dashboard > dashboard drill", () => {
cy.signInAsAdmin();
});
- it("should handle URL click through on a table", () => {
- createDashboardWithQuestion({}, (dashboardId) => {
- H.visitDashboard(dashboardId);
-
- cy.findByTestId("dashboard-header").icon("pencil").click();
- H.showDashboardCardActions();
- cy.findByTestId("dashboardcard-actions-panel").icon("click").click();
-
- // configure a URL click through on the "MY_NUMBER" column
- H.sidebar()
- .findByText("On-click behavior for each column")
- .parent()
- .parent()
- .within(() => cy.findByText("MY_NUMBER").click());
- cy.findByText("Go to a custom destination").click();
- cy.findByText("URL").click();
-
- // set the url and text template
- H.modal().within(() => {
- cy.get("input").first().type("/foo/{{my_number}}/{{my_param}}", {
- parseSpecialCharSequences: false,
- });
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.get("input")
- .last()
- .type("column value: {{my_number}}", {
- parseSpecialCharSequences: false,
- })
- .blur();
- cy.findByText("Done").click();
- });
-
- cy.findByTestId("edit-bar").findByText("Save").click();
-
- setParamValue("My Param", "param-value");
- // click value and confirm url updates
-
- H.getDashboardCard().findByText("column value: 111").click();
- cy.location("pathname").should("eq", "/foo/111/param-value");
- });
- });
-
- it("should insert values from hidden column on custom destination URL click through (metabase#13927)", () => {
- const questionDetails = {
- name: "13927",
- native: { query: "SELECT PEOPLE.STATE, PEOPLE.CITY from PEOPLE;" },
- };
-
- const clickBehavior = {
- "table.cell_column": "CITY",
- "table.pivot_column": "STATE",
- column_settings: {
- '["name","CITY"]': {
- click_behavior: {
- type: "link",
- linkType: "url",
- linkTextTemplate:
- "Click to find out which state does {{CITY}} belong to.",
- linkTemplate: "/test/{{STATE}}",
- },
- },
- },
- "table.columns": [
- {
- name: "STATE",
- fieldRef: ["field", "STATE", { "base-type": "type/Text" }],
- enabled: false,
- },
- {
- name: "CITY",
- fieldRef: ["field", "CITY", { "base-type": "type/Text" }],
- enabled: true,
- },
- ],
- };
-
- H.createNativeQuestionAndDashboard({ questionDetails }).then(
- ({ body: dashboardCard }) => {
- const { dashboard_id } = dashboardCard;
-
- H.editDashboardCard(dashboardCard, {
- visualization_settings: clickBehavior,
- });
-
- H.visitDashboard(dashboard_id);
- },
- );
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Click to find out which state does Rye belong to.").click();
-
- cy.log("Reported failing on v0.37.2");
- cy.location("pathname").should("eq", "/test/CO");
- });
-
- it("should insert data from the correct row in the URL for pivot tables (metabase#17920)", () => {
- const query =
- "SELECT STATE, SOURCE, COUNT(*) AS CNT from PEOPLE GROUP BY STATE, SOURCE";
- const questionSettings = {
- "table.pivot": true,
- "table.pivot_column": "SOURCE",
- "table.cell_column": "CNT",
- };
- const columnKey = JSON.stringify(["name", "CNT"]);
- const dashCardSettings = {
- column_settings: {
- [columnKey]: {
- click_behavior: {
- type: "link",
- linkType: "url",
- linkTemplate: "/test/{{CNT}}/{{STATE}}/{{SOURCE}}",
- },
- },
- },
- };
- createQuestion(
- { query, visualization_settings: questionSettings },
- (questionId) => {
- createDashboard(
- { questionId, visualization_settings: dashCardSettings },
- (dashboardIdA) => H.visitDashboard(dashboardIdA),
- );
- },
- );
-
- H.tableInteractiveBody()
- .findAllByRole("row")
- .eq(5)
- .findByText("18")
- .as("targetCell");
- // querying the element before clicking to ensure its stability
- cy.get("@targetCell").click({ force: true });
- cy.location("pathname").should("eq", "/test/18/CO/Organic");
- });
-
- it("should handle question click through on a table", () => {
- createDashboardWithQuestion({}, (dashboardId) =>
- H.visitDashboard(dashboardId),
- );
-
- cy.findByLabelText("Edit dashboard").click();
- H.showDashboardCardActions();
- cy.findByLabelText("Click behavior").click();
-
- H.sidebar().within(() => {
- // Configuring on-click behavior for MY_NUMBER column
- cy.findByText("MY_NUMBER").click();
- cy.findByText("Go to a custom destination").click();
- cy.findByText("Saved question").click();
- });
-
- H.modal().findByText("Orders").click();
-
- H.sidebar().findByText("User ID").click();
- H.popover().findByText("MY_NUMBER").click();
-
- H.sidebar().findByText("Product → Category").click();
- H.popover().findByText("My Param").click();
-
- H.sidebar()
- .findByLabelText(/Customize link text/)
- .type("num: {{my_number}}", {
- parseSpecialCharSequences: false,
- });
-
- cy.findByTestId("edit-bar").button("Save").click();
-
- // wait to leave editing mode and set a param value
- H.main().findByText("You're editing this dashboard.").should("not.exist");
- setParamValue("My Param", "Widget");
-
- // click on table value
- cy.findByTestId("dashcard").findByText("num: 111").click();
-
- H.queryBuilderHeader().findByText("Orders").should("be.visible");
- cy.findByTestId("qb-filters-panel").within(() => {
- cy.findByText("User ID is 111").should("be.visible");
- cy.findByText("Product → Category is Widget").should("be.visible");
- });
- H.assertQueryBuilderRowCount(5);
- });
-
- it("should handle dashboard click through on a table", () => {
- createQuestion({}, (questionId) => {
- createDashboard(
- { dashboardName: "start dash", questionId },
- (dashboardIdA) => {
- createDashboardWithQuestion(
- { dashboardName: "end dash" },
- (dashboardIdB) => {
- H.visitDashboard(dashboardIdA);
- },
- );
- },
- );
- });
- cy.icon("pencil").click();
- H.showDashboardCardActions();
- cy.findByTestId("dashboardcard-actions-panel").within(() => {
- cy.icon("click").click();
- });
-
- // configure clicks on "MY_NUMBER to update the param
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("On-click behavior for each column")
- .parent()
- .parent()
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- .within(() => cy.findByText("MY_NUMBER").click());
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Go to a custom destination").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Link to")
- .parent()
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- .within(() => cy.findByText("Dashboard").click());
- H.entityPickerModal().within(() => {
- cy.findByText("end dash").click();
- });
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Available filters")
- .parent()
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- .within(() => cy.findByText("My Param").click());
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- H.selectDropdown().within(() => cy.findByText("MY_STRING").click());
-
- // set the text template
- cy.findByPlaceholderText("E.x. Details for {{Column Name}}").type(
- "text: {{my_string}}",
- { parseSpecialCharSequences: false },
- );
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Save").click();
-
- // click on table value
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("text: foo").click();
-
- // check that param was set to "foo"
- cy.location("search").should("eq", "?my_param=foo");
- H.filterWidget("My Param").findByText("foo");
- });
-
- it("should open the same dashboard when a custom URL click behavior points to the same dashboard (metabase#22702)", () => {
- createDashboardWithQuestion({}, (dashboardId) => {
- H.visitDashboard(dashboardId);
- H.editDashboard();
- H.showDashboardCardActions();
- cy.findByTestId("dashboardcard-actions-panel")
- .icon("click")
- .should("be.visible")
- .click();
-
- H.sidebar().within(() => {
- cy.findByText("MY_NUMBER").click();
- cy.findByText("Go to a custom destination").click();
- cy.findByText("URL").click();
- });
-
- H.modal().within(() => {
- cy.get("input")
- .first()
- .type(`/dashboard/${dashboardId}?my_param=Aaron Hand`, { delay: 0 });
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.get("input").last().type("Click behavior", { delay: 0 }).blur();
- cy.button("Done").click();
- });
-
- H.saveDashboard();
-
- cy.findByTestId("dashcard").findByText("Click behavior").click();
- H.filterWidget("My Param").findByText("Aaron Hand").should("be.visible");
-
- cy.location("pathname").should("eq", `/dashboard/${dashboardId}`);
- cy.location("search").should("eq", "?my_param=Aaron+Hand");
- });
- });
-
describe("should pass multiple filters for numeric column on drill-through (metabase#13062)", () => {
const questionDetails = {
name: "13062Q",
@@ -358,7 +71,7 @@ describe("scenarios > dashboard > dashboard drill", () => {
);
});
- it("when clicking on the field value (metabase#13062-1)", () => {
+ 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();
@@ -373,9 +86,11 @@ describe("scenarios > dashboard > dashboard drill", () => {
.should("be.visible");
H.assertQueryBuilderRowCount(1);
- });
- it("when clicking on the card title (metabase#13062-2)", () => {
+ cy.log("when clicking on the card title (metabase#13062-2)");
+ cy.go("back");
+ H.filterWidget().findByText("2 selections").should("be.visible");
+
cy.findByTestId("dashcard").findByText(questionDetails.name).click();
cy.findByTestId("qb-filters-panel")
.findByText("Rating is equal to 2 selections")
@@ -515,89 +230,6 @@ describe("scenarios > dashboard > dashboard drill", () => {
.and("be.visible");
});
- it("should apply correct date range on a graph drill-through (metabase#13785)", () => {
- cy.log("Create a question");
-
- H.createQuestion({
- name: "13785",
- query: {
- "source-table": REVIEWS_ID,
- aggregation: [["count"]],
- breakout: [["field", REVIEWS.CREATED_AT, { "temporal-unit": "month" }]],
- },
- display: "bar",
- }).then(({ body: { id: QUESTION_ID } }) => {
- H.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => {
- cy.log("Add filter to the dashboard");
-
- cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, {
- parameters: [
- {
- id: "4ff53514",
- name: "Date Filter",
- slug: "date_filter",
- type: "date/all-options",
- },
- ],
- });
-
- cy.log("Add question to the dashboard");
- H.addOrUpdateDashboardCard({
- card_id: QUESTION_ID,
- dashboard_id: DASHBOARD_ID,
- card: {
- // Set "Click behavior"
- visualization_settings: {
- click_behavior: {
- type: "crossfilter",
- parameterMapping: {
- "4ff53514": {
- source: {
- type: "column",
- id: "CREATED_AT",
- name: "Created At",
- },
- target: {
- type: "parameter",
- id: "4ff53514",
- },
- id: "4ff53514",
- },
- },
- },
- },
- // Connect filter and card
- parameter_mappings: [
- {
- parameter_id: "4ff53514",
- card_id: QUESTION_ID,
- target: ["dimension", ["field", REVIEWS.CREATED_AT, null]],
- },
- ],
- },
- });
-
- H.visitDashboard(DASHBOARD_ID);
-
- cy.intercept(
- "POST",
- `/api/dashboard/${DASHBOARD_ID}/dashcard/*/card/${QUESTION_ID}/query`,
- ).as("cardQuery");
-
- H.chartPathWithFillColor("#509EE3")
- .eq(14) // August 2026 (Total of 12 reviews, 9 unique days)
- .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");
- });
- });
- });
-
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(
@@ -634,92 +266,6 @@ describe("scenarios > dashboard > dashboard drill", () => {
);
});
- it("should not hide custom formatting when click behavior is enabled (metabase#14597)", () => {
- const columnKey = JSON.stringify(["name", "MY_NUMBER"]);
- const questionSettings = {
- column_settings: {
- [columnKey]: {
- number_style: "currency",
- currency_style: "code",
- currency_in_header: false,
- },
- },
- };
- const dashCardSettings = {
- column_settings: {
- [columnKey]: {
- click_behavior: {
- type: "link",
- linkType: "url",
- linkTemplate: "/it/worked",
- },
- },
- },
- };
-
- createQuestion(
- { visualization_settings: questionSettings },
- (questionId) => {
- createDashboard(
- { questionId, visualization_settings: dashCardSettings },
- (dashboardIdA) => H.visitDashboard(dashboardIdA),
- );
- },
- );
-
- // formatting works, so we see "USD" in the table
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("USD 111.00").click();
- cy.location("pathname").should("eq", "/it/worked");
- });
-
- it("should not remove click behavior on 'reset to defaults' (metabase#14919)", () => {
- const LINK_NAME = "Home";
-
- H.createQuestion({
- name: "14919",
- query: { "source-table": PRODUCTS_ID },
- }).then(({ body: { id: QUESTION_ID } }) => {
- H.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => {
- // Add previously added question to the dashboard
- H.addOrUpdateDashboardCard({
- card_id: QUESTION_ID,
- dashboard_id: DASHBOARD_ID,
- card: {
- // Add click through behavior to that question
- visualization_settings: {
- column_settings: {
- [`["ref",["field-id",${PRODUCTS.CATEGORY}]]`]: {
- click_behavior: {
- type: "link",
- linkType: "url",
- linkTemplate: "/",
- linkTextTemplate: LINK_NAME,
- },
- },
- },
- },
- },
- });
-
- H.visitDashboard(DASHBOARD_ID);
- cy.icon("pencil").click();
- // Edit "Visualization options"
- H.showDashboardCardActions();
- cy.icon("palette").click();
- H.modal().within(() => {
- cy.findByText("Reset to defaults").click();
- cy.button("Done").click();
- });
- // Save the whole dashboard
- cy.button("Save").click();
- cy.findByText("You're editing this dashboard.").should("not.exist");
- cy.log("Reported failing on v0.38.0 - link gets dropped");
- cy.findByTestId("dashcard-container").findAllByText(LINK_NAME);
- });
- });
- });
-
it('should drill-through on PK/FK to the "object detail" when filtered by explicit joined column (metabase#15331)', () => {
cy.intercept("POST", "/api/dataset").as("dataset");
@@ -916,7 +462,7 @@ describe("scenarios > dashboard > dashboard drill", () => {
H.visitDashboard(ORDERS_DASHBOARD_ID);
});
- it("should correctly drill-through on Orders filter (metabase#11503-1)", () => {
+ it("should correctly drill-through on Orders and on Products filter (metabase#11503)", () => {
setFilterValue(ordersIdFilter.name);
drillThroughCardTitle("Orders");
@@ -930,9 +476,14 @@ describe("scenarios > dashboard > dashboard drill", () => {
H.assertQueryBuilderRowCount(2);
postDrillAssertion("ID is 2 selections");
- });
- it("should correctly drill-through on Products filter (metabase#11503-2)", () => {
+ cy.log(
+ "should correctly drill-through on Products filter (metabase#11503-2)",
+ );
+ cy.go("back");
+ H.filterWidget().eq(0).should("contain", "2 selections");
+ H.clearFilterWidget(0);
+ H.filterWidget().eq(0).should("contain", ordersIdFilter.name);
setFilterValue(productsIdFilter.name);
drillThroughCardTitle("Orders");
@@ -968,81 +519,6 @@ describe("scenarios > dashboard > dashboard drill", () => {
});
});
-function createDashboardWithQuestion(
- { dashboardName = "dashboard" } = {},
- callback,
-) {
- createQuestion({}, (questionId) => {
- createDashboard({ dashboardName, questionId }, callback);
- });
-}
-
-function createQuestion(options, callback) {
- cy.request("POST", "/api/card", {
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "native",
- native: {
- query: options.query || "select 111 as my_number, 'foo' as my_string",
- },
- },
- display: "table",
- visualization_settings: options.visualization_settings || {},
- name: "Question",
- collection_id: null,
- }).then(({ body: { id: questionId } }) => {
- callback(questionId);
- });
-}
-
-function createDashboard(
- { dashboardName = "dashboard", questionId, visualization_settings },
- callback,
-) {
- H.createDashboard({ name: dashboardName }).then(
- ({ body: { id: dashboardId } }) => {
- cy.request("PUT", `/api/dashboard/${dashboardId}`, {
- parameters: [
- {
- name: "My Param",
- slug: "my_param",
- id: "e8f79be9",
- type: "category",
- },
- ],
- });
-
- H.addOrUpdateDashboardCard({
- card_id: questionId,
- dashboard_id: dashboardId,
- card: {
- parameter_mappings: [
- {
- parameter_id: "e8f79be9",
- card_id: questionId,
- target: [
- "dimension",
- ["field", PEOPLE.NAME, { "source-field": ORDERS.USER_ID }],
- ],
- },
- ],
- visualization_settings,
- },
- }).then(() => callback(dashboardId));
- },
- );
-}
-
-function setParamValue(paramName, text) {
- // wait to leave editing mode and set a param value
- cy.findByText("You're editing this dashboard.").should("not.exist");
- cy.findByText(paramName).click();
- H.dashboardParametersPopover().within(() => {
- cy.findByPlaceholderText("Search the list").type(text);
- cy.findByText("Add filter").click();
- });
-}
-
function drillThroughCardTitle(title) {
cy.findByTestId("legend-caption").contains(title).click();
cy.contains(`Started from ${title}`);
diff --git a/e2e/test/scenarios/dashboard/dashcard-reproductions.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-reproductions.cy.spec.js
index ac466e980ce..a6c226a412b 100644
--- a/e2e/test/scenarios/dashboard/dashcard-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/dashboard/dashcard-reproductions.cy.spec.js
@@ -1,476 +1,9 @@
const { H } = cy;
-import { SAMPLE_DB_ID, WRITABLE_DB_ID } from "e2e/support/cypress_data";
+import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
import { createMockParameter } from "metabase-types/api/mocks";
-const { ORDERS, ORDERS_ID, REVIEWS, PRODUCTS, PRODUCTS_ID, REVIEWS_ID } =
- SAMPLE_DATABASE;
-
-describe("issue 18067", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it(
- "should allow settings click behavior on boolean fields (metabase#18067)",
- { tags: "@external" },
- () => {
- const dialect = "mysql";
- const TEST_TABLE = "many_data_types";
- H.restore(`${dialect}-writable`);
- H.resetTestTable({ type: dialect, table: TEST_TABLE });
- cy.signInAsAdmin();
- H.resyncDatabase({
- dbId: WRITABLE_DB_ID,
- tableName: TEST_TABLE,
- tableAlias: "testTable",
- });
-
- cy.get("@testTable").then((testTable) => {
- const dashboardDetails = {
- name: "18067 dashboard",
- };
- const questionDetails = {
- name: "18067 question",
- database: WRITABLE_DB_ID,
- query: { "source-table": testTable.id },
- };
- H.createQuestionAndDashboard({
- dashboardDetails,
- questionDetails,
- }).then(({ body: { dashboard_id } }) => {
- H.visitDashboard(dashboard_id);
- });
- });
-
- H.editDashboard();
-
- cy.log('Select "click behavior" option');
- H.showDashboardCardActions();
- cy.findByTestId("dashboardcard-actions-panel").icon("click").click();
-
- H.sidebar().within(() => {
- cy.findByText("Boolean").scrollIntoView().click();
- cy.contains("Click behavior for Boolean").should("be.visible");
- });
- },
- );
-});
-
-describe("issue 15993", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should show filters defined on a question with filter pass-thru (metabase#15993)", () => {
- H.createQuestion({
- name: "15993",
- query: {
- "source-table": ORDERS_ID,
- },
- }).then(({ body: { id: question1Id } }) => {
- H.createNativeQuestion({ native: { query: "select 0" } }).then(
- ({ body: { id: nativeId } }) => {
- H.createDashboard().then(({ body: { id: dashboardId } }) => {
- // Add native question to the dashboard
- H.addOrUpdateDashboardCard({
- dashboard_id: dashboardId,
- card_id: nativeId,
- card: {
- // Add click behavior to the dashboard card and point it to the question 1
- visualization_settings: getVisualizationSettings(question1Id),
- },
- });
- H.visitDashboard(dashboardId);
- });
- },
- );
- });
-
- // Drill-through
- cy.findAllByRole("gridcell").contains("0").realClick();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("117.03").should("not.exist"); // Total for the order in which quantity wasn't 0
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Quantity is equal to 0");
-
- const getVisualizationSettings = (targetId) => ({
- column_settings: {
- '["name","0"]': {
- click_behavior: {
- targetId,
- parameterMapping: {
- [`["dimension",["field",${ORDERS.QUANTITY},null]]`]: {
- source: {
- type: "column",
- id: "0",
- name: "0",
- },
- target: {
- type: "dimension",
- id: [`["dimension",["field",${ORDERS.QUANTITY},null]]`],
- dimension: ["dimension", ["field", ORDERS.QUANTITY, null]],
- },
- id: [`["dimension",["field",${ORDERS.QUANTITY},null]]`],
- },
- },
- linkType: "question",
- type: "link",
- },
- },
- },
- });
- });
-});
-
-describe("issue 16334", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/dataset").as("dataset");
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashcardQuery",
- );
- });
-
- it("should not change the visualization type in a targetted question with mapped filter (metabase#16334)", () => {
- // Question 2, that we're adding to the dashboard
- const questionDetails = {
- query: {
- "source-table": REVIEWS_ID,
- },
- };
-
- H.createQuestion({
- name: "16334",
- query: {
- "source-table": PRODUCTS_ID,
- aggregation: [["count"]],
- breakout: [["field", PRODUCTS.CATEGORY, null]],
- },
- display: "pie",
- }).then(({ body: { id: question1Id } }) => {
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: { id, card_id, dashboard_id } }) => {
- H.addOrUpdateDashboardCard({
- dashboard_id,
- card_id,
- card: {
- id,
- visualization_settings: getVisualizationSettings(question1Id),
- },
- });
-
- H.visitDashboard(dashboard_id);
- cy.wait("@dashcardQuery");
- },
- );
- });
-
- cy.findAllByTestId("cell-data").contains("5").first().click();
- cy.wait("@dataset");
-
- // Make sure filter is set
- cy.findByTestId("qb-filters-panel").should(
- "contain.text",
- "Rating is equal to 5",
- );
-
- // Make sure it's connected to the original question
- cy.findByTestId("app-bar").should("contain.text", "Started from 16334");
-
- // Make sure the original visualization didn't change
- H.pieSlices().should("have.length", 2);
-
- const getVisualizationSettings = (targetId) => ({
- column_settings: {
- [`["ref",["field",${REVIEWS.RATING},null]]`]: {
- click_behavior: {
- targetId,
- parameterMapping: {
- [`["dimension",["field",${PRODUCTS.RATING},null],{"stage-number":0}]`]:
- {
- source: {
- type: "column",
- id: "RATING",
- name: "Rating",
- },
- target: {
- type: "dimension",
- id: [
- `["dimension",["field",${PRODUCTS.RATING},null],{"stage-number":0}]`,
- ],
- dimension: [
- "dimension",
- ["field", PRODUCTS.RATING, null],
- { "stage-number": 0 },
- ],
- },
- id: [
- `["dimension",["field",${PRODUCTS.RATING},null],{"stage-number":0}]`,
- ],
- },
- },
- linkType: "question",
- type: "link",
- },
- },
- },
- });
- });
-});
-
-describe("issue 17160", () => {
- const TARGET_DASHBOARD_NAME = "Target dashboard";
- const CATEGORY_FILTER_PARAMETER_ID = "7c9ege62";
-
- function assertMultipleValuesFilterState() {
- cy.findByText("2 selections").click();
-
- cy.findByLabelText("Doohickey").should("be.checked");
- cy.findByLabelText("Gadget").should("be.checked");
- }
-
- function setup() {
- H.createNativeQuestion({
- name: "17160Q",
- native: {
- query: "SELECT * FROM products WHERE {{CATEGORY}}",
- "template-tags": {
- CATEGORY: {
- id: "6b8b10ef-0104-1047-1e1b-2492d5954322",
- name: "CATEGORY",
- display_name: "CATEGORY",
- type: "dimension",
- dimension: ["field", PRODUCTS.CATEGORY, null],
- "widget-type": "category",
- default: null,
- },
- },
- },
- }).then(({ body: { id: questionId } }) => {
- // Share the question
- cy.request("POST", `/api/card/${questionId}/public_link`);
-
- H.createDashboard({ name: "17160D" }).then(
- ({ body: { id: dashboardId } }) => {
- // Share the dashboard
- cy.request("POST", `/api/dashboard/${dashboardId}/public_link`).then(
- ({ body: { uuid } }) => {
- cy.wrap(uuid).as("sourceDashboardUUID");
- },
- );
- cy.wrap(dashboardId).as("sourceDashboardId");
-
- // Add the question to the dashboard
- H.addOrUpdateDashboardCard({
- dashboard_id: dashboardId,
- card_id: questionId,
- }).then(({ body: { id: dashCardId } }) => {
- // Add dashboard filter
- cy.request("PUT", `/api/dashboard/${dashboardId}`, {
- parameters: [
- {
- default: ["Doohickey", "Gadget"],
- id: CATEGORY_FILTER_PARAMETER_ID,
- name: "Category",
- slug: "category",
- sectionId: "string",
- type: "string/=",
- },
- ],
- });
-
- createTargetDashboard().then((targetDashboardId) => {
- cy.wrap(targetDashboardId).as("targetDashboardId");
-
- // Create a click behaviour for the question card
- cy.request("PUT", `/api/dashboard/${dashboardId}`, {
- dashcards: [
- {
- id: dashCardId,
- card_id: questionId,
- row: 0,
- col: 0,
- size_x: 16,
- size_y: 10,
- parameter_mappings: [
- {
- parameter_id: CATEGORY_FILTER_PARAMETER_ID,
- card_id: 4,
- target: ["dimension", ["template-tag", "CATEGORY"]],
- },
- ],
- visualization_settings: getVisualSettingsWithClickBehavior(
- questionId,
- targetDashboardId,
- ),
- },
- ],
- });
- });
- });
- },
- );
- });
- }
-
- function getVisualSettingsWithClickBehavior(questionTarget, dashboardTarget) {
- return {
- column_settings: {
- '["name","ID"]': {
- click_behavior: {
- targetId: questionTarget,
- parameterMapping: {
- "6b8b10ef-0104-1047-1e1b-2492d5954322": {
- source: {
- type: "parameter",
- id: CATEGORY_FILTER_PARAMETER_ID,
- name: "Category",
- },
- target: {
- type: "variable",
- id: "CATEGORY",
- },
- id: "6b8b10ef-0104-1047-1e1b-2492d5954322",
- },
- },
- linkType: "question",
- type: "link",
- linkTextTemplate: "click-behavior-question-label",
- },
- },
-
- '["name","EAN"]': {
- click_behavior: {
- targetId: dashboardTarget,
- parameterMapping: {
- dd19ec03: {
- source: {
- type: "parameter",
- id: CATEGORY_FILTER_PARAMETER_ID,
- name: "Category",
- },
- target: {
- type: "parameter",
- id: "dd19ec03",
- },
- id: "dd19ec03",
- },
- },
- linkType: "dashboard",
- type: "link",
- linkTextTemplate: "click-behavior-dashboard-label",
- },
- },
- },
- };
- }
-
- function createTargetDashboard() {
- return H.createQuestionAndDashboard({
- dashboardDetails: {
- name: TARGET_DASHBOARD_NAME,
- },
- questionDetails: {
- query: {
- "source-table": PRODUCTS_ID,
- },
- },
- }).then(({ body: { id, card_id, dashboard_id } }) => {
- // Share the dashboard
- cy.request("POST", `/api/dashboard/${dashboard_id}/public_link`);
-
- // Add a filter
- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {
- parameters: [
- {
- name: "Category",
- slug: "category",
- id: "dd19ec03",
- type: "string/=",
- sectionId: "string",
- },
- ],
- });
-
- // Resize the question card and connect the filter to it
- return cy
- .request("PUT", `/api/dashboard/${dashboard_id}`, {
- dashcards: [
- {
- id,
- card_id,
- row: 0,
- col: 0,
- size_x: 16,
- size_y: 10,
- parameter_mappings: [
- {
- parameter_id: "dd19ec03",
- card_id,
- target: ["dimension", ["field", PRODUCTS.CATEGORY, null]],
- },
- ],
- },
- ],
- })
- .then(() => {
- return dashboard_id;
- });
- });
- }
-
- function visitSourceDashboard() {
- cy.get("@sourceDashboardId").then((id) => {
- H.visitDashboard(id);
- });
- }
-
- beforeEach(() => {
- cy.intercept("POST", "/api/card/*/query").as("cardQuery");
-
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should pass multiple filter values to questions and dashboards (metabase#17160-1)", () => {
- setup();
-
- // 1. Check click behavior connected to a question
- visitSourceDashboard();
-
- cy.findAllByText("click-behavior-question-label").eq(0).click();
- cy.wait("@cardQuery");
-
- cy.url().should("include", "/question");
-
- assertMultipleValuesFilterState();
-
- // 2. Check click behavior connected to a dashboard
- visitSourceDashboard();
-
- cy.get("@targetDashboardId").then((id) => {
- cy.intercept("POST", `/api/dashboard/${id}/dashcard/*/card/*/query`).as(
- "targetDashcardQuery",
- );
-
- cy.findAllByText("click-behavior-dashboard-label").eq(0).click();
- cy.wait("@targetDashcardQuery");
- });
-
- cy.url().should("include", "/dashboard");
- cy.location("search").should("eq", "?category=Doohickey&category=Gadget");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText(TARGET_DASHBOARD_NAME);
-
- assertMultipleValuesFilterState();
- });
-});
+const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
describe("issue 18454", () => {
const CARD_DESCRIPTION = "CARD_DESCRIPTION";
@@ -506,90 +39,6 @@ describe("issue 18454", () => {
});
});
-describe("issue 23137", () => {
- const GAUGE_QUESTION_DETAILS = {
- display: "gauge",
- query: {
- "source-table": REVIEWS_ID,
- aggregation: [["count"]],
- },
- };
-
- const PROGRESS_QUESTION_DETAILS = {
- display: "progress",
- query: {
- "source-table": REVIEWS_ID,
- aggregation: [["count"]],
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/card/*/query").as("cardQuery");
- });
-
- it("should navigate to a target from a gauge card (metabase#23137)", () => {
- const target_id = ORDERS_QUESTION_ID;
-
- H.createQuestionAndDashboard({
- questionDetails: GAUGE_QUESTION_DETAILS,
- }).then(({ body: { id, card_id, dashboard_id } }) => {
- H.addOrUpdateDashboardCard({
- card_id,
- dashboard_id,
- card: {
- id,
- visualization_settings: {
- click_behavior: {
- type: "link",
- linkType: "question",
- targetId: target_id,
- parameterMapping: {},
- },
- },
- },
- });
-
- H.visitDashboard(dashboard_id);
- });
-
- cy.findByTestId("gauge-arc-1").click();
- cy.wait("@cardQuery");
- H.queryBuilderHeader().findByDisplayValue("Orders").should("be.visible");
- });
-
- it("should navigate to a target from a progress card (metabase#23137)", () => {
- const target_id = ORDERS_QUESTION_ID;
-
- H.createQuestionAndDashboard({
- questionDetails: PROGRESS_QUESTION_DETAILS,
- }).then(({ body: { id, card_id, dashboard_id } }) => {
- H.addOrUpdateDashboardCard({
- card_id,
- dashboard_id,
- card: {
- id,
- visualization_settings: {
- click_behavior: {
- type: "link",
- linkType: "question",
- targetId: target_id,
- parameterMapping: {},
- },
- },
- },
- });
-
- H.visitDashboard(dashboard_id);
- });
-
- cy.findByTestId("progress-bar").click();
- cy.wait("@cardQuery");
- H.queryBuilderHeader().findByDisplayValue("Orders").should("be.visible");
- });
-});
-
// Tests for issues 27020 and 27105 (static-viz rendering with date formatting options)
// have been moved to backend tests in metabase.channel.render.card-test
@@ -1223,84 +672,6 @@ describe("issue 48878", () => {
}
});
-describe("issue 46318", () => {
- const query = `SELECT 'group_1' AS main_group, 'sub_group_1' AS sub_group, 111 AS value_sum, 'group_1__sub_group_1' AS group_name
-UNION ALL
-SELECT 'group_1', 'sub_group_2', 68, 'group_1__sub_group_2'
-UNION ALL
-SELECT 'group_2', 'sub_group_1', 79, 'group_2__sub_group_1'
-UNION ALL
-SELECT 'group_2', 'sub_group_2', 52, 'group_2__sub_group_2';
-`;
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createNativeQuestionAndDashboard({
- questionDetails: {
- name: "46318",
- native: { query },
- display: "row",
- visualization_settings: {
- "graph.dimensions": ["MAIN_GROUP", "SUB_GROUP"],
- "graph.series_order_dimension": null,
- "graph.series_order": null,
- "graph.metrics": ["VALUE_SUM"],
- },
- },
- }).then((response) => {
- H.visitDashboard(response.body.dashboard_id);
- });
-
- H.editDashboard();
- H.getDashboardCard().realHover().icon("click").click();
- cy.get("aside").within(() => {
- cy.findByText("Go to a custom destination").click();
- cy.findByText("URL").click();
- });
- H.modal().within(() => {
- cy.findByPlaceholderText("e.g. http://acme.com/id/{{user_id}}").type(
- "http://localhost:4000/?q={{group_name}}",
- { parseSpecialCharSequences: false },
- );
- cy.button("Done").click();
- });
- H.saveDashboard();
- });
-
- it("passes values from unused columns of row visualization to click behavior (metabase#46318)", () => {
- cy.findAllByRole("graphics-symbol").eq(0).click();
- cy.location("href").should(
- "eq",
- "http://localhost:4000/?q=group_1__sub_group_1",
- );
-
- cy.go("back");
-
- cy.findAllByRole("graphics-symbol").eq(2).click(); // intentionally eq(2), not eq(1) - that's how row viz works
- cy.location("href").should(
- "eq",
- "http://localhost:4000/?q=group_1__sub_group_2",
- );
-
- cy.go("back");
-
- cy.findAllByRole("graphics-symbol").eq(1).click(); // intentionally eq(1), not eq(2) - that's how row viz works
- cy.location("href").should(
- "eq",
- "http://localhost:4000/?q=group_2__sub_group_1",
- );
- cy.go("back");
-
- cy.findAllByRole("graphics-symbol").eq(3).click();
- cy.location("href").should(
- "eq",
- "http://localhost:4000/?q=group_2__sub_group_2",
- );
- });
-});
-
describe("issue 67432", () => {
beforeEach(() => {
H.restore();