From c3e8a9c9287c6fb3b19a50109441826de369118a Mon Sep 17 00:00:00 2001
From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
Date: Fri, 6 Aug 2021 14:33:18 +0200
Subject: [PATCH] #17212 Repro: Not possible to apply dashboard ID filter to a
 nested QB question (#17343)

* Add sane defaults to the card size in `createQuestionAndDashboard` custom command

* Add repro for #17212
---
 .../composite/createQuestionAndDashboard.js   |  3 ++
 .../reproductions/17212.cy.spec.js            | 53 +++++++++++++++++++
 2 files changed, 56 insertions(+)
 create mode 100644 frontend/test/metabase/scenarios/dashboard-filters/reproductions/17212.cy.spec.js

diff --git a/frontend/test/__support__/e2e/commands/api/composite/createQuestionAndDashboard.js b/frontend/test/__support__/e2e/commands/api/composite/createQuestionAndDashboard.js
index 9575273dee2..78dfe145e0c 100644
--- a/frontend/test/__support__/e2e/commands/api/composite/createQuestionAndDashboard.js
+++ b/frontend/test/__support__/e2e/commands/api/composite/createQuestionAndDashboard.js
@@ -6,6 +6,9 @@ Cypress.Commands.add(
         ({ body: { id: dashboardId } }) => {
           cy.request("POST", `/api/dashboard/${dashboardId}/cards`, {
             cardId: questionId,
+            // Add sane defaults for the dashboard card size
+            sizeX: 8,
+            sizeY: 6,
           });
         },
       );
diff --git a/frontend/test/metabase/scenarios/dashboard-filters/reproductions/17212.cy.spec.js b/frontend/test/metabase/scenarios/dashboard-filters/reproductions/17212.cy.spec.js
new file mode 100644
index 00000000000..89f76411496
--- /dev/null
+++ b/frontend/test/metabase/scenarios/dashboard-filters/reproductions/17212.cy.spec.js
@@ -0,0 +1,53 @@
+import {
+  restore,
+  editDashboard,
+  setFilter,
+  popover,
+} from "__support__/e2e/cypress";
+
+import { SAMPLE_DATASET } from "__support__/e2e/cypress_sample_dataset";
+
+const { PRODUCTS_ID } = SAMPLE_DATASET;
+
+const baseQuestion = {
+  query: { "source-table": PRODUCTS_ID },
+};
+
+describe.skip("issue 17212", () => {
+  beforeEach(() => {
+    restore();
+    cy.signInAsAdmin();
+
+    cy.createQuestion(baseQuestion).then(({ body: { id: baseQuestionId } }) => {
+      const questionDetails = {
+        query: { "source-table": `card__${baseQuestionId}` },
+      };
+
+      cy.createQuestionAndDashboard({ questionDetails }).then(
+        ({ body: { card_id, dashboard_id } }) => {
+          cy.intercept("POST", `/api/card/${card_id}/query`).as("cardQuery");
+
+          cy.visit(`/dashboard/${dashboard_id}`);
+
+          cy.wait("@cardQuery");
+        },
+      );
+    });
+  });
+
+  it("should be able to add ID dashboard filter to the nested question (metabase#17212)", () => {
+    editDashboard();
+
+    setFilter("ID");
+
+    cy.findByText("No valid fields").should("not.exist");
+
+    cy.findByText("Column to filter on")
+      .next("a")
+      .click();
+
+    popover()
+      .contains("ID")
+      .click();
+  });
+});
-- 
GitLab