Skip to content
Snippets Groups Projects
Unverified Commit 518e79b8 authored by Romeo Van Snick's avatar Romeo Van Snick Committed by GitHub
Browse files

Fix missing question type for metrics (#49489)

* Fix missing question type for metrics

* Add e2e test to reproduce #49454
parent e840233a
No related branches found
No related tags found
No related merge requests found
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import {
adhocQuestionHash,
createNativeQuestion,
createQuestion,
openNativeEditor,
restore,
runNativeQuery,
......@@ -8,6 +10,7 @@ import {
} from "e2e/support/helpers";
import { getRunQueryButton } from "../native-filters/helpers/e2e-sql-filter-helpers";
const { ORDERS_ID } = SAMPLE_DATABASE;
describe("issue 11727", { tags: "@external" }, () => {
const PG_DB_ID = 2;
......@@ -155,3 +158,38 @@ describe("issue 33327", () => {
cy.findByTestId("visualization-root").icon("warning").should("not.exist");
});
});
describe("issue 49454", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
createQuestion({
name: "Test Metric 49454",
type: "metric",
query: {
"source-table": ORDERS_ID,
aggregation: [["count"]],
},
});
createQuestion({
name: "Test Question 49454",
type: "question",
query: {
"source-table": ORDERS_ID,
aggregation: [["count"]],
},
});
});
it("should be possible to use metrics in native queries (metabase#49454)", () => {
openNativeEditor().type("select * from {{ #test");
cy.get(".ace_autocomplete")
.should("be.visible")
.within(() => {
cy.findByText("-question-49454").should("be.visible");
cy.findByText("-metric-49454").should("be.visible");
});
});
});
......@@ -128,5 +128,9 @@ export const getAutocompleteResultMeta = (
return t`Model in ${collectionName}`;
}
if (type === "metric") {
return t`Metric in ${collectionName}`;
}
throw new Error(`Unknown question.type(): ${type}`);
};
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