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

Repro #25031: Embedding Dashboard with Locked parameters does not allow numeric values (#25032)

* Add repro for #25031

* Rename file

* Clean up issue references
parent 23fc2531
No related branches found
No related tags found
No related merge requests found
import {
restore,
visitEmbeddedPage,
visitDashboard,
visitQuestion,
} from "__support__/e2e/helpers";
const dashboardFilter = {
name: "Equal to",
slug: "equal_to",
id: "c269ebe1",
type: "number/=",
sectionId: "number",
};
const dashboardDetails = {
name: "25031",
parameters: [dashboardFilter],
};
const defaultFilterValues = [undefined, "10"];
defaultFilterValues.forEach(value => {
const conditionalPartOfTestTitle = value
? "and the required filter with the default value"
: "";
describe("issues 20845, 25031", () => {
beforeEach(() => {
cy.intercept("PUT", "/api/card/*").as("publishChanges");
restore();
cy.signInAsAdmin();
const questionDetails = getQuestionDetails(value);
cy.createNativeQuestionAndDashboard({
questionDetails,
dashboardDetails,
}).then(({ body: { id, dashboard_id, card_id } }) => {
cy.wrap(card_id).as("questionId");
cy.wrap(dashboard_id).as("dashboardId");
visitQuestion(card_id);
// Connect dashbaord filter to the card
cy.request("PUT", `/api/dashboard/${dashboard_id}/cards`, {
cards: [
{
card_id,
id,
row: 0,
col: 0,
sizeX: 12,
sizeY: 10,
parameter_mappings: [
{
parameter_id: dashboardFilter.id,
card_id,
target: ["variable", ["template-tag", "qty_locked"]],
},
],
},
],
});
});
});
it(`QUESTION: locked parameter should work with numeric values ${conditionalPartOfTestTitle} (metabase#20845)`, () => {
cy.get("@questionId").then(questionId => {
cy.request("PUT", `/api/card/${questionId}`, {
enable_embedding: true,
embedding_params: {
qty_locked: "locked",
},
});
// This issue is not possible to reproduce using UI from this point on.
// We have to manually send the payload in order to make sure it works for both strings and integers.
["string", "integer"].forEach(type => {
cy.log(
`Make sure it works with ${type.toUpperCase()} in the payload`,
);
visitEmbeddedPage({
resource: { question: questionId },
params: {
qty_locked: type === "string" ? "15" : 15, // IMPORTANT: integer
},
});
});
cy.findByTestId("column-header").should("contain", "COUNT(*)");
cy.findByTestId("cell-data").should("contain", "5");
});
});
it.skip(`DASHBOARD: locked parameter should work with numeric values ${conditionalPartOfTestTitle} (metabase#25031)`, () => {
cy.get("@dashboardId").then(dashboardId => {
visitDashboard(dashboardId);
cy.request("PUT", `/api/dashboard/${dashboardId}`, {
enable_embedding: true,
embedding_params: {
[dashboardFilter.slug]: "locked",
},
});
// This issue is not possible to reproduce using UI from this point on.
// We have to manually send the payload in order to make sure it works for both strings and integers.
["string", "integer"].forEach(type => {
cy.log(
`Make sure it works with ${type.toUpperCase()} in the payload`,
);
const payload = {
resource: { dashboard: dashboardId },
params: {
[dashboardFilter.slug]: type === "string" ? "15" : 15, // IMPORTANT: integer
},
};
visitEmbeddedPage(payload);
// wait for the results to load
cy.contains(dashboardDetails.name);
cy.get(".CardVisualization")
.should("contain", "COUNT(*)")
.and("contain", "5");
});
});
});
});
});
/**
* @param {string} defaultValue - The default value for the defined filter
* @returns object
*/
function getQuestionDetails(defaultValue = undefined) {
return {
name: "20845",
native: {
"template-tags": {
qty_locked: {
id: "6bd8d7be-bd5b-382c-cfa2-683461891663",
name: "qty_locked",
"display-name": "Qty locked",
type: "number",
required: defaultValue ? true : false,
default: defaultValue,
},
},
query:
"select count(*) from orders where true [[AND quantity={{qty_locked}}]]",
},
};
}
import { restore, visitEmbeddedPage } from "__support__/e2e/helpers";
const defaultFilterValues = [undefined, "10"];
defaultFilterValues.forEach(value => {
const conditionalPartOfTestTitle = value
? "and the required filter with the default value"
: "";
describe("issue 20845", () => {
beforeEach(() => {
cy.intercept("PUT", "/api/card/*").as("publishChanges");
restore();
cy.signInAsAdmin();
const questionDetails = getQuestionDetails(value);
cy.createNativeQuestion(questionDetails, {
visitQuestion: true,
wrapId: true,
});
cy.icon("share").click();
cy.findByText("Embed this question in an application").click();
cy.findByText("Disabled").click();
cy.findByText("Locked").click();
cy.findByText("Preview Locked Parameters")
.parent()
.within(() => {
cy.findByPlaceholderText("Qty locked").type("15{enter}");
});
cy.button("Publish").click();
cy.wait(["@publishChanges", "@publishChanges"]);
cy.signOut();
});
it(`locked parameter should work with numeric values ${conditionalPartOfTestTitle} (metabase#20845)`, () => {
// This issue is not possible to reproduce using UI from this point on.
// We have to manually send the payload in order to make sure it works for both strings and integers.
["string", "integer"].forEach(type => {
cy.log(`Make sure it works with ${type.toUpperCase()} in the payload`);
cy.get("@questionId").then(questionId => {
visitEmbeddedPage({
resource: { question: questionId },
params: {
qty_locked: type === "string" ? "15" : 15, // IMPORTANT: integer
},
});
});
cy.findByTestId("column-header").should("contain", "COUNT(*)");
cy.findByTestId("cell-data").should("contain", "5");
});
});
});
});
/**
* @param {string} defaultValue - The default value for the defined filter
* @returns object
*/
function getQuestionDetails(defaultValue = undefined) {
return {
name: "20845",
native: {
"template-tags": {
qty_locked: {
id: "6bd8d7be-bd5b-382c-cfa2-683461891663",
name: "qty_locked",
"display-name": "Qty locked",
type: "number",
required: defaultValue ? true : false,
default: defaultValue,
},
},
query: "select count(*) from orders where quantity={{qty_locked}}",
},
};
}
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