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

#13960 Repro: Should clear default filter value and preserve "state" on reload [ci skip] (#14025)

parent 3f720a08
No related branches found
No related tags found
No related merge requests found
......@@ -11,8 +11,10 @@ import { SAMPLE_DATASET } from "__support__/cypress_sample_dataset";
const { ORDERS, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATASET;
describe("scenarios > question > filter", () => {
before(restore);
beforeEach(signInAsAdmin);
beforeEach(() => {
restore();
signInAsAdmin();
});
it.skip("should load needed data (metabase#12985)", () => {
// Save a Question
......@@ -223,4 +225,113 @@ describe("scenarios > question > filter", () => {
cy.findAllByText("Gizmo");
});
});
it.skip("should not preserve cleared filter with the default value on refresh (metabase#13960)", () => {
cy.log("**--1. Create a question--**");
cy.request("POST", "/api/card", {
name: "13960",
dataset_query: {
type: "query",
query: {
"source-table": PRODUCTS_ID,
aggregation: [["count"]],
breakout: [["field-id", PRODUCTS.CATEGORY]],
},
database: 1,
},
display: "pie",
visualization_settings: {},
}).then(({ body: { id: QUESTION_ID } }) => {
cy.log("**--2. Create a dashboard--**");
cy.request("POST", "/api/dashboard", {
name: "13960D",
}).then(({ body: { id: DASHBOARD_ID } }) => {
cy.log(
"**--3. Add filters to the dashboard and set the default value to the first one--**",
);
cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, {
name: "13960D",
parameters: [
{
name: "Category",
slug: "category",
id: "c32a49e1",
type: "category",
default: ["Doohickey"],
},
{ name: "ID", slug: "id", id: "f2bf003c", type: "id" },
],
});
cy.log("**--4. Add question to the dashboard--**");
cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, {
cardId: QUESTION_ID,
}).then(({ body: { id: DASH_CARD_ID } }) => {
cy.log("**--5. Connect the filters to the card--**");
cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, {
cards: [
{
id: DASH_CARD_ID,
card_id: QUESTION_ID,
row: 0,
col: 0,
sizeX: 10,
sizeY: 10,
series: [],
visualization_settings: {},
parameter_mappings: [
{
parameter_id: "c32a49e1",
card_id: QUESTION_ID,
target: ["dimension", ["field-id", PRODUCTS.CATEGORY]],
},
{
parameter_id: "f2bf003c",
card_id: QUESTION_ID,
target: ["dimension", ["field-id", PRODUCTS.ID]],
},
],
},
],
});
});
cy.server();
cy.route("POST", `/api/card/${QUESTION_ID}/query`).as("cardQuery");
cy.visit(`/dashboard/${DASHBOARD_ID}`);
cy.wait("@cardQuery");
cy.location("search").should("eq", "?category=Doohickey");
// Remove default filter (category)
cy.get("fieldset .Icon-close").click();
cy.url().should("not.include", "?category=Doohickey");
// Set filter value to the `ID`
cy.get("fieldset")
.contains(/ID/i)
.click();
cy.findByPlaceholderText("Enter an ID").type("1");
cy.findByText("Add filter")
.closest("button")
.should("not.be.disabled")
.click();
cy.location("search").should("eq", "?id=1");
cy.reload();
cy.findByText("13960");
cy.findAllByText("Doohickey").should("not.exist");
// TODO: depending on how this issue will be fixed, the next assertion might need to be updated
cy.location("search").should("eq", "?id=1");
});
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment