The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
e2e2unit: Final sweep of filters e2e specs (#86000)
Nemanja Glumacd807ddf4ad44
diff --git a/e2e/support/commands/visibility/isVisibleInPopover.js b/e2e/support/commands/visibility/isVisibleInPopover.tssimilarity index 88%rename from e2e/support/commands/visibility/isVisibleInPopover.jsrename to e2e/support/commands/visibility/isVisibleInPopover.tsindex 77e5ddd3cc7..460f024b526 100644--- a/e2e/support/commands/visibility/isVisibleInPopover.js+++ b/e2e/support/commands/visibility/isVisibleInPopover.ts@@ -1,11 +1,19 @@import { POPOVER_ELEMENT } from "e2e/support/helpers";+declare global {+ namespace Cypress {+ interface Chainable {+ isVisibleInPopover(): Cypress.Chainable<JQuery<HTMLElement>>;+ }+ }+}+Cypress.Commands.add("isVisibleInPopover",{prevSubject: true,},- (subject) => {+ (subject: JQuery<HTMLElement>) => {cy.wrap(subject).closest(POPOVER_ELEMENT).then(($popover) => {@@ -14,7 +22,7 @@ Cypress.Commands.add(* 1. Obtains the value of element's computed property, but it always returns it in px (for example: "12px")* 2. Returns that value as a floating point number (strips away the "px") which enables us to use it in later calculations*/- function getElementPropertyValue(property) {+ function getElementPropertyValue(property: string) {const propertyValue = window.getComputedStyle(subject[0], null).getPropertyValue(property); /* [1] */diff --git a/e2e/test/scenarios/filters/filter.cy.spec.ts b/e2e/test/scenarios/filters/filter.cy.spec.tsindex a72c299bf59..560a59136cf 100644--- a/e2e/test/scenarios/filters/filter.cy.spec.ts+++ b/e2e/test/scenarios/filters/filter.cy.spec.ts@@ -1,6 +1,7 @@import {SAMPLE_DB_ID,SAMPLE_DB_SCHEMA_ID,+ USER_GROUPS,WRITABLE_DB_ID,} from "e2e/support/cypress_data";import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";@@ -307,7 +308,7 @@ describe("scenarios > filters", () => {});H.visualize((response) => {- expect(response.body.error).to.not.exist;+ expect(response?.body).to.not.have.property("error");});H.queryBuilderMain().findByText("Something went wrong").should("not.exist");});@@ -942,6 +943,87 @@ describe("scenarios > filters", () => {});});+describe("scenarios > filters > field filters without create-queries permission", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ cy.updateCollectionGraph({+ [USER_GROUPS.ALL_USERS_GROUP]: { root: "read" },+ });++ H.createNativeQuestionAndDashboard({+ questionDetails: {+ name: "Question",+ native: {+ query: "select * from products where {{category}} and {{vendor}}",+ "template-tags": {+ category: {+ id: "6b8b10ef-0104-1047-1e5v-2492d5954555",+ name: "category",+ "display-name": "CATEGORY",+ type: "dimension",+ dimension: ["field", PRODUCTS.CATEGORY, null],+ "widget-type": "string/=",+ },+ vendor: {+ id: "6b8b10ef-0104-1047-1e5v-2492d5964545",+ name: "vendor",+ "display-name": "VENDOR",+ type: "dimension",+ dimension: ["field", PRODUCTS.VENDOR, null],+ "widget-type": "string/=",+ },+ },+ },+ },+ }).then(({ body: { card_id, dashboard_id } }) => {+ cy.wrap(card_id).as("questionId");+ cy.wrap(dashboard_id).as("dashboardId");+ });++ cy.signIn("nodata");+ });++ it("should filter a native question by Vendor and Category from the question link and from a dashboard (metabase#12654)", () => {+ cy.log("from the question link");+ H.visitQuestion("@questionId");+ filterByVendorAndCategory();++ cy.log("from a dashboard");+ H.visitDashboard("@dashboardId");+ H.getDashboardCard().findByText("Question").click();+ filterByVendorAndCategory();+ });++ function filterByVendorAndCategory() {+ H.queryBuilderMain()+ .findByText("This question is written in SQL.")+ .should("be.visible");++ H.filterWidget({ name: "VENDOR" }).click();+ H.popover().within(() => {+ cy.findByPlaceholderText("Search the list").type("Balistreri-Muller");+ cy.findByText("Balistreri-Muller").click();+ cy.button("Add filter").click();+ });+ H.filterWidget({ name: "CATEGORY" }).click();+ H.popover().within(() => {+ cy.findByText("Widget").click();+ cy.button("Add filter").click();+ });++ H.queryBuilderHeader().findByTestId("run-button").click();++ H.assertQueryBuilderRowCount(1);+ H.tableInteractiveBody().within(() => {+ cy.findByText("Widget").should("be.visible");+ cy.findByText("Balistreri-Muller").should("be.visible");+ cy.findByText("Gizmo").should("not.exist");+ cy.findByText("McClure-Lockman").should("not.exist");+ });+ }+});+describe("scenarios > filters > unsupported column types",{ tags: "@external" },diff --git a/e2e/test/scenarios/filters/relative-datetime.cy.spec.js b/e2e/test/scenarios/filters/relative-datetime.cy.spec.jsdeleted file mode 100644index be487f4345d..00000000000--- a/e2e/test/scenarios/filters/relative-datetime.cy.spec.js+++ /dev/null@@ -1,30 +0,0 @@-const { H } = cy;--describe("scenarios > question > relative-datetime", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("starting from option should set correct sign (metabase#22228)", () => {- H.openOrdersTable();-- H.tableHeaderClick("Created At");- H.popover().within(() => {- cy.findByText("Filter by this column").click();- cy.findByText("Relative date range…").click();- cy.findByText("Next").click();- cy.findByLabelText(/Starting from/).click();- cy.button("Add filter").click();- });- cy.wait("@dataset");-- cy.findByTestId("qb-filters-panel").within(() => {- const baseName = "Created At is in the next 30 days";- cy.findByText(`${baseName}, starting 7 days from now`).should(- "be.visible",- );- cy.findByText(`${baseName}, starting 7 days ago`).should("not.exist");- });- });-});diff --git a/e2e/test/scenarios/filters/view.cy.spec.js b/e2e/test/scenarios/filters/view.cy.spec.jsdeleted file mode 100644index 04350650406..00000000000--- a/e2e/test/scenarios/filters/view.cy.spec.js+++ /dev/null@@ -1,147 +0,0 @@-const { H } = cy;-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";--const { PRODUCTS } = SAMPLE_DATABASE;--describe("scenarios > question > view", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- describe("apply filters without data permissions", () => {- beforeEach(() => {- // All users upgraded to collection view access- cy.visit("/admin/permissions/collections/root");- cy.icon("close").first().click();- cy.findAllByRole("option").contains("View").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Save changes").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Yes").click();-- // Native query saved in dasbhoard- H.createDashboard({}, { wrapId: true });-- H.createNativeQuestion(- {- name: "Question",- native: {- query: "select * from products where {{category}} and {{vendor}}",- "template-tags": {- category: {- id: "6b8b10ef-0104-1047-1e5v-2492d5954555",- name: "category",- "display-name": "CATEGORY",- type: "dimension",- dimension: ["field", PRODUCTS.CATEGORY, null],- "widget-type": "string/=",- },- vendor: {- id: "6b8b10ef-0104-1047-1e5v-2492d5964545",- name: "vendor",- "display-name": "VENDOR",- type: "dimension",- dimension: ["field", PRODUCTS.VENDOR, null],- "widget-type": "string/=",- },- },- },- },- { wrapId: true },- );-- cy.get("@questionId").then((questionId) => {- cy.get("@dashboardId").then((dashboardId) => {- H.addOrUpdateDashboardCard({- dashboard_id: dashboardId,- card_id: questionId,- });- });- });- });-- it("should be able to filter Q by Vendor and Category as no data user (from Q link) (metabase#12654)", () => {- cy.log("admin sees filters by search for Vendor");- H.visitQuestion("@questionId");- cy.findAllByText("VENDOR").first().click();- H.popover().within(() => {- cy.findByPlaceholderText("Search the list").should("exist");- cy.findByText("Search the list").should("not.exist");- });-- cy.signIn("nodata");- H.visitQuestion("@questionId");-- // The nodata user has view-data permission (via All Users group) but no create-queries permission.- // With param_fields hydration, field filter widgets now show as dropdowns with values.- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("This question is written in SQL.");- cy.findAllByText("VENDOR").first().click();- H.popover().within(() => {- cy.findByPlaceholderText("Search the list").type("Balistreri-Muller");- cy.findByText("Balistreri-Muller").click();- cy.findByText("Add filter").click();- });- cy.findAllByText("CATEGORY").first().click();- H.popover().within(() => {- cy.findByText("Widget").click();- cy.findByText("Add filter").click();- });-- // eslint-disable-next-line metabase/no-unsafe-element-filtering- cy.findAllByTestId("run-button").last().click();-- cy.get(".test-TableInteractive-cellWrapper--firstColumn").should(- "have.length",- 1,- );- cy.get(".CardVisualization").within(() => {- cy.findByText("Widget");- cy.findByText("Balistreri-Muller");- cy.findByText("Gizmo").should("not.exist");- cy.findByText("McClure-Lockman").should("not.exist");- });- });-- it("should be able to filter Q by Vendor and Category as no data user (from Dashboard) (metabase#12654)", () => {- // Navigate to Q from Dashboard- cy.signIn("nodata");- H.visitDashboard("@dashboardId");-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Question").click();-- // The nodata user has view-data permission (via All Users group) but no create-queries- // permission. The dashboard load populates field metadata into the entity cache via- // addFields, so field filter widgets show as dropdowns when navigating to the question.- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("This question is written in SQL.");- cy.findAllByText("VENDOR").first().click();- H.popover().within(() => {- cy.findByPlaceholderText("Search the list").type("Balistreri-Muller");- cy.findByText("Balistreri-Muller").click();- cy.findByText("Add filter").click();- });- cy.findAllByText("CATEGORY").first().click();- H.popover().within(() => {- cy.findByText("Widget").click();- cy.findByText("Add filter").click();- });-- // eslint-disable-next-line metabase/no-unsafe-element-filtering- cy.findAllByTestId("run-button").last().click();-- cy.get(".test-TableInteractive-cellWrapper--firstColumn").should(- "have.length",- 1,- );- cy.get(".CardVisualization").within(() => {- cy.findByText("Widget");- cy.findByText("Balistreri-Muller");- cy.findByText("Gizmo").should("not.exist");- cy.findByText("McClure-Lockman").should("not.exist");- });- });- });-});