Skip to content
Snippets Groups Projects
Unverified Commit 3fdf9da0 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

#11503 Repros: Filters from dashboard not used in question (#16627)

parent ec33a15d
No related branches found
No related tags found
No related merge requests found
......@@ -725,6 +725,117 @@ describe("scenarios > dashboard > dashboard drill", () => {
});
});
});
describe("should preserve dashboard filter and apply it to the question on a drill-through (metabase#11503)", () => {
const ordersIdFilter = {
name: "Orders ID",
slug: "orders_id",
id: "82a5a271",
type: "id",
sectionId: "id",
};
const productsIdFilter = {
name: "Products ID",
slug: "products_id",
id: "a4dc1976",
type: "id",
sectionId: "id",
};
const parameters = [ordersIdFilter, productsIdFilter];
beforeEach(() => {
// Add filters to the dashboard
cy.request("PUT", "/api/dashboard/1", {
parameters,
});
// Connect those filters to the existing dashboard card
cy.request("PUT", "/api/dashboard/1/cards", {
cards: [
{
id: 1,
card_id: 1,
row: 0,
col: 0,
sizeX: 12,
sizeY: 8,
series: [],
visualization_settings: {},
parameter_mappings: [
{
parameter_id: ordersIdFilter.id,
card_id: 1,
target: ["dimension", ["field", ORDERS.ID, null]],
},
{
parameter_id: productsIdFilter.id,
card_id: 1,
target: [
"dimension",
[
"field",
PRODUCTS.ID,
{
"source-field": ORDERS.PRODUCT_ID,
},
],
],
},
],
},
],
});
cy.visit("/dashboard/1");
});
it("should correctly drill-through on Orders filter (metabase#11503-1)", () => {
setFilterValue(ordersIdFilter.name);
drillThroughCardTitle("Orders");
cy.findByText("37.65");
cy.findByText("110.93");
cy.findByText("52.72").should("not.exist");
cy.findByText("Showing 2 rows");
postDrillAssertion();
});
it("should correctly drill-through on Products filter (metabase#11503-2)", () => {
setFilterValue(productsIdFilter.name);
drillThroughCardTitle("Orders");
cy.findByText("37.65").should("not.exist");
cy.findAllByText("105.12");
cy.findByText("Showing 191 rows");
postDrillAssertion();
});
function setFilterValue(filterName) {
cy.get("fieldset")
.contains(filterName)
.click();
cy.findByPlaceholderText("Enter an ID").type("1,2,");
cy.button("Add filter").click();
cy.findByText("2 selections");
}
function postDrillAssertion() {
cy.findByText("ID is 2 selections").click();
popover().within(() => {
cy.get("li")
.should("have.length", 3) // The third one is an input field
.and("contain", "1")
.and("contain", "2");
cy.findByText("Update filter");
});
}
});
});
function createDashboardWithQuestion(
......@@ -806,3 +917,10 @@ function setParamValue(paramName, text) {
cy.findByText("Add filter").click();
});
}
function drillThroughCardTitle(title) {
cy.get(".Card-title")
.contains(title)
.click();
cy.contains(`Started from ${title}`);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment