The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
const { H } = cy;
import { SAMPLE_DB_ID, WRITABLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import { NO_COLLECTION_PERSONAL_COLLECTION_ID } from "e2e/support/cypress_sample_instance_data";
const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID, PEOPLE, PEOPLE_ID } =
SAMPLE_DATABASE;
describe("issue 32964", () => {
const LONG_NAME = "A very long column name that will cause text overflow";
const QUESTION = {
dataset_query: {
type: "query",
database: SAMPLE_DB_ID,
query: {
"source-table": ORDERS_ID,
expressions: {
[LONG_NAME]: [
"*",
["field", SAMPLE_DATABASE.ORDERS.SUBTOTAL, null],
2,
],
},
aggregation: [["sum", ["expression", LONG_NAME]]],
breakout: [
[
"field",
SAMPLE_DATABASE.ORDERS.CREATED_AT,
{
"base-type": "type/DateTime",
"temporal-unit": "week",
},
],
],
},
},
};
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
});
it("should not overflow chart settings sidebar with long column name (metabase#32964)", () => {
H.visitQuestionAdhoc(QUESTION);
H.openVizSettingsSidebar();
cy.findByTestId("sidebar-left").within(([sidebar]) => {
const maxX = sidebar.getBoundingClientRect().right;
cy.findByDisplayValue(`Sum of ${LONG_NAME}`).then(([el]) => {
const x = el.getBoundingClientRect().right;
expect(x).to.be.lessThan(maxX);
});
});
});
});
describe("issue 33079", () => {
const questionDetails = {
display: "line",
query: {
"source-table": ORDERS_ID,
aggregation: [["count"]],
breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],
},
};
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
cy.intercept("POST", "/api/dataset").as("dataset");
cy.request("GET", "/api/user/current").then(({ body: user }) => {
cy.request("PUT", `/api/user/${user.id}`, { locale: "de" });
});
});
it("underlying records drill should work in a non-English locale (metabase#33079)", () => {
H.createQuestion(questionDetails, { visitQuestion: true });
H.cartesianChartCircle().eq(1).click({ force: true });
H.popover()
.findByText("Siehe diese Einträge") // See these records
.click();
cy.wait("@dataset");
cy.findByTestId("question-row-count").should("contain", "19");
});
});
describe("issue 34414", () => {
const { INVOICES_ID } = SAMPLE_DATABASE;
const INVOICE_MODEL_DETAILS = {
name: "Invoices Model",
query: { "source-table": INVOICES_ID },
type: "model",
};
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
});
it("populate field values after re-adding filter on virtual table field (metabase#34414)", () => {
H.createQuestion(INVOICE_MODEL_DETAILS).then((response) => {
const modelId = response.body.id;
H.visitQuestionAdhoc({
dataset_query: {
type: "query",
database: SAMPLE_DB_ID,
query: { "source-table": `card__${modelId}` },
},
});
});
H.openNotebook();
H.filter({ mode: "notebook" });
H.popover().within(() => {
cy.findByText("Plan").click();
assertPlanFieldValues();
cy.log("Open filter again");
cy.findByLabelText("Back").click();
cy.log("Open plan field again");
cy.findByText("Plan").click();
assertPlanFieldValues();
});
});
});
function assertPlanFieldValues() {
cy.findByText("Basic").should("be.visible");
cy.findByText("Business").should("be.visible");
cy.findByText("Premium").should("be.visible");
}
describe("issue 38354", { tags: "@external" }, () => {
const QUESTION_DETAILS = {
query: {
"source-table": ORDERS_ID,
limit: 5,
},
};
beforeEach(() => {
H.restore("postgres-12");
cy.signInAsAdmin();
H.createQuestion(QUESTION_DETAILS, { visitQuestion: true });
});
it("should be possible to change source database (metabase#38354)", () => {
H.openNotebook();
H.getNotebookStep("data").findByTestId("data-step-cell").click();
H.miniPicker().within(() => {
H.miniPickerHeader().click();
cy.findByText("QA Postgres12").click();
cy.findByText("Orders").click();
});
// optimization: add a limit so that query runs faster
cy.button("Row limit").click();
H.getNotebookStep("limit").findByPlaceholderText("Enter a limit").type("5");
H.visualize();
cy.findByTestId("query-builder-main")
.findByText("There was a problem with your question")
.should("not.exist");
cy.get("[data-testid=cell-data]").should("contain", "37.65"); // assert visualization renders the data
});
});
describe("issue 30056", () => {
const questionDetails = {
query: {
"source-query": {
"source-table": PEOPLE_ID,
aggregation: [["count"]],
breakout: [
["field", PEOPLE.LATITUDE, { "base-type": "type/Float" }],
["field", PEOPLE.LONGITUDE, { "base-type": "type/Float" }],
],
},
filter: [">", ["field", "count", { "base-type": "type/Integer" }], 2],
},
};
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
});
it("should show table breadcrumbs for questions with post-aggregation filters (metabase#30056)", () => {
H.createQuestion(questionDetails, { visitQuestion: true });
// the name of the table is hidden after a few seconds with a CSS animation,
// so check for "exist" only
H.queryBuilderHeader().findByText("People").should("exist");
});
});
describe("issue 39102", () => {
const questionDetails = {
name: "39102",
query: {
"source-query": {
"source-table": ORDERS_ID,
aggregation: ["count"],
breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }]],
},
filter: [">", ["field", "count", { "base-type": "type/Integer" }], 1000],
aggregation: ["count"],
},
type: "question",
};
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
cy.intercept("POST", "/api/dataset").as("dataset");
});
it("should be able to preview a multi-stage query (metabase#39102)", () => {
H.createQuestion(questionDetails, { visitQuestion: true });
H.openNotebook();
H.getNotebookStep("data", { stage: 0 }).icon("play").click();
cy.wait("@dataset");
cy.findByTestId("preview-root").within(() => {
cy.findByText("Tax").should("be.visible");
cy.icon("close").click();
});
H.getNotebookStep("summarize", { stage: 0 }).icon("play").click();
cy.wait("@dataset");
cy.findByTestId("preview-root").within(() => {
cy.findByText("Count").should("be.visible");
cy.findByText("3,610").should("be.visible");
cy.findByText("744").should("be.visible");
cy.icon("close").click();
});
H.getNotebookStep("filter", { stage: 1 }).icon("play").click();
cy.wait("@dataset");
cy.findByTestId("preview-root").within(() => {
cy.findByText("Count").should("be.visible");
cy.findByText("3,610").should("be.visible");
cy.findByText("744").should("not.exist");
cy.icon("close").click();
});
H.getNotebookStep("summarize", { stage: 1 }).icon("play").click();
cy.wait("@dataset");
cy.findByTestId("preview-root").within(() => {
cy.findByText("Count").should("be.visible");
cy.findByText("4").should("be.visible");
});
});
});
describe("issue 13814", () => {
const questionDetails = {
display: "scalar",
query: {
"source-table": ORDERS_ID,
aggregation: [
["count", ["field", ORDERS.TAX, { "base-type": "type/Float" }]],
],
},
};
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
});
it("should support specifying a field in 'count' MBQL clause even if the UI doesn't support it (metabase#13814)", () => {
cy.log("verify that the API supports saving this MBQL");
H.createQuestion(questionDetails).then(({ body: card }) =>
H.visitQuestion(card.id),
);
cy.log("verify that the query is executed correctly");
cy.findByTestId("scalar-value").findByText("18,760").should("be.visible");
cy.log(
"verify that the clause is displayed correctly and won't crash if updated",
);
H.openNotebook();
H.getNotebookStep("summarize")
.findByText("Count of Tax")
.should("be.visible")
.click();
H.popover().findByText("Count of rows").click();
H.getNotebookStep("summarize").findByText("Count").should("be.visible");
});
});
describe("issue 39795", () => {
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
// Remapping Product ID to the product title is what made the column order reset
cy.request("post", `/api/field/${ORDERS.PRODUCT_ID}/dimension`, {
human_readable_field_id: PRODUCTS.TITLE,
name: "Product ID",
type: "external",
});
});
it("should allow me to re-order even when a field is set with a different display value (metabase#39795)", () => {
H.visitQuestionAdhoc({
dataset_query: {
database: SAMPLE_DB_ID,
query: {
"source-table": ORDERS_ID,
},
type: "query",
},
});
H.openVizSettingsSidebar();
H.getDraggableElements()
.eq(0)
.should("have.attr", "data-testid", "draggable-item-ID");
H.moveDnDKitListElement("draggable-item", {
startIndex: 0,
dropIndex: 2,
useMouseEvents: true,
});
H.getDraggableElements()
.eq(0)
.should("have.attr", "data-testid", "draggable-item-User ID");
H.getDraggableElements()
.eq(2)
.should("have.attr", "data-testid", "draggable-item-ID");
});
});
describe("issue 40176", () => {
const DIALECT = "postgres";
const TABLE = "uuid_pk_table";
beforeEach(() => {
H.restore(`${DIALECT}-writable`);
cy.signInAsAdmin();
H.resetTestTable({ type: DIALECT, table: TABLE });
H.resyncDatabase({
dbId: WRITABLE_DB_ID,
tableName: TABLE,
});
});
it(
"should allow filtering on UUID PK columns (metabase#40176)",
{ tags: "@external" },
() => {
H.getTable({ name: TABLE }).then(({ id: tableId }) => {
H.visitQuestionAdhoc({
display: "table",
dataset_query: {
database: WRITABLE_DB_ID,
query: {
"source-table": tableId,
},
type: "query",
},
});
});
H.openNotebook();
cy.findByTestId("action-buttons").findByText("Filter").click();
H.popover().within(() => {
cy.findByText("ID").click();
cy.findByLabelText("Filter value").type(
"a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
);
cy.button("Add filter").click();
});
H.visualize();
cy.findByTestId("question-row-count")
.findByText("Showing 1 row")
.should("be.visible");
},
);
});
describe("issue 40435", () => {
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
cy.intercept("PUT", "/api/card/*").as("updateCard");
});
it("should make new query columns visible by default (metabase#40435)", () => {
H.openOrdersTable();
H.openNotebook();
H.getNotebookStep("data").button("Pick columns").click();
H.popover().within(() => {
cy.findByText("Select all").click();
cy.findByText("User ID").click();
});
H.getNotebookStep("data").button("Pick columns").click();
H.visualize();
H.openVizSettingsSidebar();
cy.findByTestId("sidebar-left").within(() => {
cy.findByTestId("ID-hide-button").click();
cy.findByTestId("ID-show-button").click();
});
H.saveQuestion();
H.openNotebook();
H.getNotebookStep("data").button("Pick columns").click();
H.popover().findByText("Product ID").click();
H.queryBuilderHeader().findByText("Save").click();
// eslint-disable-next-line metabase/no-unsafe-element-filtering
H.modal().last().findByText("Save").click();
cy.wait("@updateCard");
H.visualize();
cy.findByRole("columnheader", { name: "ID" }).should("be.visible");
cy.findByRole("columnheader", { name: "User ID" }).should("be.visible");
cy.findByRole("columnheader", { name: "Product ID" }).should("be.visible");
});
});
describe(
"issue 42010 -- Unable to filter by mongo id",
{ tags: "@mongo" },
() => {
beforeEach(() => {
H.restore("mongo-5");
cy.signInAsAdmin();
cy.intercept("POST", "/api/dataset").as("dataset");
cy.request(`/api/database/${WRITABLE_DB_ID}/schema/`).then(({ body }) => {
const tableId = body.find((table) => table.name === "orders").id;
H.openTable({
database: WRITABLE_DB_ID,
table: tableId,
limit: 2,
});
});
cy.wait("@dataset");
});
it("should be possible to filter by Mongo _id column (metabase#40770, metabase#42010)", () => {
H.tableInteractiveBody()
.findByTestId("center-center-quadrant")
.findAllByRole("gridcell")
.first()
.then(($cell) => {
// Ids are non-deterministic so we have to obtain the id from the cell, and store its value.
const id = $cell.text();
cy.log(
"Scenario 1 - Make sure the simple mode filter is working correctly (metabase#40770)",
);
H.filter();
H.popover().within(() => {
cy.findAllByText("ID").should("have.length", 2).first().click();
cy.findByLabelText("Filter value").type(id).click();
cy.button("Apply filter").click();
});
H.assertQueryBuilderRowCount(1);
removeFilter();
cy.log(
"Scenario 2 - Make sure filter is working in the notebook editor (metabase#42010)",
);
H.openNotebook();
H.filter({ mode: "notebook" });
H.popover()
.findAllByRole("option")
.first()
.should("have.text", "ID")
.click();
cy.findByTestId("string-filter-picker").within(() => {
cy.findByLabelText("Filter operator").should("have.text", "Is");
cy.findByLabelText("Filter value").type(id);
cy.button("Add filter").click();
});
cy.findByTestId("step-filter-0-0").within(() => {
cy.findByText(`ID is ${id}`);
cy.log(
"Scenario 2.1 - Trigger the preview to make sure it reflects the filter correctly",
);
cy.icon("play").click();
});
// The preview should show only one row
const ordersColumns = 10;
cy.findByTestId("preview-root")
.findByTestId("table-body")
.findAllByTestId("cell-data")
.should("have.length.at.most", ordersColumns);
cy.log("Scenario 2.2 - Make sure we can visualize the data");
H.visualize();
cy.findByTestId("question-row-count").should(
"have.text",
"Showing 1 row",
);
});
});
},
);
function removeFilter() {
cy.findByTestId("filter-pill").findByLabelText("Remove").click();
cy.findByTestId("question-row-count").should("have.text", "Showing 2 rows");
}
describe("issue 42244", () => {
const COLUMN_NAME = "Created At".repeat(5);
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
cy.request("PUT", `/api/field/${ORDERS.CREATED_AT}`, {
display_name: COLUMN_NAME,
});
});
it("should allow to change the temporal bucket when the column name is long (metabase#42244)", () => {
H.openOrdersTable({ mode: "notebook" });
H.summarize({ mode: "notebook" });
H.getNotebookStep("summarize")
.findByText("Pick a column to group by")
.click();
H.popover().within(() => {
cy.findByText(COLUMN_NAME).realHover();
cy.findByText("by month").should("be.visible").click();
});
// eslint-disable-next-line metabase/no-unsafe-element-filtering
H.popover().last().findByText("Year").click();
H.getNotebookStep("summarize")
.findByText(`${COLUMN_NAME}: Year`)
.should("be.visible");
});
});
describe("issue 44071", () => {
const questionDetails = {
name: "Test",
query: { "source-table": ORDERS_ID },
collection_id: NO_COLLECTION_PERSONAL_COLLECTION_ID,
};
beforeEach(() => {
H.restore();
cy.signIn("nocollection");
H.createQuestion(questionDetails);
});
it("should be able to save questions based on another questions without collection access (metabase#44071)", () => {
cy.visit("/");
H.newButton("Question").click();
H.miniPickerBrowseAll().click();
H.entityPickerModal().within(() => {
cy.findByText(/Personal Collection/).click();
cy.findByText(questionDetails.name).click();
});
H.getNotebookStep("data")
.findByText(questionDetails.name)
.should("be.visible");
H.saveQuestion();
H.appBar()
.findByText(/Personal Collection/)
.should("be.visible");
});
});
describe("issue 44415", () => {
beforeEach(() => {
H.restore();
cy.signIn("admin");
H.createQuestion(
{
query: {
"source-table": ORDERS_ID,
filter: [
"and",
[
"not-null",
["field", ORDERS.DISCOUNT, { "base-type": "type/Float" }],
],
],
},
visualization_settings: {
"table.columns": [
{
name: "ID",
fieldRef: ["field", ORDERS.ID, null],
enabled: true,
},
{
name: "DISCOUNT",
fieldRef: ["field", ORDERS.DISCOUNT, null],
enabled: true,
},
],
},
},
{ wrapId: true },
);
});
it("should be able to edit a table question in the notebook editor before running its query (metabase#44415)", () => {
cy.get("@questionId").then((questionId) =>
cy.visit(`/question/${questionId}/notebook`),
);
H.getNotebookStep("filter")
.findAllByTestId("notebook-cell-item")
.first()
.icon("close")
.click();
H.getNotebookStep("filter").should("not.exist");
H.visualize();
cy.findByTestId("qb-filters-panel").should("not.exist");
cy.get("@questionId").then((questionId) => {
cy.url().should("not.include", `/question/${questionId}`);
cy.url().should("include", "question#");
});
});
});
describe("issue 37374", () => {
const questionDetails = {
query: {
"source-table": PRODUCTS_ID,
aggregation: [["count"]],
breakout: [
["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }],
["field", PRODUCTS.VENDOR, { "base-type": "type/Text" }],
],
},
};
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
H.createQuestion(questionDetails, { wrapId: true });
cy.signIn("nodata");
});
it("should allow to change the viz type to pivot without data access (metabase#37374)", () => {
H.visitQuestion("@questionId");
cy.intercept("POST", "/api/card/*/query").as("cardQuery");
cy.intercept("POST", "/api/card/pivot/*/query").as("cardPivotQuery");
cy.log("changing the viz type to pivot table and running the query works");
H.openVizTypeSidebar();
cy.findByTestId("chart-type-sidebar")
.findByTestId("Pivot Table-button")
.click();
cy.wait("@cardPivotQuery");
cy.findByTestId("pivot-table").should("be.visible");
cy.log("changing the viz type back to table and running the query works");
cy.findByTestId("chart-type-sidebar").findByTestId("Table-button").click();
cy.wait("@cardQuery");
H.tableInteractive().should("be.visible");
});
});
describe("issue 44532", () => {
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
H.openProductsTable();
});
it("should update chart metrics and dimensions with each added breakout (metabase#44532)", () => {
H.summarize();
H.rightSidebar()
.findByRole("listitem", { name: "Category" })
.button("Add dimension")
.click();
cy.wait("@dataset");
H.echartsContainer().within(() => {
cy.findByText("Count").should("exist"); // y-axis
cy.findByText("Category").should("exist"); // x-axis
// x-axis values
cy.findByText("Doohickey").should("exist");
cy.findByText("Gadget").should("exist");
cy.findByText("Gizmo").should("exist");
cy.findByText("Widget").should("exist");
});
H.rightSidebar()
.findByRole("listitem", { name: "Created At" })
.button("Add dimension")
.click();
cy.wait("@dataset");
cy.findByLabelText("Legend").within(() => {
cy.findByText("Doohickey").should("exist");
cy.findByText("Gadget").should("exist");
cy.findByText("Gizmo").should("exist");
cy.findByText("Widget").should("exist");
});
H.echartsContainer().within(() => {
cy.findByText("Count").should("exist"); // y-axis
cy.findByText("Created At: Month").should("exist"); // x-axis
// x-axis values
cy.findByText("April 2026").should("exist");
cy.findByText("April 2027").should("exist");
cy.findByText("April 2028").should("exist");
// previous x-axis values
cy.findByText("Doohickey").should("not.exist");
cy.findByText("Gadget").should("not.exist");
cy.findByText("Gizmo").should("not.exist");
cy.findByText("Widget").should("not.exist");
});
H.rightSidebar().button("Done").click();
cy.wait("@dataset");
cy.findByLabelText("Legend").within(() => {
cy.findByText("Doohickey").should("exist");
cy.findByText("Gadget").should("exist");
cy.findByText("Gizmo").should("exist");
cy.findByText("Widget").should("exist");
});
H.echartsContainer().within(() => {
cy.findByText("Count").should("exist"); // y-axis
cy.findByText("Created At: Month").should("exist"); // x-axis
// x-axis values
cy.findByText("April 2026").should("exist");
cy.findByText("April 2027").should("exist");
cy.findByText("April 2028").should("exist");
// previous x-axis values
cy.findByText("Doohickey").should("not.exist");
cy.findByText("Gadget").should("not.exist");
cy.findByText("Gizmo").should("not.exist");
cy.findByText("Widget").should("not.exist");
});
});
});
describe("issue 31960", () => {
const questionDetails = {
query: {
"source-table": ORDERS_ID,
aggregation: [["count"]],
breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "week" }]],
},
display: "line",
visualization_settings: {
"graph.metrics": ["count"],
"graph.dimensions": ["CREATED_AT"],
},
};
// the dot that corresponds to July 13–19, 2025
const dotIndex = 10;
const rowCount = 11;
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
});
it("should apply a date range filter for a query broken out by week (metabase#31960)", () => {
H.createDashboardWithQuestions({ questions: [questionDetails] }).then(
({ dashboard }) => {
H.visitDashboard(dashboard.id);
},
);
H.getDashboardCard().within(() => {
// eslint-disable-next-line metabase/no-unsafe-element-filtering
H.cartesianChartCircle().eq(dotIndex).realHover();
});
H.assertEChartsTooltip({
header: "July 13–19, 2025", // expect this to break when we shift years in the Sample Database
rows: [{ name: "Count", value: String(rowCount), secondaryValue: "0%" }],
});
H.getDashboardCard().within(() => {
// eslint-disable-next-line metabase/no-unsafe-element-filtering
H.cartesianChartCircle().eq(dotIndex).click({ force: true });
});
H.popover().findByText("See these Orders").click();
cy.findByTestId("qb-filters-panel")
.findByText("Created At: Week is Jul 13–19, 2025")
.should("be.visible");
H.assertQueryBuilderRowCount(rowCount);
});
});
describe("issue 43294", () => {
const questionDetails = {
display: "line",
query: {
"source-table": ORDERS_ID,
aggregation: [["count"]],
breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],
},
visualization_settings: {
"graph.metrics": ["count"],
"graph.dimensions": ["CREATED_AT"],
},
};
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
cy.intercept("POST", "/api/dataset").as("dataset");
});
it("should not overwrite viz settings with click actions in raw data mode (metabase#43294)", () => {
H.createQuestion(questionDetails, { visitQuestion: true });
H.queryBuilderFooter().findByLabelText("Switch to data").click();
// TODO: reenable this test when we reenable the "Compare to the past" components.
// cy.log("compare action");
// cy.button("Add column").click();
// popover().findByText("Compare to the past").click();
// popover().button("Done").click();
cy.log("extract action");
cy.button("Add column").click();
H.popover().findByText("Extract part of column").click();
H.popover().within(() => {
cy.findByText("Created At: Month").click();
cy.findByText("Year").click();
});
cy.wait("@dataset");
cy.log("combine action");
cy.button("Add column").click();
H.popover().findByText("Combine columns").click();
H.popover().button("Done").click();
cy.wait("@dataset");
cy.log("check visualization");
H.queryBuilderFooter().findByLabelText("Switch to visualization").click();
H.echartsContainer().within(() => {
cy.findByText("Count").should("be.visible");
cy.findByText("Created At: Month").should("be.visible");
});
});
});
describe("issue 40399", () => {
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
});
it("should not show results from other stages in a stages preview (metabase#40399)", () => {
H.createQuestion(
{
name: "40399",
query: {
"source-table": PRODUCTS_ID,
joins: [
{
fields: "all",
alias: "Orders",
"source-table": ORDERS_ID,
strategy: "left-join",
condition: [
"=",
["field", PRODUCTS.ID, null],
["field", ORDERS.PRODUCT_ID, { "join-alias": "Orders" }],
],
},
],
filter: ["=", ["field", PRODUCTS.CATEGORY, null], "Widget"],
},
},
{
visitQuestion: true,
},
);
H.openNotebook();
H.getNotebookStep("filter", { stage: 0 }).within(() => {
cy.icon("play").click();
cy.findByTestId("preview-root")
.findAllByText("Widget")
.should("be.visible");
});
H.getNotebookStep("join", { stage: 0 }).within(() => {
cy.icon("play").click();
cy.findByTestId("preview-root")
.findAllByText("Gizmo")
.should("be.visible");
cy.findByTestId("preview-root").findByText("Widget").should("not.exist");
});
H.getNotebookStep("data", { stage: 0 }).within(() => {
cy.icon("play").click();
cy.findByTestId("preview-root")
.findAllByText("Gizmo")
.should("be.visible");
cy.findByTestId("preview-root").findAllByText("Gizmo").should("exist");
cy.findByTestId("preview-root").findAllByText("Widget").should("exist");
});
});
});
describe("issue 43057", () => {
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
});
it("should differentiate between date and datetime filters with 00:00 time (metabase#43057)", () => {
H.openOrdersTable();
cy.log("set the date and verify the filter and results");
cy.intercept("POST", "/api/dataset").as("dataset");
H.tableHeaderClick("Created At");
H.popover().within(() => {
cy.findByText("Filter by this column").click();
cy.findByText("Fixed date range…").click();
cy.findByText("On").click();
cy.findByLabelText("Date").clear().type("November 18, 2027");
cy.button("Add filter").click();
});
cy.wait("@dataset");
H.assertQueryBuilderRowCount(16);
cy.findByTestId("qb-filters-panel")
.findByText("Created At is on Nov 18, 2027")
.should("be.visible");
cy.log("set time to 00:00 and verify the filter and results");
cy.findByTestId("qb-filters-panel")
.findByText("Created At is on Nov 18, 2027")
.click();
H.popover().within(() => {
cy.button("Add time").click();
cy.findByLabelText("Time").should("have.value", "00:00");
cy.button("Update filter").click();
});
cy.wait("@dataset");
H.assertQueryBuilderRowCount(1);
cy.findByTestId("qb-filters-panel")
.findByText("Created At is Nov 18, 2027, 12:00 AM")
.should("be.visible");
cy.log("remove time and verify the filter and results");
cy.findByTestId("qb-filters-panel")
.findByText("Created At is Nov 18, 2027, 12:00 AM")
.click();
H.popover().within(() => {
cy.findByLabelText("Time").should("have.value", "00:00");
cy.button("Remove time").click();
cy.button("Update filter").click();
});
cy.wait("@dataset");
H.assertQueryBuilderRowCount(16);
cy.findByTestId("qb-filters-panel")
.findByText("Created At is on Nov 18, 2027")
.should("be.visible");
});
});
describe("issue 19894", () => {
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
});
it("should show all columns when using the join column selecter (metabase#19894)", () => {
H.createQuestion(
{
name: "Q1",
query: {
"source-table": PRODUCTS_ID,
aggregation: [["count"]],
breakout: [["field", PRODUCTS.CATEGORY, null]],
},
},
{
wrapId: true,
},
);
H.createQuestion({
name: "Q2",
query: {
"source-table": PRODUCTS_ID,
aggregation: [["sum", ["field", PRODUCTS.PRICE, null]]],
breakout: [["field", PRODUCTS.CATEGORY, null]],
},
});
H.createQuestion({
name: "Q3",
query: {
"source-table": PRODUCTS_ID,
aggregation: [["avg", ["field", PRODUCTS.RATING, null]]],
breakout: [["field", PRODUCTS.CATEGORY, null]],
},
});
H.startNewQuestion();
H.miniPicker().should("exist");
cy.realType("Q1");
H.miniPicker().findByText("Q1").click();
cy.button("Join data").click();
cy.realType("Q2");
H.miniPicker().findByText("Q2").click();
H.popover().findByText("Category").click();
H.popover().findByText("Category").click();
cy.button("Join data").click();
cy.realType("Q3");
H.miniPicker().findByText("Q3").click();
H.popover().findByText("Category").should("be.visible");
H.popover().findByText("Count").should("be.visible");
H.popover().findByText("Q1").click();
H.popover().findByText("Q2").click();
H.popover().findByText("Q2 - Category → Category").should("be.visible");
H.popover().findByText("Q2 - Category → Sum of Price").should("be.visible");
H.popover().findByText("Q1").click();
H.popover().findByText("Category").should("be.visible");
H.popover().findByText("Count").should("be.visible");
});
});
describe("issue 44637", () => {
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
});
it("should not crash when rendering a line/bar chart with empty results (metabase#44637)", () => {
H.createNativeQuestion(
{
native: {
query: "SELECT '2023-01-01'::date, 2 FROM people WHERE false",
},
},
{ visitQuestion: true },
);
H.assertQueryBuilderRowCount(0);
H.queryBuilderMain().findByText("No results").should("exist");
H.queryBuilderFooter().button("Visualization").click();
H.leftSidebar().within(() => {
cy.findByTestId("more-charts-toggle").click();
cy.icon("bar").click();
});
H.queryBuilderMain().within(() => {
cy.findByText("No results").should("exist");
cy.findByText("Something's gone wrong").should("not.exist");
});
H.queryBuilderFooter().icon("calendar").click();
H.rightSidebar().findByText("Create event");
});
});