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

Enable "Add to dashboard" for metrics v2 (#45271)

* Enable "Add to dashboard" for metrics v2

* Add repro for #44220
parent 9b167f7c
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,8 @@ import {
sidebar,
undoToastList,
visitDashboard,
openQuestionActions,
getDashboardCards,
} from "e2e/support/helpers";
const { ORDERS_ID, ORDERS, PRODUCTS_ID, PRODUCTS } = SAMPLE_DATABASE;
......@@ -95,6 +97,39 @@ describe("scenarios > metrics > dashboard", () => {
cy.intercept("POST", "/api/dataset").as("dataset");
});
it("should be possible to add metric to a dashboard via context menu (metabase#44220)", () => {
createQuestion(ORDERS_SCALAR_METRIC).then(({ body: { id: metricId } }) => {
cy.intercept("POST", "/api/dataset").as("dataset");
cy.visit(`/metric/${metricId}`);
cy.wait("@dataset");
cy.findByTestId("scalar-value").should("have.text", "18,760");
cy.log("Add metric to a dashboard via context menu");
openQuestionActions();
popover().findByTextEnsureVisible("Add to dashboard").click();
modal().within(() => {
cy.findByRole("heading", {
name: "Add this metric to a dashboard",
}).should("be.visible");
cy.findByText("Orders in a dashboard").click();
cy.button("Select").click();
});
cy.log("Assert it's been added before the save");
cy.location("pathname").should(
"eq",
`/dashboard/${ORDERS_DASHBOARD_ID}-orders-in-a-dashboard`,
);
cy.location("hash").should("eq", `#add=${metricId}&edit`);
cy.findByTestId("scalar-value").should("have.text", "18,760");
cy.log("Assert we can save the dashboard with the metric");
saveDashboard();
getDashboardCards().should("have.length", 2);
cy.findByTestId("scalar-value").should("have.text", "18,760");
});
});
it("should be possible to add metrics to a dashboard", () => {
createQuestion(ORDERS_SCALAR_METRIC);
createQuestion(ORDERS_TIMESERIES_METRIC);
......
......@@ -186,7 +186,7 @@ export const QuestionActions = ({
});
}
if (isQuestion) {
if (isQuestion || isMetric) {
extraButtons.push({
title: t`Add to dashboard`,
icon: "add_to_dash",
......
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