From f6f4f0c794831245c258b05f634356c152c6af00 Mon Sep 17 00:00:00 2001
From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
Date: Fri, 9 Jul 2021 23:29:48 +0200
Subject: [PATCH] [SQL filters coverage] Add initial set of e2e tests around
 SQL field filter type of "None" (#16928)

* Add test for SQL field filter of the type "None"

* Add repro for #13825

* Fix spelling

Co-authored-by: Gustavo Saiani <gustavo@poe.ma>
---
 .../filters/sql-field-filter-none.cy.spec.js  | 60 +++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 frontend/test/metabase/scenarios/filters/sql-field-filter-none.cy.spec.js

diff --git a/frontend/test/metabase/scenarios/filters/sql-field-filter-none.cy.spec.js b/frontend/test/metabase/scenarios/filters/sql-field-filter-none.cy.spec.js
new file mode 100644
index 00000000000..40d451c02bd
--- /dev/null
+++ b/frontend/test/metabase/scenarios/filters/sql-field-filter-none.cy.spec.js
@@ -0,0 +1,60 @@
+import {
+  restore,
+  mockSessionProperty,
+  openNativeEditor,
+  filterWidget,
+} from "__support__/e2e/cypress";
+
+import * as SQLFilter from "./helpers/e2e-sql-filter-helpers";
+import * as FieldFilter from "./helpers/e2e-field-filter-helpers";
+
+describe("scenarios > filters > sql filters > field filter > None", () => {
+  beforeEach(() => {
+    restore();
+    cy.intercept("POST", "api/dataset").as("dataset");
+
+    cy.signInAsAdmin();
+    // Make sure feature flag is on regardless of the environment where this is running
+    mockSessionProperty("field-filter-operators-enabled?", true);
+
+    openNativeEditor();
+    SQLFilter.enterParameterizedQuery(
+      "SELECT * FROM products WHERE {{filter}}",
+    );
+
+    SQLFilter.openTypePickerFromDefaultFilterType();
+    SQLFilter.chooseType("Field Filter");
+
+    FieldFilter.mapTo({
+      table: "Products",
+      field: "Category",
+    });
+
+    FieldFilter.setWidgetType("None");
+
+    filterWidget().should("not.exist");
+  });
+
+  it("should successfully run the query and show all results", () => {
+    SQLFilter.runQuery();
+
+    cy.get(".Visualization").within(() => {
+      cy.findByText("Rustic Paper Wallet");
+    });
+
+    cy.findByText("Showing 200 rows");
+  });
+
+  it.skip("should let you change the field filter type to something else and restore the filter widget (metabase#13825)", () => {
+    FieldFilter.setWidgetType("String contains");
+
+    FieldFilter.openEntryForm();
+    FieldFilter.addWidgetStringFilter("zm");
+
+    SQLFilter.runQuery();
+
+    cy.get(".Visualization").within(() => {
+      cy.findByText("Rustic Paper Wallet");
+    });
+  });
+});
-- 
GitLab