From f285ae891cb0a61dae8152b7e62703acc5908c93 Mon Sep 17 00:00:00 2001
From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
Date: Wed, 4 Nov 2020 21:00:42 +0100
Subject: [PATCH] Repro for #13626: Pie chart shows spinner for `0` or `null`
 [ci skip] (#13673)

* Add repro for #13626 [ci skip]

Note: Once this issue is fixed, add a positive assertion to the Cypress test.
---
 .../scenarios/question/nulls.cy.spec.js       | 81 +++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/frontend/test/metabase/scenarios/question/nulls.cy.spec.js b/frontend/test/metabase/scenarios/question/nulls.cy.spec.js
index 894b36096a9..b692df40eca 100644
--- a/frontend/test/metabase/scenarios/question/nulls.cy.spec.js
+++ b/frontend/test/metabase/scenarios/question/nulls.cy.spec.js
@@ -37,6 +37,87 @@ describe("scenarios > question > null", () => {
     });
   });
 
+  it.skip("(metabase#13626)", () => {
+    // Preparation for the test: "Arrange and Act phase" - see repro steps in #13626
+    withSampleDataset(({ ORDERS }) => {
+      // 1. create a question
+      cy.request("POST", "/api/card", {
+        name: "13626",
+        dataset_query: {
+          database: 1,
+          query: {
+            "source-table": 2,
+            aggregation: [["sum", ["expression", "NewDiscount"]]],
+            breakout: [["field-id", ORDERS.ID]],
+            expressions: {
+              NewDiscount: [
+                "case",
+                [[["=", ["field-id", ORDERS.ID], 2], 0]],
+                { default: ["field-id", ORDERS.DISCOUNT] },
+              ],
+            },
+            filter: ["=", ["field-id", ORDERS.ID], 1, 2, 3],
+          },
+          type: "query",
+        },
+        display: "pie",
+        visualization_settings: {},
+      }).then(({ body: { id: questionId } }) => {
+        // 2. create a dashboard
+        cy.request("POST", "/api/dashboard", {
+          name: "13626D",
+        }).then(({ body: { id: dashboardId } }) => {
+          // add filter (ID) to the dashboard
+          cy.request("PUT", `/api/dashboard/${dashboardId}`, {
+            parameters: [
+              {
+                id: "1f97c149",
+                name: "ID",
+                slug: "id",
+                type: "id",
+              },
+            ],
+          });
+
+          // add previously created question to the dashboard
+          cy.request("POST", `/api/dashboard/${dashboardId}/cards`, {
+            cardId: questionId,
+          }).then(({ body: { id: dashCardId } }) => {
+            // connect filter to that question
+            cy.request("PUT", `/api/dashboard/${dashboardId}/cards`, {
+              cards: [
+                {
+                  id: dashCardId,
+                  card_id: questionId,
+                  row: 0,
+                  col: 0,
+                  sizeX: 8,
+                  sizeY: 6,
+                  parameter_mappings: [
+                    {
+                      parameter_id: "1f97c149",
+                      card_id: questionId,
+                      target: ["dimension", ["field-id", ORDERS.ID]],
+                    },
+                  ],
+                },
+              ],
+            });
+          });
+          // NOTE: The actual "Assertion" phase begins here
+          cy.visit(`/dashboard/${dashboardId}?id=1`);
+          cy.findByText("13626D");
+
+          cy.log("**Reported failing in v0.37.0.2**");
+          // TODO: Once the issue is fixed, add a positive asssertion here
+          cy.get(".DashCard").within(() => {
+            cy.get(".LoadingSpinner").should("not.exist");
+          });
+        });
+      });
+    });
+  });
+
   describe("aggregations with null values", () => {
     beforeEach(() => {
       cy.server();
-- 
GitLab