From 9b3dbcc88f90af6391701d46319cbb29bf0ab20f Mon Sep 17 00:00:00 2001
From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
Date: Thu, 5 May 2022 15:51:45 +0200
Subject: [PATCH] Repros #22447, #22449, #22450: illogical UI elements for
 nodata user [ci skip]

---
 ...llogical-UI-elements-for-nodata.cy.spec.js | 80 +++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 frontend/test/metabase/scenarios/permissions/reproductions/22447-illogical-UI-elements-for-nodata.cy.spec.js

diff --git a/frontend/test/metabase/scenarios/permissions/reproductions/22447-illogical-UI-elements-for-nodata.cy.spec.js b/frontend/test/metabase/scenarios/permissions/reproductions/22447-illogical-UI-elements-for-nodata.cy.spec.js
new file mode 100644
index 00000000000..00054670ec9
--- /dev/null
+++ b/frontend/test/metabase/scenarios/permissions/reproductions/22447-illogical-UI-elements-for-nodata.cy.spec.js
@@ -0,0 +1,80 @@
+import { restore, visitQuestion, isEE } from "__support__/e2e/cypress";
+import { USER_GROUPS, SAMPLE_DB_ID } from "__support__/e2e/cypress_data";
+
+const { ALL_USERS_GROUP, COLLECTION_GROUP } = USER_GROUPS;
+
+describe.skip("UI elements that make no sense for users without data permissions (metabase#22447, metabase##22449, metabase#22450)", () => {
+  beforeEach(() => {
+    restore();
+  });
+
+  it("should not offer to save question to users with no data permissions", () => {
+    cy.signIn("nodata");
+
+    visitQuestion("1");
+
+    cy.findByText("Settings");
+    cy.findByText("Visualization").click();
+
+    cy.findByTextEnsureVisible("Choose a visualization");
+    cy.icon("line").click();
+
+    cy.findByTextEnsureVisible("Line options");
+    cy.findByText("Save").should("not.exist");
+
+    // TODO: Please uncoment this part when metabase#22449 gets fixed
+    // cy.icon("refresh").should("not.exist");
+
+    // TODO: Please uncoment this part when metabase#22450 gets fixed
+    // cy.visit("/collection/root");
+
+    // cy.get("main")
+    //   .find(".Icon-add")
+    //   .click();
+
+    // Do not forget to import popover
+    // popover()
+    //   .should("contain", "Dashboard")
+    //   .and("contain", "Collection")
+    //   .and("not.contain", "Question");
+  });
+
+  it("should not show visualization or question settings to users with block data permissions", () => {
+    cy.onlyOn(isEE);
+
+    cy.signInAsAdmin();
+    cy.updatePermissionsGraph({
+      [ALL_USERS_GROUP]: {
+        [SAMPLE_DB_ID]: { data: { schemas: "block" } },
+      },
+      [COLLECTION_GROUP]: {
+        [SAMPLE_DB_ID]: { data: { schemas: "block" } },
+      },
+    });
+
+    cy.signIn("nodata");
+
+    visitQuestion("1");
+
+    cy.findByTextEnsureVisible("There was a problem with your question");
+
+    cy.findByText("Settings").should("not.exist");
+    cy.findByText("Visualization").should("not.exist");
+
+    // TODO: Please uncoment this part when metabase#22449 gets fixed
+    // cy.icon("refresh").should("not.exist");
+
+    // TODO: Please uncoment this part when metabase#22450 gets fixed
+    // cy.visit("/collection/root");
+
+    // cy.get("main")
+    //   .find(".Icon-add")
+    //   .click();
+
+    // Do not forget to import popover
+    // popover()
+    //   .should("contain", "Dashboard")
+    //   .and("contain", "Collection")
+    //   .and("not.contain", "Question");
+  });
+});
-- 
GitLab