Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Consolidate question e2e tests (#83329)

Nemanja Glumac106eaa5260be
diff --git a/e2e/support/helpers/e2e-ui-elements-helpers.js b/e2e/support/helpers/e2e-ui-elements-helpers.js
index 1acb4b8dc3a..50c99166972 100644
--- a/e2e/support/helpers/e2e-ui-elements-helpers.js
+++ b/e2e/support/helpers/e2e-ui-elements-helpers.js
@@ -328,14 +328,6 @@ export const getDraggableElements = () => {
return cy.findAllByTestId(/draggable-item/);
};
-export const moveColumnDown = (column, distance) => {
- column
- .trigger("mousedown", 0, 0, { force: true })
- .trigger("mousemove", 5, 5, { force: true })
- .trigger("mousemove", 0, distance * 50, { force: true })
- .trigger("mouseup", 0, distance * 50, { force: true });
-};
-
/**
* Moves an element within a dnd-kit sortable list from one position to another.
*
diff --git a/e2e/test/scenarios/custom-column/cc-typing-suggestion.cy.spec.js b/e2e/test/scenarios/custom-column/cc-typing-suggestion.cy.spec.js
index b408fa41d7d..52171983692 100644
--- a/e2e/test/scenarios/custom-column/cc-typing-suggestion.cy.spec.js
+++ b/e2e/test/scenarios/custom-column/cc-typing-suggestion.cy.spec.js
@@ -285,6 +285,27 @@ describe("scenarios > question > custom column > typing suggestion", () => {
});
});
+describe("scenarios > question > custom column > typing suggestion > reviews", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it("distinct inside custom expression should suggest non-numeric types (metabase#13469)", () => {
+ H.openReviewsTable({ mode: "notebook" });
+ H.summarize({ mode: "notebook" });
+ H.popover().contains("Custom Expression").click();
+
+ H.enterCustomColumnDetails({ formula: "Distinct([R", blur: false });
+
+ cy.log(
+ "**The point of failure for ANY non-numeric value reported in v0.36.4**",
+ );
+ // the default type for "Reviewer" is "No semantic type"
+ H.CustomExpressionEditor.completion("Reviewer").should("be.visible");
+ });
+});
+
const addCustomColumn = () => {
cy.findByTestId("action-buttons").findByText("Custom column").click();
};
diff --git a/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js
index a35e70f5972..4edf8a43ca7 100644
--- a/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js
+++ b/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js
@@ -487,6 +487,40 @@ describe("scenarios > question > custom column", () => {
H.CustomExpressionEditor.value().should("equal", "Sum([MyCC \\[2027\\]])");
});
+ it("should append indexes to duplicate custom expression names (metabase#12104)", () => {
+ cy.viewport(1920, 800); // we're looking for a column name beyond the right of the default viewport
+ H.openProductsTable({ mode: "notebook" });
+
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("Custom column").click();
+ addSimpleCustomColumn("EXPR");
+
+ H.getNotebookStep("expression").within(() => {
+ cy.icon("add").click();
+ });
+ addSimpleCustomColumn("EXPR");
+
+ H.getNotebookStep("expression").within(() => {
+ cy.icon("add").click();
+ });
+ addSimpleCustomColumn("EXPR");
+
+ H.getNotebookStep("expression").within(() => {
+ cy.findByText("EXPR");
+ cy.findByText("EXPR (1)");
+ cy.findByText("EXPR (2)");
+ });
+
+ H.visualize();
+
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("EXPR");
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("EXPR (1)");
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("EXPR (2)");
+ });
+
it("should be able to add a date range filter to a custom column", () => {
H.visitQuestionAdhoc({
display: "table",
@@ -646,6 +680,40 @@ describe("scenarios > question > custom column", () => {
);
});
+ it("should allow using `Custom Expression` in orders metrics and keep manually entered parenthesis intact if they affect the result (metabase#12899, metabase#13306)", () => {
+ H.openOrdersTable({ mode: "notebook" });
+ H.summarize({ mode: "notebook" });
+ H.popover().contains("Custom Expression").click();
+
+ H.enterCustomColumnDetails({
+ formula: "sum([Total]) / (sum([Product → Price]) * average([Quantity]))",
+ format: true,
+ });
+
+ H.CustomExpressionEditor.value().should(
+ "equal",
+ dedent`
+ Sum([Total]) /
+ (Sum([Product → Price]) * Average([Quantity]))
+ `.trim(),
+ );
+
+ H.enterCustomColumnDetails({
+ formula: "2 * Max([Total])",
+ name: "twice max total",
+ });
+
+ H.expressionEditorWidget().button("Done").click();
+ cy.findByTestId("aggregate-step")
+ .contains("twice max total")
+ .should("exist");
+
+ H.visualize();
+
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("318.7");
+ });
+
it("should not allow formatting or saving an invalid expression, and validate it when typing", () => {
H.openOrdersTable({ mode: "notebook" });
cy.findByLabelText("Custom column").click();
@@ -886,3 +954,9 @@ describe("scenarios > question > custom column", () => {
H.CustomExpressionEditor.value().should("eq", "[Bar]");
});
});
+
+function addSimpleCustomColumn(name) {
+ H.enterCustomColumnDetails({ formula: "[Category]", blur: true });
+ H.CustomExpressionEditor.nameInput().click().type(name);
+ cy.button("Done").click();
+}
diff --git a/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.js
index 4c38cf110ae..cc062e3539c 100644
--- a/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.js
+++ b/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.js
@@ -834,4 +834,20 @@ describe("scenarios > question > custom column > aggregation", () => {
)
.should("be.visible");
});
+
+ it("should allow using aggregation functions inside expressions in aggregation (metabase#52611)", () => {
+ cy.visit("/");
+ H.newButton("Question").click();
+ H.miniPicker().findByText("Sample Database").click();
+ H.miniPicker().findByText("Orders").click();
+ H.addSummaryField({ metric: "Custom Expression" });
+ H.enterCustomColumnDetails({
+ formula: "case(Sum([Total]) > 10, Sum([Total]), Sum([Subtotal]))",
+ name: "conditional sum",
+ });
+ cy.button("Done").click();
+ H.addSummaryGroupingField({ field: "Total" });
+ H.visualize();
+ H.echartsContainer().should("contain.text", "Total: 8 bins");
+ });
});
diff --git a/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.js
index 50a78ce1436..39796ef966e 100644
--- a/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.js
+++ b/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.js
@@ -45,6 +45,47 @@ describe("issue 13751", { tags: "@external" }, () => {
});
});
+describe("postgres > question > custom columns", { tags: "@external" }, () => {
+ beforeEach(() => {
+ H.restore("postgres-12");
+ cy.signInAsAdmin();
+
+ cy.request(`/api/database/${WRITABLE_DB_ID}/schema/public`).then(
+ ({ body }) => {
+ const tableId = body.find((table) => table.name === "orders").id;
+ H.openTable({
+ database: WRITABLE_DB_ID,
+ table: tableId,
+ mode: "notebook",
+ });
+ },
+ );
+
+ cy.findByRole("button", { name: "Summarize" }).click();
+ });
+
+ it("`Percentile` custom expression function should accept two parameters (metabase#15714)", () => {
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("Pick a function or metric").click();
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("Custom Expression").click();
+ H.enterCustomColumnDetails({
+ formula: "Percentile([Subtotal], 0.1)",
+ format: true,
+ });
+
+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
+ cy.findByText("Function Percentile expects 1 argument").should("not.exist");
+ H.CustomExpressionEditor.nameInput().type("Expression name");
+ cy.button("Done").should("not.be.disabled").click();
+ // Todo: Add positive assertions once this is fixed
+
+ cy.findByTestId("aggregate-step")
+ .contains("Expression name")
+ .should("exist");
+ });
+});
+
describe("issue 14843", () => {
const { PEOPLE, PEOPLE_ID } = SAMPLE_DATABASE;
const CC_NAME = "City Length";
@@ -490,6 +531,59 @@ describe("issue 21135", () => {
});
});
+describe("issue 40064", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsNormalUser();
+ });
+
+ it("should be able to edit a custom column with the same name as one of the columns used in the expression (metabase#40064)", () => {
+ H.createQuestion(
+ {
+ query: {
+ "source-table": ORDERS_ID,
+ expressions: {
+ Tax: ["*", ["field", ORDERS.TAX, { "base-type": "type/Float" }], 2],
+ },
+ limit: 1,
+ },
+ },
+ { visitQuestion: true },
+ );
+
+ cy.log("check the initial expression value");
+ H.tableInteractive().findByText("4.14").should("be.visible");
+
+ cy.log("update the expression and check the value");
+ H.openNotebook();
+ H.getNotebookStep("expression").findByText("Tax").click();
+ H.enterCustomColumnDetails({ formula: "[Tax] * 3", blur: true });
+ H.popover().button("Update").click();
+ H.visualize();
+ H.tableInteractive().findByText("6.21").should("be.visible");
+
+ cy.log("rename the expression and make sure you cannot create a cycle");
+ H.openNotebook();
+ H.getNotebookStep("expression").findByText("Tax").click();
+ H.enterCustomColumnDetails({
+ formula: "[Tax] * 3",
+ name: "Tax3",
+ blur: true,
+ });
+ H.popover().button("Update").should("not.be.disabled").click();
+ H.getNotebookStep("expression").findByText("Tax3").click();
+ H.enterCustomColumnDetails({
+ formula: "[Tax3] * 3",
+ name: "Tax3",
+ blur: true,
+ });
+ H.popover().within(() => {
+ cy.findByText("Unknown column: Tax3").should("be.visible");
+ cy.button("Update").should("be.disabled");
+ });
+ });
+});
+
describe("issue 21513", () => {
beforeEach(() => {
H.restore();
diff --git a/e2e/test/scenarios/custom-column/custom-column-reproductions-2.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-reproductions-2.cy.spec.js
index 6406a4efe28..cd790255d00 100644
--- a/e2e/test/scenarios/custom-column/custom-column-reproductions-2.cy.spec.js
+++ b/e2e/test/scenarios/custom-column/custom-column-reproductions-2.cy.spec.js
@@ -697,6 +697,42 @@ describe("Issue 26512", () => {
});
});
+describe("issues 41381, 33439, 33441", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsNormalUser();
+ });
+
+ it("should validate custom expressions: constant-only, convertTimezone on an unsupported db, and an incorrect date expression (metabase#41381, metabase#33439, metabase#33441)", () => {
+ H.openOrdersTable({ mode: "notebook" });
+ H.addCustomColumn();
+ H.enterCustomColumnDetails({ formula: "'Test'", name: "Constant" });
+ H.popover().within(() => {
+ cy.findByText("Invalid expression").should("not.exist");
+ cy.button("Done").should("be.enabled");
+ });
+
+ H.enterCustomColumnDetails({
+ formula:
+ 'convertTimezone("2022-12-28T12:00:00", "Canada/Pacific", "Canada/Eastern")',
+ name: "Date",
+ });
+ H.popover().within(() => {
+ cy.findByText("Unsupported function convertTimezone");
+ cy.button("Done").should("be.disabled");
+ });
+
+ H.enterCustomColumnDetails({
+ formula: 'datetimeDiff([Created At] , now(), "days")',
+ name: "Date",
+ });
+ H.popover().within(() => {
+ cy.findByText("Types are incompatible.").should("be.visible");
+ cy.button("Done").should("be.disabled");
+ });
+ });
+});
+
describe("Issue 38498", { tags: "@external" }, () => {
beforeEach(() => {
H.restore("postgres-12");
diff --git a/e2e/test/scenarios/native/native-reproductions.cy.spec.js b/e2e/test/scenarios/native/native-reproductions.cy.spec.js
index d4923ee001d..39b5abc3363 100644
--- a/e2e/test/scenarios/native/native-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/native/native-reproductions.cy.spec.js
@@ -766,3 +766,58 @@ describe("issue 46308", () => {
H.cartesianChartCircle().should("have.length", 3);
});
});
+
+describe("issue 38176", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsNormalUser();
+ cy.intercept("PUT", "/api/card/**").as("updateQuestion");
+ });
+
+ it("restoring a question to a previous version should preserve the variables (metabase#38176)", () => {
+ H.createNativeQuestion(
+ {
+ name: "38176",
+ native: {
+ query:
+ 'SELECT "COUNTRY" from "ACCOUNTS" WHERE country = {{ country }} LIMIT 5',
+ "template-tags": {
+ country: {
+ type: "text",
+ id: "dd06cd10-596b-41d0-9d6e-94e98ceaf989",
+ name: "country",
+ "display-name": "Country",
+ },
+ },
+ },
+ },
+ { visitQuestion: true },
+ );
+
+ cy.findByPlaceholderText("Country").type("NL");
+
+ cy.findByTestId("qb-header").icon("play").click();
+
+ H.questionInfoButton().click();
+ H.sidesheet().within(() => {
+ cy.findByPlaceholderText("Add description")
+ .type("This is a question")
+ .blur();
+
+ cy.wait("@updateQuestion");
+ cy.wait("@cardQuery");
+ cy.findByRole("tab", { name: "History" }).click();
+ cy.findByText(/added a description/i);
+ cy.findByTestId("question-revert-button").click();
+ cy.wait("@cardQuery");
+
+ cy.findByRole("tab", { name: "History" }).click();
+ cy.findByText(/reverted to an earlier version/i, {
+ timeout: 10000,
+ }).should("be.visible");
+ });
+
+ cy.findByLabelText("Close").click();
+ H.tableInteractive().should("contain", "NL");
+ });
+});
diff --git a/e2e/test/scenarios/native/native-reproductions.cy.spec.ts b/e2e/test/scenarios/native/native-reproductions.cy.spec.ts
index 64e1fd9be86..b7c22c81c26 100644
--- a/e2e/test/scenarios/native/native-reproductions.cy.spec.ts
+++ b/e2e/test/scenarios/native/native-reproductions.cy.spec.ts
@@ -8,15 +8,17 @@ import type {
IconName,
ListDatabasesResponse,
} from "metabase-types/api";
+import { createMockParameter } from "metabase-types/api/mocks";
import { getRunQueryButton } from "../native-filters/helpers/e2e-sql-filter-helpers";
const { ORDERS_ID, REVIEWS } = SAMPLE_DATABASE;
-describe("issue 11727", { tags: "@external" }, () => {
+describe("issues 11727, 14957, 15876", { tags: "@external" }, () => {
const PG_DB_ID = 2;
+ const PG_DB_NAME = "QA Postgres12";
- const questionDetails = {
+ const cancelQuestionDetails = {
dataset_query: {
type: "native",
database: PG_DB_ID,
@@ -26,14 +28,63 @@ describe("issue 11727", { tags: "@external" }, () => {
},
};
+ const timeCastQuestionDetails: NativeQuestionDetails = {
+ native: {
+ query: `select mytz as "ts", mytz::text as "tsAStext", state, mytz::time as "time - LOOK AT THIS COLUMN", mytz::time::text as "timeAStext", mytz::time(0) as "time(0) - ALL INCORRECT", mytz::time(3) as "time(3) - MOSTLY WORKING" from (
+ select '2022-05-04 16:29:59.268160-04:00'::timestamptz as mytz, 'incorrect' AS state union all
+ select '2022-05-04 16:29:59.412459-04:00'::timestamptz, 'good' union all
+ select '2022-05-08 13:14:42.926221-04:00'::timestamptz, 'incorrect' union all
+ select '2022-05-08 13:14:42.132026-04:00'::timestamptz, 'good' union all
+ select '2022-05-10 07:38:58.987352-04:00'::timestamptz, 'incorrect' union all
+ select '2022-05-10 07:38:58.001001-04:00'::timestamptz, 'good' union all
+ select '2022-05-12 11:01:23.000000-04:00'::timestamptz, 'ALWAYS incorrect' union all
+ select '2022-05-12 11:01:23.000-04:00'::timestamptz, 'ALWAYS incorrect' union all
+ select '2022-05-12 11:01:23-04:00'::timestamptz, 'ALWAYS incorrect'
+ )x`,
+ },
+ database: PG_DB_ID,
+ };
+
+ // time, time(0), time(3)
+ const castColumns = 3;
+
+ const correctValues = [
+ {
+ value: "1:29 PM",
+ rows: 2,
+ },
+ {
+ value: "10:14 AM",
+ rows: 2,
+ },
+ {
+ value: "4:38 AM",
+ rows: 2,
+ },
+ {
+ value: "8:01 AM",
+ rows: 3,
+ },
+ ];
+
beforeEach(() => {
H.restore("postgres-12");
cy.signInAsAdmin();
- cy.intercept("GET", "/api/database").as("getDatabases");
});
- it("should cancel the native query via the keyboard shortcut (metabase#11727)", () => {
- cy.visit("/question#" + H.adhocQuestionHash(questionDetails));
+ it("should correctly cast to `TIME`, cancel the native query via the keyboard shortcut, and save a question before query has been executed (metabase#15876, metabase#11727, metabase#14957)", () => {
+ H.createNativeQuestion(timeCastQuestionDetails, { visitQuestion: true });
+
+ cy.findByTestId("query-visualization-root").within(() => {
+ correctValues.forEach(({ value, rows }) => {
+ const count = rows * castColumns;
+
+ cy.findAllByText(value).should("have.length", count);
+ });
+ });
+
+ cy.intercept("GET", "/api/database").as("getDatabases");
+ cy.visit("/question#" + H.adhocQuestionHash(cancelQuestionDetails));
cy.wait("@getDatabases");
H.runNativeQuery({ wait: false });
@@ -44,6 +95,16 @@ describe("issue 11727", { tags: "@external" }, () => {
cy.findByTestId("query-builder-main")
.findByText("Here's where your results will appear")
.should("be.visible");
+
+ H.startNewNativeQuestion();
+
+ cy.findByTestId("gui-builder-data").click();
+ cy.findByLabelText(PG_DB_NAME).click();
+ H.NativeEditor.type("select pg_sleep(60)");
+ H.saveQuestion("14957", undefined, {
+ path: ["Our analytics"],
+ });
+ H.modal().should("not.exist");
});
});
@@ -251,17 +312,66 @@ describe("issue 53194", () => {
});
});
-describe("issue 53299", { tags: ["@mongo"] }, () => {
+describe("issues 53299, 47793", { tags: ["@external", "@mongo"] }, () => {
+ const MONGO_DB_ID = 2;
+
+ const questionDetails: NativeQuestionDetails = {
+ database: MONGO_DB_ID,
+ native: {
+ query: `[
+ { $match: { quantity: {{quantity}} }},
+ {
+ "$project": {
+ "_id": "$_id",
+ "id": "$id",
+ "user_id": "$user_id",
+ "product_id": "$product_id",
+ "subtotal": "$subtotal",
+ "tax": "$tax",
+ "total": "$total",
+ "created_at": "$created_at",
+ "quantity": "$quantity",
+ "discount": "$discount"
+ }
+ },
+ {
+ "$limit": 1048575
+ }
+]`,
+ "template-tags": {
+ quantity: {
+ type: "number",
+ name: "quantity",
+ id: "754ae827-661c-4fc9-b511-c0fb7b6bae2b",
+ "display-name": "Quantity",
+ default: "10",
+ },
+ },
+ collection: "orders",
+ },
+ };
+
beforeEach(() => {
H.restore("mongo-5");
cy.signInAsAdmin();
});
- it("should be possible to switch to mongodb when editing an sql question (metabase#53299)", () => {
+ it("should be possible to switch to mongodb when editing an sql question and to preview queries for mongodb (metabase#53299, metabase#47793)", () => {
H.startNewNativeQuestion();
H.selectNativeEditorDataSource("QA Mongo");
H.nativeEditorDataSource().should("contain", "QA Mongo");
+
+ H.createNativeQuestion(questionDetails, { visitQuestion: true });
+ cy.findByTestId("visibility-toggler")
+ .findByText(/open editor/i)
+ .click();
+ cy.findByTestId("native-query-editor-container")
+ .findByLabelText("Preview the query")
+ .click();
+ H.modal()
+ .should("contain.text", "$project")
+ .and("contain.text", "quantity: 10");
});
});
@@ -1012,3 +1122,130 @@ describe("issue 69160", () => {
.should("have.attr", "placeholder", "B");
});
});
+
+describe("issue 64293", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsNormalUser();
+ });
+
+ it("should be possible to run a query for a empty required parameter without a default value (metabase#64293)", () => {
+ const questionDetails: NativeQuestionDetails = {
+ name: "Question 1",
+ native: {
+ query: "SELECT * FROM PEOPLE WHERE state = {{State}}",
+ "template-tags": {
+ State: {
+ type: "text",
+ name: "State",
+ id: "1",
+ "display-name": "State",
+ },
+ },
+ },
+ parameters: [
+ createMockParameter({
+ id: "1",
+ slug: "State",
+ required: true,
+ name: "State",
+ }),
+ ],
+ };
+
+ H.createNativeQuestion(questionDetails, { visitQuestion: true });
+
+ cy.findByPlaceholderText("State").should("exist");
+ cy.findByPlaceholderText("State").type("NY{enter}");
+
+ H.runButtonOverlay().should("exist");
+ H.runButtonOverlay().click();
+
+ H.ensureParameterColumnValue({
+ columnName: "STATE",
+ columnValue: "NY",
+ });
+ });
+});
+
+describe("issue 68574", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+
+ const questionDetails: NativeQuestionDetails = {
+ name: "Question 1",
+ native: {
+ query: "SELECT * FROM ORDERS WHERE CREATED_AT > {{ start }}",
+ "template-tags": {
+ start: {
+ type: "date",
+ name: "start",
+ "display-name": "Start",
+ id: "1",
+ },
+ },
+ },
+ parameters: [
+ createMockParameter({
+ id: "1",
+ slug: "start",
+ required: true,
+ name: "Start",
+ type: "date/single",
+ target: ["variable", ["template-tag", "start"]],
+ }),
+ ],
+ };
+
+ H.createNativeQuestion(questionDetails, { wrapId: true });
+ });
+
+ it("should format a date parameter widget value according to the custom date formatting setting (metabase#68574)", () => {
+ updateFormattingSettings({
+ date_style: "D MMMM, YYYY",
+ date_abbreviate: false,
+ });
+ visitQuestion("2027-01-01");
+ assertParameterFormat("1 January, 2027");
+
+ cy.log("change the date format");
+ updateFormattingSettings({
+ date_style: "dddd, MMMM D, YYYY",
+ date_abbreviate: false,
+ });
+ visitQuestion("2027-01-01");
+ assertParameterFormat("Friday, January 1, 2027");
+
+ cy.log("enable date abbreviation");
+ updateFormattingSettings({
+ date_style: "dddd, MMMM D, YYYY",
+ date_abbreviate: true,
+ });
+ visitQuestion("2027-01-01");
+ assertParameterFormat("Fri, Jan 1, 2027");
+
+ cy.log("even when the setting is unset, it should render a valid format");
+ updateFormattingSettings(undefined);
+ visitQuestion("2027-01-01");
+ assertParameterFormat("January 1, 2027");
+ });
+
+ function updateFormattingSettings(settings: any) {
+ H.updateSetting("custom-formatting", {
+ "type/Temporal": settings,
+ });
+ }
+
+ function visitQuestion(value: string) {
+ cy.get("@questionId").then((id) => {
+ cy.visit(`/question/${id}?start=${value}`);
+ });
+ }
+
+ function assertParameterFormat(value: string) {
+ cy.findByTestId("parameter-value-widget-target")
+ .should("be.visible")
+ .should("contain.text", value);
+ }
+});
diff --git a/e2e/test/scenarios/native/native.cy.spec.js b/e2e/test/scenarios/native/native.cy.spec.js
index 85be523e861..983431ea781 100644
--- a/e2e/test/scenarios/native/native.cy.spec.js
+++ b/e2e/test/scenarios/native/native.cy.spec.js
@@ -326,7 +326,9 @@ describe("scenarios > question > native", () => {
cy.get("@sidebar").contains(/added/i);
});
- it("should not autorun ad-hoc native queries by default", () => {
+ it("should not autorun ad-hoc native queries by default or native queries after updating a question (metabase#30165)", () => {
+ cy.intercept("POST", "/api/dataset").as("adhocDataset");
+
H.visitQuestionAdhoc(
{
display: "scalar",
@@ -343,6 +345,35 @@ describe("scenarios > question > native", () => {
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("Here's where your results will appear").should("be.visible");
+ cy.get("@adhocDataset.all").should("have.length", 0);
+
+ cy.intercept("POST", "/api/dataset").as("dataset");
+ cy.intercept("POST", "/api/card/*/query").as("cardQuery");
+ cy.intercept("PUT", "/api/card/*").as("updateQuestion");
+
+ H.startNewNativeQuestion();
+ H.NativeEditor.type("SELECT * FROM ORDERS");
+ H.saveQuestionToCollection("Q1");
+
+ H.NativeEditor.focus().type(" WHERE TOTAL < 20");
+ H.queryBuilderHeader().findByText("Save").click();
+ cy.findByTestId("save-question-modal").within(() => {
+ cy.findByText("Save").click();
+ });
+ cy.wait("@updateQuestion");
+
+ H.NativeEditor.focus().type(" LIMIT 10");
+ H.queryBuilderHeader().findByText("Save").click();
+ cy.findByTestId("save-question-modal").within(() => {
+ cy.findByText("Save").click();
+ });
+ cy.wait("@updateQuestion");
+
+ cy.get("@dataset.all").should("have.length", 0);
+ cy.get("@cardQuery.all").should("have.length", 0);
+ cy.findByTestId("query-builder-main")
+ .findByText("Here's where your results will appear")
+ .should("be.visible");
});
it("should allow to preview a fully parameterized query", () => {
diff --git a/e2e/test/scenarios/question/multiple-column-breakouts.cy.spec.ts b/e2e/test/scenarios/question/multiple-column-breakouts.cy.spec.ts
index 1a2c9c5d819..2e504a343b6 100644
--- a/e2e/test/scenarios/question/multiple-column-breakouts.cy.spec.ts
+++ b/e2e/test/scenarios/question/multiple-column-breakouts.cy.spec.ts
@@ -286,12 +286,14 @@ describe("scenarios > question > multiple column breakouts", () => {
bucketLabel,
bucket1Name,
bucket2Name,
+ columns,
}: {
tableName: string;
columnName: string;
bucketLabel: string;
bucket1Name: string;
bucket2Name: string;
+ columns: string[];
}) {
H.startNewQuestion();
H.miniPicker().within(() => {
@@ -324,6 +326,8 @@ describe("scenarios > question > multiple column breakouts", () => {
H.popover().last().findByText(bucket2Name).click();
H.visualize();
cy.wait("@dataset");
+ H.queryBuilderFooter().findByLabelText("Switch to data").click();
+ H.assertTableData({ columns });
}
cy.log("temporal breakouts");
@@ -333,6 +337,7 @@ describe("scenarios > question > multiple column breakouts", () => {
bucketLabel: "Temporal bucket",
bucket1Name: "Year",
bucket2Name: "Month",
+ columns: ["Created At: Year", "Created At: Month", "Count"],
});
H.assertQueryBuilderRowCount(49);
@@ -343,6 +348,7 @@ describe("scenarios > question > multiple column breakouts", () => {
bucketLabel: "Binning strategy",
bucket1Name: "10 bins",
bucket2Name: "50 bins",
+ columns: ["Total: 10 bins", "Total: 50 bins", "Count"],
});
H.assertQueryBuilderRowCount(32);
@@ -353,6 +359,7 @@ describe("scenarios > question > multiple column breakouts", () => {
bucketLabel: "Binning strategy",
bucket1Name: "Bin every 10 degrees",
bucket2Name: "Bin every 20 degrees",
+ columns: ["Latitude: 10°", "Latitude: 20°", "Count"],
});
H.assertQueryBuilderRowCount(6);
});
@@ -606,13 +613,15 @@ describe("scenarios > question > multiple column breakouts", () => {
});
});
- it("should be able to change pivot split settings when there are more than 2 breakouts", () => {
+ it("should be able to change pivot split settings when there are more than 2 breakouts and not move columns items into measures and vice-versa", () => {
function testPivotSplit({
questionDetails,
columnNamePattern,
+ testMeasureMoves = false,
}: {
questionDetails: StructuredQuestionDetails;
columnNamePattern: RegExp;
+ testMeasureMoves?: boolean;
}) {
H.createQuestion(questionDetails, { visitQuestion: true });
@@ -626,8 +635,42 @@ describe("scenarios > question > multiple column breakouts", () => {
.findAllByText(columnNamePattern)
.should("have.length", 3);
- cy.log("move a column from rows to columns");
H.openVizSettingsSidebar();
+
+ if (testMeasureMoves) {
+ const assertBreakoutsBeforeMeasure = () => {
+ H.getDraggableElements().should(($items) => {
+ expect($items).to.have.length(6);
+ $items.slice(0, 5).each((_index, item) => {
+ expect(item.getAttribute("data-testid")).to.match(
+ /^draggable-item-Created At: /,
+ );
+ });
+ expect($items.eq(5)).to.have.attr(
+ "data-testid",
+ "draggable-item-Count",
+ );
+ });
+ };
+
+ assertBreakoutsBeforeMeasure();
+
+ cy.log("move an item from columns to measures");
+ H.moveDnDKitListElement("drag-handle", {
+ startIndex: 2,
+ dropIndex: 5,
+ });
+ assertBreakoutsBeforeMeasure();
+
+ cy.log("move an item from measures to columns");
+ H.moveDnDKitListElement("drag-handle", {
+ startIndex: 5,
+ dropIndex: 2,
+ });
+ assertBreakoutsBeforeMeasure();
+ }
+
+ cy.log("move a column from rows to columns");
H.moveDnDKitListElement("drag-handle", {
startIndex: 2,
dropIndex: 3,
@@ -652,6 +695,7 @@ describe("scenarios > question > multiple column breakouts", () => {
testPivotSplit({
questionDetails: questionWith5TemporalBreakoutsDetails,
columnNamePattern: /^Created At/,
+ testMeasureMoves: true,
});
cy.log("'num-bins' breakouts");
@@ -660,43 +704,6 @@ describe("scenarios > question > multiple column breakouts", () => {
columnNamePattern: /^Total: \d+ bins$/,
});
});
-
- it("should not be able to move columns items into measures and vice-versa", () => {
- H.createQuestion(questionWith5TemporalBreakoutsDetails, {
- visitQuestion: true,
- });
-
- const columnNamePattern = /^Created At/;
-
- cy.log("change display and assert the default settings");
- H.openVizTypeSidebar();
- cy.findByTestId("chart-type-sidebar")
- .findByTestId("Pivot Table-button")
- .click();
- cy.wait("@pivotDataset");
- cy.findByTestId("pivot-table")
- .findAllByText(columnNamePattern)
- .should("have.length", 3);
-
- cy.log("move an item from columns to measures");
- H.openVizSettingsSidebar();
- H.moveDnDKitListElement("drag-handle", {
- startIndex: 2,
- dropIndex: 5,
- });
- cy.findByTestId("pivot-table")
- .findAllByText(columnNamePattern)
- .should("have.length", 3);
-
- cy.log("move an item from measures to columns");
- H.moveDnDKitListElement("drag-handle", {
- startIndex: 5,
- dropIndex: 2,
- });
- cy.findByTestId("pivot-table")
- .findAllByText(columnNamePattern)
- .should("have.length", 3);
- });
});
describe("dashboards", () => {
@@ -809,7 +816,6 @@ describe("scenarios > question > multiple column breakouts", () => {
cy.wait("@dataset");
}
- // Fragile and bound to break when the year changes
cy.log("temporal breakouts");
testDatePostAggregationExpression({
questionDetails: questionWith2TemporalBreakoutsDetails,
@@ -839,7 +845,7 @@ describe("scenarios > question > multiple column breakouts", () => {
testDatePostAggregationExpression({
questionDetails: questionWith2NumBinsBreakoutsDetails,
expression1: "[Total: 10 bins] + 100",
- expression2: "[Total: 10 bins] + 200",
+ expression2: "[Total: 50 bins] + 200",
});
H.assertTableData({
@@ -850,10 +856,10 @@ describe("scenarios > question > multiple column breakouts", () => {
"Expression1",
"Expression2",
],
- firstRows: [["-60 – -40", "-50 – -45", "1", "40", "140"]],
+ firstRows: [["-60 – -40", "-50 – -45", "1", "40", "150"]],
});
- cy.log("'max-bins' breakouts");
+ cy.log("'bin-width' breakouts");
testDatePostAggregationExpression({
questionDetails: questionWith2BinWidthBreakoutsDetails,
expression1: "[Latitude: 20°] + 100",
@@ -1103,7 +1109,7 @@ describe("scenarios > question > multiple column breakouts", () => {
firstRows: [["-60", "155"]],
});
- cy.log("'max-bins' breakouts");
+ cy.log("'bin-width' breakouts");
testPostAggregationAggregation({
questionDetails: questionWith2BinWidthBreakoutsDetails,
column1Name: "Latitude: 20°",
@@ -1178,7 +1184,7 @@ describe("scenarios > question > multiple column breakouts", () => {
],
});
- cy.log("'max-bins' breakouts");
+ cy.log("'bin-width' breakouts");
testPostAggregationBreakout({
questionDetails: questionWith2BinWidthBreakoutsDetails,
column1Name: "Latitude: 20°",
@@ -1341,19 +1347,8 @@ describe("scenarios > question > multiple column breakouts", () => {
});
});
-function tableHeaderClick(
- columnName: string,
- { columnIndex = 0 }: { columnIndex?: number } = {},
-) {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.tableInteractive()
- .findAllByText(columnName)
- .eq(columnIndex)
- .trigger("mousedown");
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.tableInteractive()
- .findAllByText(columnName)
- .eq(columnIndex)
- .trigger("mouseup");
+function tableHeaderClick(columnName: string) {
+ H.tableInteractive().findAllByText(columnName).eq(0).trigger("mousedown");
+
+ H.tableInteractive().findAllByText(columnName).eq(0).trigger("mouseup");
}
diff --git a/e2e/test/scenarios/question/native-query-drill.cy.spec.ts b/e2e/test/scenarios/question/native-query-drill.cy.spec.ts
index 5d1af69f2da..eaf54a7f57a 100644
--- a/e2e/test/scenarios/question/native-query-drill.cy.spec.ts
+++ b/e2e/test/scenarios/question/native-query-drill.cy.spec.ts
@@ -96,6 +96,7 @@ describe("scenarios > question > native query drill", () => {
H.tableInteractive().findByText("October 7, 2026, 1:34 AM").click();
H.popover().within(() => {
+ cy.button("Save").should("be.visible");
cy.findByText("Filter by this date and time").should("not.exist");
cy.button("Save").click();
});
@@ -115,9 +116,9 @@ describe("scenarios > question > native query drill", () => {
});
});
- describe("query builder drills", () => {
- it("column-extract drill", () => {
- cy.log("from column header");
+ describe("query builder drills and brush filters", () => {
+ it("column-extract, column-filter, distribution, sort, summarize, and summarize-column-by-time drills", () => {
+ cy.log("column-extract drill: from column header");
H.createNativeQuestion(ordersTableQuestionDetails, {
visitQuestion: true,
wrapId: true,
@@ -136,7 +137,7 @@ describe("scenarios > question > native query drill", () => {
],
});
- cy.log("from plus button");
+ cy.log("column-extract drill: from plus button");
H.visitQuestion("@questionId");
H.tableInteractive().button("Add column").click();
H.popover().within(() => {
@@ -152,53 +153,9 @@ describe("scenarios > question > native query drill", () => {
["2", "May 15, 2027, 8:04 AM", "3", "Q2"],
],
});
- });
- it("combine-columns drill", () => {
- cy.log("from column header");
- H.createNativeQuestion(peopleTableQuestionDetails, {
- visitQuestion: true,
- wrapId: true,
- });
- H.tableHeaderClick("EMAIL");
- H.popover().findByText("Combine columns").click();
- H.popover().button("Done").click();
- cy.wait("@dataset");
- H.assertTableData({
- columns: ["ID", "EMAIL", "CREATED_AT", "Combined EMAIL, ID"],
- firstRows: [
- [
- "1",
- "October 7, 2026, 1:34 AM",
- ],
- ],
- });
-
- cy.log("from plus button");
+ cy.log("column-filter drill");
H.visitQuestion("@questionId");
- H.tableInteractive().button("Add column").click();
- H.popover().findByText("Combine columns").click();
- H.popover().button("Done").click();
- cy.wait("@dataset");
- H.assertTableData({
- columns: ["ID", "EMAIL", "CREATED_AT", "Combined ID, EMAIL"],
- firstRows: [
- [
- "1",
- "October 7, 2026, 1:34 AM",
- ],
- ],
- });
- });
-
- it("column-filter drill", () => {
- H.createNativeQuestion(ordersTableQuestionDetails, {
- visitQuestion: true,
- });
H.assertQueryBuilderRowCount(10);
H.tableHeaderClick("QUANTITY");
H.popover().findByText("Filter by this column").click();
@@ -209,12 +166,9 @@ describe("scenarios > question > native query drill", () => {
cy.wait("@dataset");
});
H.assertQueryBuilderRowCount(8);
- });
- it("distribution drill", () => {
- H.createNativeQuestion(ordersTableQuestionDetails, {
- visitQuestion: true,
- });
+ cy.log("distribution drill");
+ H.visitQuestion("@questionId");
H.tableHeaderClick("QUANTITY");
H.popover().findByText("Distribution").click();
cy.wait("@dataset");
@@ -223,28 +177,9 @@ describe("scenarios > question > native query drill", () => {
cy.findByText("QUANTITY: 8 bins").should("be.visible");
});
H.assertQueryBuilderRowCount(5);
- });
-
- it("quick-filter drill", () => {
- H.createNativeQuestion(timeseriesLineQuestionDetails, {
- visitQuestion: true,
- });
- H.assertQueryBuilderRowCount(10);
- H.cartesianChartCircle().eq(0).click();
- H.popover().within(() => {
- cy.findByText("Filter by this value").should("be.visible");
- cy.findByText("=").click();
- cy.wait("@dataset");
- });
- H.assertQueryBuilderRowCount(3);
- });
- it("sort drill", () => {
- cy.log("ascending");
- H.createNativeQuestion(ordersTableQuestionDetails, {
- visitQuestion: true,
- wrapId: true,
- });
+ cy.log("sort drill: ascending");
+ H.visitQuestion("@questionId");
H.tableHeaderClick("QUANTITY");
H.popover().icon("arrow_up").click();
cy.wait("@dataset");
@@ -253,7 +188,7 @@ describe("scenarios > question > native query drill", () => {
firstRows: [["1", "February 11, 2028, 9:40 PM", "2"]],
});
- cy.log("descending");
+ cy.log("sort drill: descending");
H.visitQuestion("@questionId");
H.tableHeaderClick("QUANTITY");
H.popover().icon("arrow_down").click();
@@ -262,14 +197,9 @@ describe("scenarios > question > native query drill", () => {
columns: ["ID", "CREATED_AT", "QUANTITY"],
firstRows: [["8", "June 17, 2028, 2:37 AM", "7"]],
});
- });
- it("summarize drill", () => {
- cy.log("distinct values");
- H.createNativeQuestion(ordersTableQuestionDetails, {
- visitQuestion: true,
- wrapId: true,
- });
+ cy.log("summarize drill: distinct values");
+ H.visitQuestion("@questionId");
H.tableHeaderClick("QUANTITY");
H.popover().findByText("Distinct values").click();
cy.wait("@dataset");
@@ -278,7 +208,7 @@ describe("scenarios > question > native query drill", () => {
firstRows: [["5"]],
});
- cy.log("sum");
+ cy.log("summarize drill: sum");
H.visitQuestion("@questionId");
H.tableHeaderClick("QUANTITY");
H.popover().findByText("Sum").click();
@@ -288,7 +218,7 @@ describe("scenarios > question > native query drill", () => {
firstRows: [["38"]],
});
- cy.log("avg");
+ cy.log("summarize drill: avg");
H.visitQuestion("@questionId");
H.tableHeaderClick("QUANTITY");
H.popover().findByText("Avg").click();
@@ -297,12 +227,9 @@ describe("scenarios > question > native query drill", () => {
columns: ["Average of QUANTITY"],
firstRows: [["3.8"]],
});
- });
- it("summarize-column-by-time drill", () => {
- H.createNativeQuestion(ordersTableQuestionDetails, {
- visitQuestion: true,
- });
+ cy.log("summarize-column-by-time drill");
+ H.visitQuestion("@questionId");
H.tableHeaderClick("QUANTITY");
H.popover().findByText("Sum over time").click();
cy.wait("@dataset");
@@ -316,40 +243,83 @@ describe("scenarios > question > native query drill", () => {
});
});
- it("unsupported drills", () => {
- cy.log("aggregated cell click");
+ it("combine-columns drill", () => {
+ cy.log("from column header");
+ H.createNativeQuestion(peopleTableQuestionDetails, {
+ visitQuestion: true,
+ wrapId: true,
+ });
+ H.tableHeaderClick("EMAIL");
+ H.popover().findByText("Combine columns").click();
+ H.popover().button("Done").click();
+ cy.wait("@dataset");
+ H.assertTableData({
+ columns: ["ID", "EMAIL", "CREATED_AT", "Combined EMAIL, ID"],
+ firstRows: [
+ [
+ "1",
+ "October 7, 2026, 1:34 AM",
+ ],
+ ],
+ });
+
+ cy.log("from plus button");
+ H.visitQuestion("@questionId");
+ H.tableInteractive().button("Add column").click();
+ H.popover().findByText("Combine columns").click();
+ H.popover().button("Done").click();
+ cy.wait("@dataset");
+ H.assertTableData({
+ columns: ["ID", "EMAIL", "CREATED_AT", "Combined ID, EMAIL"],
+ firstRows: [
+ [
+ "1",
+ "October 7, 2026, 1:34 AM",
+ ],
+ ],
+ });
+ });
+
+ it("quick-filter drill, unsupported aggregated cell drills, and timeseries brush filter", () => {
H.createNativeQuestion(timeseriesLineQuestionDetails, {
visitQuestion: true,
+ wrapId: true,
});
H.assertQueryBuilderRowCount(10);
H.cartesianChartCircle().eq(0).click();
H.popover().within(() => {
+ cy.findByText("Filter by this value").should("be.visible");
cy.findByText(/See these/).should("not.exist");
cy.findByText(/Breakout by/).should("not.exist");
cy.findByText(/Automatic insights/).should("not.exist");
+ cy.findByText("=").click();
+ cy.wait("@dataset");
});
+ H.assertQueryBuilderRowCount(3);
- cy.log("legend item click");
- H.createNativeQuestion(timeseriesWithCategoryLineQuestionDetails, {
- visitQuestion: true,
- });
- cy.findByTestId("visualization-root").findByText("Gadget").click();
- cy.findByRole("tooltip").should("not.exist");
- });
- });
-
- describe("query builder brush filters", () => {
- it("timeseries filter", () => {
- H.createNativeQuestion(timeseriesLineQuestionDetails, {
- visitQuestion: true,
- });
+ H.visitQuestion("@questionId");
H.assertQueryBuilderRowCount(10);
applyBrushFilter({ left: 200, right: 800 });
cy.wait("@dataset");
H.assertQueryBuilderRowCount(4);
});
- it("numeric filter", () => {
+ it("legend item click has no drills", () => {
+ H.createNativeQuestion(timeseriesWithCategoryLineQuestionDetails, {
+ visitQuestion: true,
+ });
+ cy.findByTestId("visualization-root")
+ .findByText("Gadget")
+ .should("be.visible")
+ .click();
+ cy.get(H.POPOVER_ELEMENT).should("not.exist");
+ });
+
+ it("numeric brush filter", () => {
H.createNativeQuestion(numericLineQuestionDetails, {
visitQuestion: true,
});
@@ -359,7 +329,7 @@ describe("scenarios > question > native query drill", () => {
H.assertQueryBuilderRowCount(5);
});
- it("coordinates filter", () => {
+ it("coordinates brush filter", () => {
cy.log("pin map");
H.createNativeQuestion(pinMapQuestionDetails, { visitQuestion: true });
cy.findByTestId("visualization-root").realHover();
diff --git a/e2e/test/scenarios/question/nested.cy.spec.js b/e2e/test/scenarios/question/nested.cy.spec.js
index 245d0a22120..772a1e80b3e 100644
--- a/e2e/test/scenarios/question/nested.cy.spec.js
+++ b/e2e/test/scenarios/question/nested.cy.spec.js
@@ -84,13 +84,7 @@ describe("scenarios > question > nested", () => {
name: "15725",
native: { query: "select 'A' as cat, 5 as val" },
});
- // Window object gets recreated for every `cy.visit`
- // See: https://stackoverflow.com/a/65218352/8815185
- cy.visit("/", {
- onBeforeLoad(win) {
- cy.spy(win.console, "warn").as("consoleWarn");
- },
- });
+ cy.visit("/");
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("New").click();
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
@@ -121,12 +115,7 @@ describe("scenarios > question > nested", () => {
H.visualize();
- cy.get("@consoleWarn").should(
- "not.be.calledWith",
- "Removing invalid MBQL clause",
- );
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Sum of VAL");
+ assertCountAndSumByCategory();
});
it("Count of rows by CAT + add sum of VAL later from the sidebar (metabase#15725-2)", () => {
@@ -142,14 +131,19 @@ describe("scenarios > question > nested", () => {
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText(/^Sum of/).click();
H.popover().findByText("VAL").click();
- cy.wait("@dataset").then((xhr) => {
- expect(xhr.response.body.error).not.to.exist;
- });
- cy.get("@consoleWarn").should(
- "not.be.calledWith",
- "Removing invalid MBQL clause",
- );
+ cy.wait("@dataset");
+ H.rightSidebar().button("Done").click();
+
+ assertCountAndSumByCategory();
});
+
+ function assertCountAndSumByCategory() {
+ H.queryBuilderFooter().findByLabelText("Switch to data").click();
+ H.assertTableData({
+ columns: ["CAT", "Count", "Sum of VAL"],
+ firstRows: [["A", "1", "5"]],
+ });
+ }
});
it("should properly work with native questions (metabase#15808, metabase#16938, metabase#18364)", () => {
@@ -205,11 +199,10 @@ describe("scenarios > question > nested", () => {
H.saveQuestionToCollection();
- cy.wait("@cardCreated").then(({ response: { body } }) => {
- expect(body.error).not.to.exist;
- });
+ cy.wait("@cardCreated");
- cy.button("Failed").should("not.exist");
+ cy.location("pathname").should("match", /^\/question\/\d+/);
+ cy.findByTestId("save-question-modal").should("not.exist");
}
});
});
diff --git a/e2e/test/scenarios/question/new.cy.spec.js b/e2e/test/scenarios/question/new.cy.spec.js
index a43618b6b2b..595c5249336 100644
--- a/e2e/test/scenarios/question/new.cy.spec.js
+++ b/e2e/test/scenarios/question/new.cy.spec.js
@@ -64,12 +64,16 @@ describe("scenarios > question > new", () => {
// Discarding the search query should take us back to the original tab
cy.findByPlaceholderText("Search…").clear().blur();
- cy.get("[role='tab']:contains('Search')").should("not.exist");
+ H.entityPickerModalLevel(0)
+ .findByText(/Search results for /)
+ .should("not.exist");
cy.findByText("Orders, Count").click();
});
cy.log("toggle notebook button should be hidden for brand new questions");
+ cy.findByTestId("data-step-cell").should("contain", "Orders, Count");
+ cy.findByTestId("qb-header-action-panel").should("exist");
H.notebookButton().should("not.exist");
H.visualize();
@@ -172,6 +176,7 @@ describe("scenarios > question > new", () => {
cy.findByText("Personal question").click();
});
H.visualize();
+ H.tableInteractiveBody().findByText("39.72").should("be.visible");
});
});
@@ -190,17 +195,17 @@ describe("scenarios > question > new", () => {
cy.get(".test-TableInteractive-cellWrapper--lastColumn").eq(0).click();
cy.wait("@dataset");
- H.tableInteractiveBody()
- .get(".test-TableInteractive-cellWrapper--firstColumn")
- .should("have.length.gt", 1);
-
cy.log(
"**Reported at v0.34.3 - v0.37.0.2 / probably was always like this**",
);
cy.log(
"**It should display the table with all orders with the selected quantity.**",
);
- H.tableInteractive();
+ cy.findByTestId("filter-pill").should("have.text", "Quantity is 2");
+ cy.findByTestId("object-detail").should("not.exist");
+ H.tableInteractiveBody()
+ .find(".test-TableInteractive-cellWrapper--firstColumn")
+ .should("have.length.gt", 1);
cy.get(".test-TableInteractive-cellWrapper--firstColumn") // ID (first in the default order for Sample Database)
.eq(0) // first table body cell
@@ -210,7 +215,7 @@ describe("scenarios > question > new", () => {
cy.log("only one row should appear after filtering by ID");
H.tableInteractiveBody()
- .get(".test-TableInteractive-cellWrapper--firstColumn")
+ .find(".test-TableInteractive-cellWrapper--firstColumn")
.should("have.length", 1);
});
@@ -273,7 +278,6 @@ describe("scenarios > question > new", () => {
it("should not suggest recent items where can_write=false when saving a question", () => {
// SETUP TEST - prevent normal user from having access to third collection w/ added content
cy.log("setup restricted permissions scenario");
- cy.signInAsAdmin();
// create dashboard that will have restricted access
H.createDashboard(
@@ -485,7 +489,7 @@ describe("scenarios > question > new", () => {
H.queryBuilderHeader().button("Save").click();
- cy.findByTestId("save-question-modal").within((modal) => {
+ cy.findByTestId("save-question-modal").within(() => {
cy.findByLabelText(/Where do you want to save/).click();
});
@@ -503,7 +507,6 @@ describe("scenarios > question > new", () => {
});
it("when selecting a collection", () => {
- // H.miniPickerBrowseAll().click();
H.entityPickerModal().within(() => {
H.pickEntity({
path: ["Our analytics", "Collection in root collection"],
@@ -622,7 +625,7 @@ describe(
cy.signInAsAdmin();
});
- it("can create a question from the sample database", () => {
+ it("can create a question from the sample database or a saved question, and shows models and raw data options after creating a model", () => {
cy.visit("/question/new");
H.miniPickerBrowseAll().click();
@@ -634,9 +637,7 @@ describe(
H.tableInteractive().within(() => {
cy.findByText("Rustic Paper Wallet").should("be.visible");
});
- });
- it("can create a question from a saved question", () => {
cy.visit("/question/new");
H.miniPickerBrowseAll().click();
@@ -648,9 +649,7 @@ describe(
H.tableInteractive().within(() => {
cy.findByText(39.72).should("be.visible");
});
- });
- it("shows models and raw data options after creating a model", () => {
H.createQuestion({
name: "Orders Model",
query: { "source-table": ORDERS_ID },
@@ -672,7 +671,10 @@ describe(
H.miniPickerBrowseAll().click();
H.entityPickerModal().within(() => {
cy.findByText("Recent items").click();
- cy.findByTestId("result-item").should("contain.text", "Orders Model");
+ // Recents are sorted newest first, and the model was picked last
+ cy.findAllByTestId("result-item")
+ .first()
+ .should("contain.text", "Orders Model");
});
});
},
diff --git a/e2e/test/scenarios/question/notebook-data-source.cy.spec.ts b/e2e/test/scenarios/question/notebook-data-source.cy.spec.ts
index 569b99491fa..3e22a460194 100644
--- a/e2e/test/scenarios/question/notebook-data-source.cy.spec.ts
+++ b/e2e/test/scenarios/question/notebook-data-source.cy.spec.ts
@@ -26,7 +26,7 @@ describe("scenarios > notebook > data source", () => {
H.miniPickerBrowseAll().click();
H.entityPickerModal().within(() => {
- // databases is selected already
+ assertDataPickerEntitySelected(0, "Databases");
H.entityPickerModalLevel(1).findByText("Sample Database").click();
assertDataPickerEntityNotSelected(2, "Accounts");
assertDataPickerEntityNotSelected(2, "Analytic Events");
@@ -70,6 +70,18 @@ describe("scenarios > notebook > data source", () => {
assertDataPickerEntitySelected(2, "Orders");
});
+ it("should correctly display a table as the model's source when editing simple model's query", () => {
+ cy.visit(`/model/${ORDERS_MODEL_ID}/query`);
+
+ cy.findByTestId("data-step-cell").should("have.text", "Orders").click();
+ H.miniPicker().within(() => {
+ H.miniPickerHeader().should("contain", "Sample Database");
+ cy.findByText("Orders").should("exist");
+ });
+ });
+ });
+
+ describe("multi-schema table as a source", () => {
it(
"should correctly display a table from a multi-schema database (metabase#39807,metabase#11958)",
{ tags: "@external" },
@@ -130,22 +142,29 @@ describe("scenarios > notebook > data source", () => {
H.miniPicker().within(() => {
cy.findByText(dbName).click();
cy.findByText("Domestic").click();
+ cy.findByText("Animals").should("be.visible");
+ cy.findByText("Birds").should("not.exist");
cy.findByText("Animals").click();
});
H.popover().findByText("Name").click();
H.popover().findByText("Name").click();
+
+ cy.log("select a table that only exists in the first schema");
+ H.join();
+ H.miniPicker().within(() => {
+ cy.findByText(dbName).click();
+ cy.findByText(schemaName).click();
+ cy.findByText("Animals").should("be.visible");
+ cy.findByText("Birds").click();
+ });
+ H.popover().findByText("Name").click();
+ H.popover().findByText("Name").click();
+ H.getNotebookStep("join", { stage: 0, index: 2 })
+ .findByLabelText("Right table")
+ .findByText("Birds")
+ .should("be.visible");
},
);
-
- it("should correctly display a table as the model's source when editing simple model's query", () => {
- cy.visit(`/model/${ORDERS_MODEL_ID}/query`);
-
- cy.findByTestId("data-step-cell").should("have.text", "Orders").click();
- H.miniPicker().within(() => {
- H.miniPickerHeader().should("contain", "Sample Database");
- cy.findByText("Orders").should("exist");
- });
- });
});
describe("library table as a source", () => {
@@ -156,11 +175,11 @@ describe("scenarios > notebook > data source", () => {
H.createLibrary();
});
- it("should allow to pick a published table from the mini picker", () => {
+ it("should allow to pick a published table from the mini picker and the data picker", () => {
H.publishTables({ table_ids: [ORDERS_ID, PRODUCTS_ID] });
H.startNewQuestion();
- cy.log("verify the picker when nothing is selected");
+ cy.log("mini picker: verify the picker when nothing is selected");
H.popover().findByText("Orders").click();
H.join();
H.popover().findByText("Products").click();
@@ -168,18 +187,41 @@ describe("scenarios > notebook > data source", () => {
H.tableHeaderColumn("User ID").should("be.visible");
H.tableHeaderColumn("Products → ID").should("be.visible");
- cy.log("verify the picker when there is a selected item");
+ cy.log("data picker: verify the picker when there is a selected item");
H.openNotebook();
H.getNotebookStep("data").findByText("Orders").click();
+ H.popover().within(() => {
+ cy.findByText("Data").click();
+ cy.findByText("Browse all").click();
+ });
+
+ H.entityPickerModal().within(() => {
+ H.entityPickerModalItem(0, "Library").should(
+ "have.attr",
+ "data-active",
+ "true",
+ );
+ H.entityPickerModalItem(1, "Data").should(
+ "have.attr",
+ "data-active",
+ "true",
+ );
+ H.entityPickerModalItem(2, "Orders").should(
+ "have.attr",
+ "data-active",
+ "true",
+ );
+ });
+ H.entityPickerModal().button("Close").click();
+
+ cy.log("mini picker: verify the picker when there is a selected item");
+ H.getNotebookStep("data").findByText("Orders").click();
H.popover().findByText("Products").click();
H.getNotebookStep("data").findByText("Products").should("be.visible");
- });
- it("should allow to pick a publish table from the data picker", () => {
- H.publishTables({ table_ids: [ORDERS_ID, PRODUCTS_ID] });
H.startNewQuestion();
- cy.log("verify the picker when nothing is selected");
+ cy.log("data picker: verify the picker when nothing is selected");
H.popover().findByText("Browse all").click();
H.entityPickerModal().within(() => {
H.entityPickerModalLevel(0).findByText("Library").click();
@@ -198,31 +240,6 @@ describe("scenarios > notebook > data source", () => {
H.visualize();
H.tableHeaderColumn("User ID").should("be.visible");
H.tableHeaderColumn("Products → ID").should("be.visible");
-
- H.openNotebook();
- H.getNotebookStep("data").findByText("Orders").click();
- H.popover().within(() => {
- cy.findByText("Data").click();
- cy.findByText("Browse all").click();
- });
-
- H.entityPickerModal().within(() => {
- H.entityPickerModalItem(0, "Library").should(
- "have.attr",
- "data-active",
- "true",
- );
- H.entityPickerModalItem(1, "Data").should(
- "have.attr",
- "data-active",
- "true",
- );
- H.entityPickerModalItem(2, "Orders").should(
- "have.attr",
- "data-active",
- "true",
- );
- });
});
});
@@ -364,10 +381,10 @@ describe("issue 34350", { tags: "@external" }, () => {
H.visualize();
+ cy.findAllByTestId("cell-data").should("contain", "37.65");
H.queryBuilderMain()
.findByText("There was a problem with your question")
.should("not.exist");
- cy.findAllByTestId("cell-data").should("contain", "37.65");
});
});
@@ -469,6 +486,8 @@ describe("issue 32252", () => {
H.newButton("Question").click();
H.miniPicker().within(() => {
cy.findByText("Our analytics").click();
+ H.miniPickerHeader().should("contain", "Our analytics");
+ cy.findByTestId("mini-picker-list-loader").should("not.exist");
cy.findByText("My collection").should("not.exist");
cy.findByText("My question").should("not.exist");
});
@@ -499,6 +518,8 @@ describe("issue 32252", () => {
H.newButton("Question").click();
H.miniPicker().within(() => {
cy.findByText("Our analytics").click();
+ H.miniPickerHeader().should("contain", "Our analytics");
+ cy.findByTestId("mini-picker-list-loader").should("not.exist");
cy.findByText("My collection").should("not.exist");
cy.findByText("My question").should("not.exist");
});
diff --git a/e2e/test/scenarios/question/notebook-link-to-data-source.cy.spec.ts b/e2e/test/scenarios/question/notebook-link-to-data-source.cy.spec.ts
index b04f3e05fd7..f52aa64f2b3 100644
--- a/e2e/test/scenarios/question/notebook-link-to-data-source.cy.spec.ts
+++ b/e2e/test/scenarios/question/notebook-link-to-data-source.cy.spec.ts
@@ -401,11 +401,23 @@ describe("scenarios > notebook > link to data source", () => {
});
context("permissions", () => {
- it("shouldn't show the source question if it lives in a collection that user can't see", () => {
+ it("shouldn't show the source question to users without write query permissions or if it lives in a collection that user can't see", () => {
H.createQuestion({
name: "Nested question based on a question",
query: { "source-table": `card__${ORDERS_COUNT_QUESTION_ID}` },
}).then(({ body: nestedQuestion }) => {
+ cy.log(
+ "A user with curate collection permissions but without write query permissions should not see the notebook icon",
+ );
+ cy.signIn("nodata");
+ H.visitQuestion(nestedQuestion.id);
+ cy.findByTestId("qb-header-action-panel").should("be.visible");
+ cy.findByTestId("qb-header-action-panel")
+ .icon("notebook")
+ .should("not.exist");
+
+ cy.signInAsAdmin();
+
cy.log("Move the source question to admin's personal collection");
cy.request("PUT", `/api/card/${ORDERS_COUNT_QUESTION_ID}`, {
collection_id: ADMIN_PERSONAL_COLLECTION_ID,
@@ -446,24 +458,6 @@ describe("scenarios > notebook > link to data source", () => {
});
});
- it("user with the curate collection permissions but without write query permissions shouldn't be able to see/open the source question", () => {
- H.createQuestion({
- name: "Nested question based on a question",
- query: { "source-table": `card__${ORDERS_COUNT_QUESTION_ID}` },
- }).then(({ body: nestedQuestion }) => {
- cy.signIn("nodata");
- H.visitQuestion(nestedQuestion.id);
-
- cy.log("We should not even show the notebook icon");
- cy.findByTestId("qb-header-action-panel")
- .icon("notebook")
- .should("not.exist");
-
- // TODO update the following once metabase#46398 is fixed
- // cy.visit(`/question/${nestedQuestion.id}/notebook`);
- });
- });
-
describe("sandboxing", () => {
beforeEach(() => {
H.activateToken("pro-self-hosted");
diff --git a/e2e/test/scenarios/question/notebook-native-preview-sidebar.cy.spec.ts b/e2e/test/scenarios/question/notebook-native-preview-sidebar.cy.spec.ts
index 6c6a84b53ed..3b309498dc3 100644
--- a/e2e/test/scenarios/question/notebook-native-preview-sidebar.cy.spec.ts
+++ b/e2e/test/scenarios/question/notebook-native-preview-sidebar.cy.spec.ts
@@ -14,23 +14,6 @@ describe("scenarios > question > notebook > native query preview sidebar", () =>
cy.signInAsAdmin();
});
- it("should not show empty sidebar when no data source is selected", () => {
- cy.intercept("POST", "/api/dataset/native").as("nativeDataset");
- H.openReviewsTable({ mode: "notebook", limit: 1 });
- openSidebar();
- cy.wait("@nativeDataset");
-
- cy.findByTestId("app-bar").findByLabelText("New").click();
- H.popover().findByTextEnsureVisible("Question").click();
- H.miniPickerBrowseAll().click();
- cy.findByPlaceholderText("Search for tables and more...").should(
- "be.visible",
- );
- H.entityPickerModal().button("Close").click();
-
- cy.findByTestId("native-query-preview-sidebar").should("not.exist");
- });
-
it("smoke test: should show the preview sidebar, update it, and close it", () => {
const queryLimit = 2;
@@ -42,6 +25,7 @@ describe("scenarios > question > notebook > native query preview sidebar", () =>
cy.log("Refreshing the page does not persist the sidebar state");
cy.reload();
+ cy.findByLabelText("View SQL").should("be.visible");
cy.findByTestId("native-query-preview-sidebar").should("not.exist");
openSidebar();
@@ -67,17 +51,37 @@ describe("scenarios > question > notebook > native query preview sidebar", () =>
cy.log("It should be possible to close the sidebar");
closeSidebar();
cy.findByTestId("native-query-preview-sidebar").should("not.exist");
+
+ cy.log(
+ "It should not show an empty sidebar when no data source is selected",
+ );
+ openSidebar();
+ cy.wait("@nativeDataset");
+ cy.findByTestId("native-query-preview-sidebar").should("be.visible");
+
+ cy.findByTestId("app-bar").findByLabelText("New").click();
+ H.popover().findByTextEnsureVisible("Question").click();
+ H.miniPickerBrowseAll().click();
+ cy.findByPlaceholderText("Search for tables and more...").should(
+ "be.visible",
+ );
+ H.entityPickerModal().button("Close").click();
+
+ cy.findByTestId("native-query-preview-sidebar").should("not.exist");
});
it("should not offer the sidebar preview for a user without native permissions", () => {
cy.signIn("nosql");
H.openReviewsTable({ mode: "notebook" });
+ cy.findByTestId("data-step-cell").should("contain", "Reviews");
+ cy.findByTestId("qb-header-action-panel")
+ .findByTestId("qb-save-button")
+ .should("be.visible");
cy.findByTestId("qb-header-action-panel")
.findByLabelText(/View SQL/i)
.should("not.exist");
cy.findByLabelText("View SQL").should("not.exist");
cy.findByTestId("native-query-preview-sidebar").should("not.exist");
- cy.get("code").should("not.exist");
});
it(
@@ -95,6 +99,9 @@ describe("scenarios > question > notebook > native query preview sidebar", () =>
"It shouldn't be possible to click on any of the notebook elements",
);
cy.button("Visualize").click({ timeout: 500 }); // no need to wait four seconds
+ cy.then(() => {
+ throw new Error("Visualize should be covered by the sidebar");
+ });
/**
* The only reliable way to test that the button is not clickable because it is covered by another element.
@@ -226,7 +233,12 @@ describe("converting question to SQL (metabase#12651, metabase#21615, metabase#3
cy.log(
"should be possible to `Explore results` after saving a question (metabase#32121)",
);
+ cy.intercept("POST", "/api/dataset").as("exploreDataset");
cy.findByTestId("qb-header").findByText("Explore results").click();
+ cy.wait("@exploreDataset");
+ cy.findByTestId("qb-header")
+ .findByText("Explore results")
+ .should("not.exist");
cy.get("[data-testid=cell-data]").should("contain", "37.65");
});
diff --git a/e2e/test/scenarios/question/notebook.cy.spec.js b/e2e/test/scenarios/question/notebook.cy.spec.js
index afbbddc41e2..3c22e53d342 100644
--- a/e2e/test/scenarios/question/notebook.cy.spec.js
+++ b/e2e/test/scenarios/question/notebook.cy.spec.js
@@ -55,9 +55,10 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
cy.button("Visualize").click();
+ cy.location("pathname").should("not.include", "/notebook");
+ H.tableInteractive().should("be.visible");
// there were no changes to the question, so we shouldn't have the option to "Save"
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Save").should("not.exist");
+ H.queryBuilderHeader().button("Save").should("not.exist");
});
it("should allow post-aggregation filters", () => {
@@ -97,18 +98,56 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
cy.contains("Showing 1 row"); // ensure only one user was returned
});
- it("shouldn't show sub-dimensions for FK (metabase#16787)", () => {
+ it("should render preview without detail view column, pick custom aggregation expressions, and hide FK sub-dimensions (metabase#63070, metabase#16787)", () => {
+ function openPreview() {
+ cy.findByTestId("step-preview-button").click();
+ }
+
+ function verifyPreviewIsRendered() {
+ cy.findByTestId("table-scroll-container").should("contain", "37.65");
+ }
+
+ function verifyIndexColumnsNotRendered() {
+ cy.findAllByTestId("row-id-cell").should("have.length", 0);
+ }
+
H.openOrdersTable({ mode: "notebook" });
+
+ openPreview();
+ verifyPreviewIsRendered();
+ verifyIndexColumnsNotRendered();
+
H.summarize({ mode: "notebook" });
+ H.popover().within(() => {
+ cy.findByPlaceholderText("Find...").type("Distinc");
+ cy.findByText("Number of distinct values of ...").should("be.visible");
+ cy.findByText("DistinctIf").click();
+ H.CustomExpressionEditor.value().should(
+ "equal",
+ "DistinctIf(column, condition)",
+ );
+ });
+ H.expressionEditorWidget().button("Cancel").click();
+ H.popover().findByPlaceholderText("Find...").should("be.visible");
+ cy.realPress("Escape");
+ H.popover({ skipVisibilityCheck: true }).should("not.exist");
+
H.getNotebookStep("summarize")
.findByText("Pick a column to group by")
.click();
H.popover().within(() => {
- cy.findByText("User ID")
+ H.getDimensionByName({ name: "Created At" })
+ .findByLabelText("Temporal bucket")
+ .should("exist");
+ H.getDimensionByName({ name: "Subtotal" })
+ .findByLabelText("Binning strategy")
+ .should("exist");
+
+ H.getDimensionByName({ name: "User ID" })
.findByLabelText("Binning strategy")
.should("not.exist");
- cy.findByText("User ID")
+ H.getDimensionByName({ name: "User ID" })
.findByLabelText("Temporal bucket")
.should("not.exist");
});
@@ -129,48 +168,14 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("ID is between 96 and 97").click();
+ H.popover().findByDisplayValue("96").should("be.visible");
+ H.popover().findByDisplayValue("97").should("be.visible");
H.popover().findByText("Between").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Is not");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Greater than");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Less than");
- });
-
- it("should append indexes to duplicate custom expression names (metabase#12104)", () => {
- cy.viewport(1920, 800); // we're looking for a column name beyond the right of the default viewport
- cy.intercept("POST", "/api/dataset").as("dataset");
- H.openProductsTable({ mode: "notebook" });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Custom column").click();
- addSimpleCustomColumn("EXPR");
-
- H.getNotebookStep("expression").within(() => {
- cy.icon("add").click();
- });
- addSimpleCustomColumn("EXPR");
-
- H.getNotebookStep("expression").within(() => {
- cy.icon("add").click();
- });
- addSimpleCustomColumn("EXPR");
-
- H.getNotebookStep("expression").within(() => {
- cy.findByText("EXPR");
- cy.findByText("EXPR (1)");
- cy.findByText("EXPR (2)");
+ cy.findByRole("menu").within(() => {
+ cy.findByText("Is not").should("be.visible");
+ cy.findByText("Greater than").should("be.visible");
+ cy.findByText("Less than").should("be.visible");
});
-
- H.visualize();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("EXPR");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("EXPR (1)");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("EXPR (2)");
});
it("should show the real number of rows instead of HARD_ROW_LIMIT when loading (metabase#17397)", () => {
@@ -182,8 +187,7 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
},
(req) => {
req.on("response", (res) => {
- // Throttle the response to 500 Kbps to simulate a mobile 3G connection
- res.setThrottle(500);
+ res.setDelay(2000);
});
},
).as("dataset");
@@ -211,33 +215,16 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("Product ID is 2 selections");
+ cy.findByTestId("question-row-count").should(
+ "have.text",
+ "Showing 98 rows",
+ );
cy.wait("@dataset");
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.contains("Showing 175 rows");
});
- it("should show an info popover for dimensions listened by the custom expression editor", () => {
- // start a custom question with orders
- H.openOrdersTable({ mode: "notebook" });
- H.filter({ mode: "notebook" });
-
- H.popover().contains("Custom Expression").click();
-
- H.CustomExpressionEditor.type("[Cre");
-
- // hover over option in the suggestion list
- H.CustomExpressionEditor.completion("Created At")
- .parents("li")
- .findByLabelText("More info")
- .realHover();
-
- H.hovercard().within(() => {
- cy.contains("The date and time an order was submitted.");
- cy.contains("Creation timestamp");
- });
- });
-
- it("should show an info card filter columns in the popover", () => {
+ it("should show an info card for filter columns in the popover and the custom expression editor", () => {
H.openOrdersTable({ mode: "notebook" });
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
@@ -256,12 +243,29 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
cy.contains("Foreign Key");
cy.findByText(/The id of the user/);
});
+
+ // Move the mouse off the info icon so the hovercard can't cover the next click
+ cy.findByTestId("step-data-0-0").realHover();
+ cy.get("body").should("not.contain", "The id of the user");
+
+ H.popover().contains("Custom Expression").click();
+
+ H.CustomExpressionEditor.type("[Cre");
+
+ // hover over option in the suggestion list
+ H.CustomExpressionEditor.completion("Created At")
+ .parents("li")
+ .findByLabelText("More info")
+ .realHover();
+
+ H.hovercard().within(() => {
+ cy.contains("The date and time an order was submitted.");
+ cy.contains("Creation timestamp");
+ });
});
describe("popover rendering issues (metabase#15502)", () => {
beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
cy.viewport(1280, 720);
H.startNewQuestion();
H.miniPicker().within(() => {
@@ -270,7 +274,7 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
});
});
- it("popover should not render outside of viewport regardless of the screen resolution (metabase#15502-1)", () => {
+ it('popover should render within the viewport and not cover the button that invoked it, and "median" is not offered for databases without "percentile-aggregations" (metabase#15502-1, metabase#15502-2)', () => {
H.getNotebookStep("filter")
.findByText("Add filters to narrow your answer")
.click();
@@ -282,12 +286,17 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
.findByText("Add filters to narrow your answer")
.click();
H.popover().isRenderedWithinViewport();
- });
+ H.getProfileLink().click();
- it("popover should not cover the button that invoked it (metabase#15502-2)", () => {
H.getNotebookStep("summarize")
.findByText("Pick a function or metric")
.click();
+
+ H.popover().within(() => {
+ cy.findByText("Average of ...").should("be.visible");
+ cy.findByText("Median of ...").should("not.exist");
+ });
+
// Click outside to close this popover
H.getProfileLink().click();
// Popover invoked again blocks the button making it impossible to click the button for the third time
@@ -297,6 +306,7 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
H.getNotebookStep("summarize")
.findByText("Pick a function or metric")
.click();
+ H.popover().findByText("Average of ...").should("be.visible");
});
});
@@ -318,6 +328,9 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
cy.findByLabelText("ID").click();
});
+ H.popover().findAllByLabelText("More info").first().realHover();
+ H.hovercard().contains("This is a unique ID");
+
cy.findByTestId("step-data-0-0").findByText("Data").click(); //Dismiss popover
H.visualize();
@@ -328,18 +341,6 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
cy.findByText("ID").should("not.exist");
});
- it("should render a field info icon in the fields picker", () => {
- H.openTable({
- table: ORDERS_ID,
- mode: "notebook",
- });
-
- cy.findByTestId("fields-picker").click();
- H.popover().findAllByLabelText("More info").first().realHover();
-
- H.hovercard().contains("This is a unique ID");
- });
-
it("should treat max/min on a name as a string filter (metabase#21973)", () => {
const questionDetails = {
name: "21973",
@@ -385,8 +386,6 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
});
it("should prompt to join with a model if the question is based on a model", () => {
- cy.intercept("GET", "/api/table/*/query_metadata").as("loadMetadata");
-
H.createQuestion({
name: "Products model",
query: { "source-table": PRODUCTS_ID },
@@ -412,23 +411,20 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
cy.findByText("Products model").click();
});
- H.visualize();
- });
-
- it('should not show "median" aggregation option for databases that do not support "percentile-aggregations" driver feature', () => {
- H.startNewQuestion();
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Orders").click();
+ H.getNotebookStep("join").within(() => {
+ cy.findByLabelText("Right table")
+ .findByText("Products model")
+ .should("be.visible");
+ cy.findByLabelText("Left column")
+ .findByText("Product ID")
+ .should("be.visible");
+ cy.findByLabelText("Right column")
+ .findByText(/→ ID$/)
+ .should("be.visible");
});
- H.getNotebookStep("summarize")
- .findByText("Pick a function or metric")
- .click();
-
- H.popover().within(() => {
- cy.findByText("Median of ...").should("not.exist");
- });
+ H.visualize();
+ H.tableInteractive().should("be.visible");
});
describe('"median" aggregation function', { tags: "@external" }, () => {
@@ -448,7 +444,7 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
);
});
- it('should show "median" aggregation option for databases that support "percentile-aggregations" driver feature', () => {
+ it('should show "median" aggregation option for databases that support "percentile-aggregations" driver feature, in the notebook and the Summarize side panel', () => {
cy.findByRole("button", { name: "Summarize" }).click();
H.addSummaryField({ metric: "Median of ...", field: "Price" });
@@ -463,6 +459,14 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
cy.findByLabelText("Switch to data").click();
cy.findAllByTestId("header-cell").should("contain", "Median of Price");
+
+ H.summarize();
+
+ cy.findByTestId("add-aggregation-button").click();
+
+ H.popover().within(() => {
+ cy.findByText("Median of ...").should("be.visible");
+ });
});
it("should support custom columns", () => {
@@ -497,18 +501,6 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
.should("contain", "Median of Median of Mega price")
.should("contain", "Median of Count");
});
-
- it("should support Summarize side panel", () => {
- H.visualize();
-
- H.summarize();
-
- cy.findByTestId("add-aggregation-button").click();
-
- H.popover().within(() => {
- cy.findByText("Median of ...").should("be.visible");
- });
- });
});
it("should properly render previews (metabase#28726, metabase#29959)", () => {
@@ -867,22 +859,6 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
});
});
- it("should allow using aggregation functions inside expressions in aggregation (metabase#52611)", () => {
- cy.visit("/");
- H.newButton("Question").click();
- H.miniPicker().findByText("Sample Database").click();
- H.miniPicker().findByText("Orders").click();
- H.addSummaryField({ metric: "Custom Expression" });
- H.enterCustomColumnDetails({
- formula: "case(Sum([Total]) > 10, Sum([Total]), Sum([Subtotal]))",
- name: "conditional sum",
- });
- cy.button("Done").click();
- H.addSummaryGroupingField({ field: "Total" });
- H.visualize();
- H.echartsContainer().should("contain.text", "Total: 8 bins");
- });
-
it("Correctly translates aggregations", () => {
cy.request("PUT", `/api/user/${ADMIN_USER_ID}`, {
locale: "en-ZZ",
@@ -901,14 +877,9 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
cy.findAllByText("[zz] Average of Subtotal").should("exist");
cy.findAllByText("Average of Subtotal").should("not.exist");
-
- cy.request("PUT", `/api/user/${ADMIN_USER_ID}`, {
- locale: "en",
- });
});
it("should support browser based navigation (metabase#55162)", () => {
- cy.intercept(`/api/table/${PRODUCTS_ID}/fks`).as("tableFK");
H.createQuestion(
{ query: { "source-table": PRODUCTS_ID }, name: "products" },
{ visitQuestion: true, wrapId: true },
@@ -1060,16 +1031,6 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
`/model/${PRODUCT_QUESTION_ID}-products`,
);
- /**
- * foreign key relation orders should work, but it consistently fails in CI
- */
- // cy.wait("@tableFK");
-
- // H.modal().findByTestId("fk-relation-orders").click();
-
- // cy.location("pathname").should("contain", "/question");
- // cy.findByTestId("filter-pill").should("contain.text", "Product ID is 1");
-
H.openQuestionActions("Turn back to saved question");
cy.location("pathname").should(
@@ -1085,40 +1046,6 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
// );
});
});
-
- it("should be possible to select custom expressions in the aggregation picker", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.summarize({ mode: "notebook" });
- H.popover().within(() => {
- cy.findByPlaceholderText("Find...").type("Distinc");
- cy.findByText("Number of distinct values of ...").should("be.visible");
- cy.findByText("DistinctIf").click();
- H.CustomExpressionEditor.value().should(
- "equal",
- "DistinctIf(column, condition)",
- );
- });
- });
-
- it("should not render detail view column in preview (metabase#63070)", () => {
- function openPreview() {
- cy.findByTestId("step-preview-button").click();
- }
-
- function verifyPreviewIsRendered() {
- cy.findByTestId("table-scroll-container").should("contain", "37.65");
- }
-
- function verifyIndexColumnsNotRendered() {
- cy.findAllByTestId("row-id-cell").should("have.length", 0);
- }
-
- H.openOrdersTable({ mode: "notebook" });
-
- openPreview();
- verifyPreviewIsRendered();
- verifyIndexColumnsNotRendered();
- });
});
function assertTableRowCount(expectedCount) {
@@ -1127,9 +1054,3 @@ function assertTableRowCount(expectedCount) {
expectedCount,
);
}
-
-function addSimpleCustomColumn(name) {
- H.enterCustomColumnDetails({ formula: "[Category]", blur: true });
- H.CustomExpressionEditor.nameInput().click().type(name);
- cy.button("Done").click();
-}
diff --git a/e2e/test/scenarios/question/nulls.cy.spec.js b/e2e/test/scenarios/question/nulls.cy.spec.js
index 203df8ad7fe..6de07909f4e 100644
--- a/e2e/test/scenarios/question/nulls.cy.spec.js
+++ b/e2e/test/scenarios/question/nulls.cy.spec.js
@@ -121,10 +121,15 @@ describe("scenarios > question > null", () => {
H.visitDashboard(DASHBOARD_ID);
cy.log("P0 regression in v0.37.1!");
- cy.findByTestId("loading-indicator").should("not.exist");
- cy.findByText("13801_Q1");
- cy.findAllByTestId("scalar-value").should("contain", "0");
- cy.findByText("13801_Q2");
+ H.getDashboardCard(1).within(() => {
+ cy.findByText("13801_Q2").should("be.visible");
+ cy.findByTestId("scalar-value").should("have.text", "0");
+ });
+ H.getDashboardCard(0).within(() => {
+ cy.findByText("13801_Q1").should("be.visible");
+ cy.findByTestId("scalar-value").should("exist");
+ cy.findByTestId("loading-indicator").should("not.exist");
+ });
});
});
});
@@ -135,6 +140,9 @@ describe("scenarios > question > null", () => {
const findGridcell = (text) =>
cy.findByRole("grid").findByRole("gridcell", { name: text });
+ findGridcell("49.21").should("be.visible");
+ cy.intercept("POST", "/api/dataset").as("dataset");
+
// Total of "39.72", and the next cell is the `discount` (which is empty)
findGridcell("39.72")
.next()
@@ -144,6 +152,8 @@ describe("scenarios > question > null", () => {
.click({ force: true });
H.popover().contains("=").click();
+ cy.wait("@dataset");
+ cy.findByTestId("filter-pill").should("contain.text", "Discount is empty");
findGridcell("39.72").should("be.visible");
// This row ([id] 3) had the `discount` column value and should be filtered out now
@@ -172,12 +182,12 @@ describe("scenarios > question > null", () => {
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.contains("Cumulative sum of Discount by Created At: Month");
+ H.cartesianChartCircle().should("have.length.of.at.least", 40);
+
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("There was a problem with your question").should(
"not.exist",
);
-
- H.cartesianChartCircle().should("have.length.of.at.least", 40);
});
});
});
diff --git a/e2e/test/scenarios/question/offset.cy.spec.ts b/e2e/test/scenarios/question/offset.cy.spec.ts
index 5bce67f87d2..1bce5879fb1 100644
--- a/e2e/test/scenarios/question/offset.cy.spec.ts
+++ b/e2e/test/scenarios/question/offset.cy.spec.ts
@@ -11,12 +11,6 @@ import type {
const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
-const ORDERS_ID_FIELD_REF: FieldReference = [
- "field",
- ORDERS.ID,
- { "base-type": "type/BigInteger" },
-];
-
const ORDERS_TOTAL_FIELD_REF: FieldReference = [
"field",
ORDERS.TOTAL,
@@ -47,81 +41,74 @@ describe("scenarios > question > offset", () => {
cy.intercept("POST", "/api/card").as("saveQuestion");
});
- describe("custom columns", () => {
- it("does not suggest or allow using offset()", () => {
- const expression = "Offset([Total], -1)";
+ describe("aggregations", () => {
+ it("suggests and allows using offset(), but not in filters or custom columns", () => {
+ const filterExpression = "Offset([Total], -1) > 0";
+ const customColumnExpression = "Offset([Total], -1)";
+ const expression = "Offset(Sum([Total]), -1)";
const prefixLength = 3;
+ const filterPrefix = filterExpression.substring(0, prefixLength);
+ const customColumnPrefix = customColumnExpression.substring(
+ 0,
+ prefixLength,
+ );
const prefix = expression.substring(0, prefixLength);
const query: StructuredQuery = {
"source-table": ORDERS_ID,
- fields: [ORDERS_ID_FIELD_REF, ORDERS_TOTAL_FIELD_REF],
limit: 5,
- "order-by": [["asc", ORDERS_TOTAL_FIELD_REF]],
};
H.createQuestion({ query }, { visitQuestion: true });
H.openNotebook();
- cy.button("Custom column").click();
- H.enterCustomColumnDetails({ formula: prefix });
- cy.log("does not suggest offset() in custom columns");
- H.CustomExpressionEditor.completions().should("not.exist");
+ cy.button("Filter").click();
+ H.popover().findByText("Custom Expression").click();
+ H.enterCustomColumnDetails({ formula: filterPrefix, blur: false });
- H.enterCustomColumnDetails({ formula: expression });
+ cy.log("does not suggest offset() in filter expressions");
+ H.CustomExpressionEditor.completions()
+ .should("exist")
+ .and("not.contain", "Offset");
+
+ H.enterCustomColumnDetails({ formula: filterExpression });
cy.realPress("Tab");
H.expressionEditorWidget().within(() => {
cy.button("Done").should("be.disabled");
- cy.findByText("OFFSET is not supported in custom columns").should(
+ cy.findByText("OFFSET is not supported in custom filters").should(
"exist",
);
});
- });
- });
- describe("filters", () => {
- it("does not suggest or allow using offset()", () => {
- const expression = "Offset([Total], -1) > 0";
- const prefixLength = 3;
- const prefix = expression.substring(0, prefixLength);
- const query: StructuredQuery = {
- "source-table": ORDERS_ID,
- limit: 5,
- };
+ H.expressionEditorWidget().button("Cancel").click();
+ H.popover().findByText("Custom Expression").should("be.visible");
+ cy.realPress("Escape");
+ H.popover({ skipVisibilityCheck: true }).should("not.exist");
- H.createQuestion({ query }, { visitQuestion: true });
- H.openNotebook();
- cy.button("Filter").click();
- H.popover().findByText("Custom Expression").click();
- H.enterCustomColumnDetails({ formula: prefix });
+ cy.button("Custom column").click();
+ H.enterCustomColumnDetails({
+ formula: customColumnPrefix,
+ blur: false,
+ });
- cy.log("does not suggest offset() in filter expressions");
- H.CustomExpressionEditor.completions().should("not.exist");
+ cy.log("does not suggest offset() in custom columns");
+ H.CustomExpressionEditor.completions()
+ .should("exist")
+ .and("not.contain", "Offset");
- H.enterCustomColumnDetails({ formula: expression });
+ H.enterCustomColumnDetails({ formula: customColumnExpression });
cy.realPress("Tab");
H.expressionEditorWidget().within(() => {
cy.button("Done").should("be.disabled");
- cy.findByText("OFFSET is not supported in custom filters").should(
+ cy.findByText("OFFSET is not supported in custom columns").should(
"exist",
);
});
- });
- });
- describe("aggregations", () => {
- it("suggests and allows using offset()", () => {
- const expression = "Offset(Sum([Total]), -1)";
- const prefixLength = 3;
- const prefix = expression.substring(0, prefixLength);
- const query: StructuredQuery = {
- "source-table": ORDERS_ID,
- limit: 5,
- };
+ H.expressionEditorWidget().button("Cancel").click();
+ H.expressionEditorWidget().should("not.exist");
- H.createQuestion({ query }, { visitQuestion: true });
- H.openNotebook();
cy.button("Summarize").click();
H.getNotebookStep("summarize")
.findByText("Pick a function or metric")
@@ -158,11 +145,11 @@ describe("scenarios > question > offset", () => {
H.createQuestion({ query }, { visitQuestion: true });
- verifyNoQuestionError();
verifyTableContent([
["April 2025", ""],
["May 2025", "52.76"],
]);
+ verifyNoQuestionError();
H.openNotebook();
H.getNotebookStep("summarize").icon("play").should("be.visible");
@@ -184,19 +171,19 @@ describe("scenarios > question > offset", () => {
addBreakout(breakoutName);
H.visualize();
- verifyNoQuestionError();
verifyLineChart({
xAxis: breakoutName + ": Month",
yAxis: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
});
+ verifyNoQuestionError();
saveQuestion().then(({ response }) => {
H.visitQuestion(response?.body.id);
- verifyNoQuestionError();
verifyLineChart({
xAxis: breakoutName + ": Month",
yAxis: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
});
+ verifyNoQuestionError();
});
});
@@ -244,11 +231,11 @@ describe("scenarios > question > offset", () => {
H.visualize();
- verifyNoQuestionError();
verifyTableContent([
["April 2028", "Gadget", "15,713", "31,426.01"],
["September 2028", "Gadget", "15,017.31", "30,034.62"],
]);
+ verifyNoQuestionError();
});
});
@@ -309,6 +296,10 @@ describe("scenarios > question > offset", () => {
H.echartsContainer().within(() => {
cy.contains("January 2027").should("be.visible");
});
+ verifyLineChart({
+ xAxis: "Created At: Month",
+ legendItems: [metricName, "Count of orders (previous month)"],
+ });
});
});
@@ -385,8 +376,6 @@ function verifyTableContent(dataRows: string[][]) {
});
for (const { index, text } of pairs) {
- cy.log("index", index);
- cy.log("text", text);
verifyTableCellContent(index, text);
}
}
diff --git a/e2e/test/scenarios/question/question-analytics.cy.spec.js b/e2e/test/scenarios/question/question-analytics.cy.spec.js
index 84bdc22766d..ab08cb0e90a 100644
--- a/e2e/test/scenarios/question/question-analytics.cy.spec.js
+++ b/e2e/test/scenarios/question/question-analytics.cy.spec.js
@@ -12,6 +12,7 @@ describe("scenarios > question > snowplow", () => {
cy.findByText("Quantity").click();
cy.button("Done").click();
});
+ H.echartsContainer().findByText("Count").should("be.visible");
};
beforeEach(() => {
diff --git a/e2e/test/scenarios/question/question-management.cy.spec.js b/e2e/test/scenarios/question/question-management.cy.spec.js
index 8f6c3d19f4d..766913c5be9 100644
--- a/e2e/test/scenarios/question/question-management.cy.spec.js
+++ b/e2e/test/scenarios/question/question-management.cy.spec.js
@@ -1,6 +1,5 @@
import { USERS, USER_GROUPS } from "e2e/support/cypress_data";
import {
- ORDERS_COUNT_QUESTION_ID,
ORDERS_DASHBOARD_ID,
ORDERS_QUESTION_ID,
} from "e2e/support/cypress_sample_instance_data";
@@ -11,7 +10,6 @@ const { H } = cy;
const PERMISSIONS = {
curate: ["admin", "normal", "nodata"],
view: ["readonly"],
- no: ["nocollection", "nosql", "none"],
};
describe(
@@ -36,18 +34,16 @@ describe(
H.visitQuestion(ORDERS_QUESTION_ID);
});
- it("should be able to edit question details (metabase#11719-1)", () => {
+ it("should be able to edit question title and description (metabase#11719-1)", () => {
cy.findByTestId("saved-question-header-title")
.click()
.type("1")
.blur();
assertRequestNot403("updateQuestion");
- assertNoPermissionsError();
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders1");
- });
+ assertNoPermissionsError();
- it("should be able to edit a question's description", () => {
H.questionInfoButton().click();
cy.findByPlaceholderText("Add description")
@@ -55,10 +51,9 @@ describe(
.blur();
assertRequestNot403("updateQuestion");
- assertNoPermissionsError();
-
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("foo");
+ assertNoPermissionsError();
});
describe("move", () => {
@@ -136,44 +131,44 @@ describe(
cy.get("header").findByText(NEW_COLLECTION_NAME);
});
- it("should be able to move models", () => {
- // TODO: Currently nodata users can't turn a question into a model
- cy.skipOn(user === "nodata");
-
- turnIntoModel();
-
- H.openNavigationSidebar();
- H.navigationSidebar().within(() => {
- // Highlight "Our analytics"
- cy.findByText("Our analytics")
- .parents("li")
- .should("have.attr", "aria-selected", "true");
- cy.findByText("Your personal collection")
- .parents("li")
- .should("have.attr", "aria-selected", "false");
- });
-
- moveQuestionTo(/Personal Collection/);
- assertRequestNot403("updateQuestion");
-
- cy.findAllByRole("status")
- .contains(
- `Model moved to ${H.getPersonalCollectionName(
- USERS[user],
- )}`,
- )
- .should("exist");
- assertNoPermissionsError();
- cy.findAllByRole("gridcell").contains("37.65");
+ // TODO: Currently nodata users can't turn a question into a model
+ onlyOn(user !== "nodata", () => {
+ it("should be able to move models", () => {
+ turnIntoModel();
+
+ H.openNavigationSidebar();
+ H.navigationSidebar().within(() => {
+ // Highlight "Our analytics"
+ cy.findByText("Our analytics")
+ .parents("li")
+ .should("have.attr", "aria-selected", "true");
+ cy.findByText("Your personal collection")
+ .parents("li")
+ .should("have.attr", "aria-selected", "false");
+ });
- H.navigationSidebar().within(() => {
- // Highlight "Your personal collection" after move
- cy.findByText("Our analytics")
- .parents("li")
- .should("have.attr", "aria-selected", "false");
- cy.findByText("Your personal collection")
- .parents("li")
- .should("have.attr", "aria-selected", "true");
+ moveQuestionTo(/Personal Collection/);
+ assertRequestNot403("updateQuestion");
+
+ cy.findAllByRole("status")
+ .contains(
+ `Model moved to ${H.getPersonalCollectionName(
+ USERS[user],
+ )}`,
+ )
+ .should("exist");
+ assertNoPermissionsError();
+ cy.findAllByRole("gridcell").contains("37.65");
+
+ H.navigationSidebar().within(() => {
+ // Highlight "Your personal collection" after move
+ cy.findByText("Our analytics")
+ .parents("li")
+ .should("have.attr", "aria-selected", "false");
+ cy.findByText("Your personal collection")
+ .parents("li")
+ .should("have.attr", "aria-selected", "true");
+ });
});
});
});
@@ -290,24 +285,6 @@ describe(
});
onlyOn(user === "normal", () => {
- it("should preselect the most recently visited dashboard", () => {
- H.openQuestionActions();
- cy.findByTestId("add-to-dashboard-button").click();
-
- findInactivePickerItem("Orders in a dashboard");
-
- // before visiting the dashboard, we don't have any history
- H.visitDashboard(ORDERS_DASHBOARD_ID);
- H.visitQuestion(ORDERS_COUNT_QUESTION_ID);
-
- H.openQuestionActions();
- cy.findByTestId("add-to-dashboard-button").click();
-
- H.pickEntity({
- path: ["Our analytics", "Orders in a dashboard"],
- });
- });
-
it("should handle lost access", () => {
cy.intercept(
"GET",
@@ -367,59 +344,76 @@ describe(
H.visitQuestion(ORDERS_QUESTION_ID);
});
- it("should not be offered to add question to dashboard inside a collection they have `read` access to", () => {
- H.openQuestionActions();
- cy.findByTestId("add-to-dashboard-button").click();
-
- findInactivePickerItem("Orders in a dashboard");
-
- H.entityPickerModal().within(() => {
- cy.findByPlaceholderText(/Search/).type(
- "Orders in a dashboard{Enter}",
- { delay: 0 },
- );
- cy.findByText(/didn't find anything/).should("be.visible");
- });
- });
+ it("should not offer to update, clone, or add the question to a dashboard it can't write to", () => {
+ cy.intercept(
+ "GET",
+ "/api/activity/most_recently_viewed_dashboard",
+ ).as("mostRecentlyViewedDashboard");
- it("should not offer a user the ability to update or clone the question", () => {
- cy.findByTestId("edit-details-button").should("not.exist");
- cy.findByRole("button", { name: "Add a description" }).should(
- "not.exist",
+ cy.findByTestId("saved-question-header-title").should(
+ "be.disabled",
);
+ H.questionInfoButton().click();
+ H.sidesheet()
+ .findByPlaceholderText("No description")
+ .should("be.disabled");
+ H.sidesheet().findByLabelText("Close").click();
H.openQuestionActions();
H.popover().within(() => {
+ cy.findByTestId("add-to-dashboard-button").should(
+ "be.visible",
+ );
cy.findByTestId("move-button").should("not.exist");
cy.findByTestId("clone-button").should("not.exist");
cy.findByTestId("archive-button").should("not.exist");
});
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Revert").should("not.exist");
- });
-
- it("should not preselect the most recently visited dashboard", () => {
- H.openQuestionActions();
cy.findByTestId("add-to-dashboard-button").click();
+ cy.wait("@mostRecentlyViewedDashboard");
H.entityPickerModal()
.findByText(/Orders in a dashboard/)
.closest("a")
.should("have.attr", "data-disabled", "true");
+ findInactivePickerItem("Orders in a dashboard");
+
+ H.entityPickerModal().within(() => {
+ cy.findByPlaceholderText(/Search/).type(
+ "Orders in a dashboard{Enter}",
+ { delay: 0 },
+ );
+ cy.findByText(/didn't find anything/).should("be.visible");
+ });
+
// before visiting the dashboard, we don't have any history
H.visitDashboard(ORDERS_DASHBOARD_ID);
H.visitQuestion(ORDERS_QUESTION_ID);
H.openQuestionActions();
cy.findByTestId("add-to-dashboard-button").click();
+ cy.wait("@mostRecentlyViewedDashboard");
H.entityPickerModal()
.findByText(/Orders in a dashboard/)
.closest("a")
.should("have.attr", "data-disabled", "true");
+
+ cy.log("the history is visible but can't be reverted");
+ cy.signInAsAdmin();
+ cy.request("PUT", `/api/card/${ORDERS_QUESTION_ID}`, {
+ description: "foo",
+ });
+ cy.signIn(user);
+ H.visitQuestion(ORDERS_QUESTION_ID);
+ H.questionInfoButton().click();
+ H.sidesheet().within(() => {
+ cy.findByRole("tab", { name: "History" }).click();
+ cy.findByText(/added a description/i).should("be.visible");
+ cy.findByTestId("question-revert-button").should("not.exist");
+ });
});
});
});
@@ -437,7 +431,15 @@ describe("question moving", () => {
H.visitQuestion(ORDERS_QUESTION_ID);
});
- it("should move a question between collections", () => {
+ it("should move a question between collections, showing an error when the move fails", () => {
+ cy.intercept(
+ { method: "PUT", url: `/api/card/${ORDERS_QUESTION_ID}`, times: 1 },
+ {
+ statusCode: 400,
+ body: { message: "Sorry buddy, only cool kids in this collection" },
+ },
+ ).as("updateQuestionFail");
+
H.appBar().findByText("Our analytics").should("be.visible");
cy.findByTestId("qb-header-action-panel")
.icon("ellipsis")
@@ -448,17 +450,11 @@ describe("question moving", () => {
path: ["Our analytics", "First collection", "Second collection"],
select: true,
});
- cy.wait("@updateQuestion").its("response.statusCode").should("eq", 200);
- cy.findAllByRole("status").contains("Question moved to Second collection");
- H.appBar().findByText("Second collection").should("be.visible");
- H.modal().should("not.exist");
- });
-
- it("should show an error when moving a question fails", () => {
- cy.intercept("PUT", `/api/card/${ORDERS_QUESTION_ID}`, {
- statusCode: 400,
- body: { message: "Sorry buddy, only cool kids in this collection" },
- }).as("updateQuestion");
+ cy.wait("@updateQuestionFail");
+ H.modal()
+ .findByText("Sorry buddy, only cool kids in this collection")
+ .should("be.visible");
+ H.entityPickerModal().findByLabelText("Close").click();
H.appBar().findByText("Our analytics").should("be.visible");
cy.findByTestId("qb-header-action-panel")
@@ -470,10 +466,10 @@ describe("question moving", () => {
path: ["Our analytics", "First collection", "Second collection"],
select: true,
});
- cy.wait("@updateQuestion");
- H.modal()
- .findByText("Sorry buddy, only cool kids in this collection")
- .should("be.visible");
+ cy.wait("@updateQuestion").its("response.statusCode").should("eq", 200);
+ cy.findAllByRole("status").contains("Question moved to Second collection");
+ H.appBar().findByText("Second collection").should("be.visible");
+ H.modal().should("not.exist");
});
});
diff --git a/e2e/test/scenarios/question/questions-entity-id.cy.spec.ts b/e2e/test/scenarios/question/questions-entity-id.cy.spec.ts
index 73deb51f93c..7bb03c829eb 100644
--- a/e2e/test/scenarios/question/questions-entity-id.cy.spec.ts
+++ b/e2e/test/scenarios/question/questions-entity-id.cy.spec.ts
@@ -11,7 +11,7 @@ describe("scenarios > questions > entity id support", () => {
cy.signInAsAdmin();
});
- it("/question/entity/${entity_id} should redirect to /question/${id}", () => {
+ it("/question/entity/${entity_id} and /question/entity/${entity_id}/notebook should redirect to /question/${id} and /question/${id}/notebook", () => {
cy.visit(`/question/entity/${ORDERS_QUESTION_ENTITY_ID}`);
cy.url().should("contain", `/question/${ORDERS_QUESTION_ID}`);
@@ -19,9 +19,7 @@ describe("scenarios > questions > entity id support", () => {
H.main()
.findByTestId("saved-question-header-title")
.should("have.text", "Orders");
- });
- it("/question/entity/${entity_id}/notebook should redirect to /question/${id}/notebook", () => {
cy.visit(`/question/entity/${ORDERS_QUESTION_ENTITY_ID}/notebook`);
cy.url().should("contain", `/question/${ORDERS_QUESTION_ID}/notebook`);
diff --git a/e2e/test/scenarios/question-reproductions/reproductions-1.cy.spec.js b/e2e/test/scenarios/question/reproductions-1.cy.spec.js
similarity index 78%
rename from e2e/test/scenarios/question-reproductions/reproductions-1.cy.spec.js
rename to e2e/test/scenarios/question/reproductions-1.cy.spec.js
index d7c57dfe232..8ed4869219d 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions-1.cy.spec.js
+++ b/e2e/test/scenarios/question/reproductions-1.cy.spec.js
@@ -1,5 +1,4 @@
const { H } = cy;
-import { WRITABLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
@@ -54,8 +53,8 @@ describe("issue 6239", () => {
// Sort descending this time
cy.icon("arrow_up").click();
+ cy.icon("arrow_down").should("be.visible");
cy.icon("arrow_up").should("not.exist");
- cy.icon("arrow_down");
H.visualize();
@@ -107,6 +106,7 @@ function goToSavedQuestionPickerAndAssertQuestion(questionName, exists = true) {
H.miniPickerBrowseAll().click();
H.entityPickerModal().within(() => {
H.entityPickerModalItem(0, "Our analytics").click();
+ H.entityPickerModalItem(1, "Orders").should("exist");
cy.findByText(questionName).should(exists ? "exist" : "not.exist");
cy.button("Close").click();
});
@@ -133,128 +133,6 @@ function openEllipsisMenuFor(item) {
.click({ force: true });
}
-describe("issue 14957", { tags: "@external" }, () => {
- const PG_DB_NAME = "QA Postgres12";
-
- beforeEach(() => {
- H.restore("postgres-12");
- cy.signInAsAdmin();
- });
-
- it("should save a question before query has been executed (metabase#14957)", () => {
- H.startNewNativeQuestion();
-
- cy.findByTestId("gui-builder-data").click();
- cy.findByLabelText(PG_DB_NAME).click();
- H.NativeEditor.type("select pg_sleep(60)");
- H.saveQuestion("14957", undefined, {
- path: ["Our analytics"],
- });
- H.modal().should("not.exist");
- });
-});
-
-describe("postgres > question > custom columns", { tags: "@external" }, () => {
- beforeEach(() => {
- H.restore("postgres-12");
- cy.signInAsAdmin();
-
- cy.request(`/api/database/${WRITABLE_DB_ID}/schema/public`).then(
- ({ body }) => {
- const tableId = body.find((table) => table.name === "orders").id;
- H.openTable({
- database: WRITABLE_DB_ID,
- table: tableId,
- mode: "notebook",
- });
- },
- );
-
- cy.findByRole("button", { name: "Summarize" }).click();
- });
-
- it("`Percentile` custom expression function should accept two parameters (metabase#15714)", () => {
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Pick a function or metric").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Custom Expression").click();
- H.enterCustomColumnDetails({
- formula: "Percentile([Subtotal], 0.1)",
- format: true,
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Function Percentile expects 1 argument").should("not.exist");
- H.CustomExpressionEditor.nameInput().type("Expression name");
- cy.button("Done").should("not.be.disabled").click();
- // Todo: Add positive assertions once this is fixed
-
- cy.findByTestId("aggregate-step")
- .contains("Expression name")
- .should("exist");
- });
-});
-
-const PG_DB_ID = 2;
-
-const questionDetails = {
- native: {
- query: `select mytz as "ts", mytz::text as "tsAStext", state, mytz::time as "time - LOOK AT THIS COLUMN", mytz::time::text as "timeAStext", mytz::time(0) as "time(0) - ALL INCORRECT", mytz::time(3) as "time(3) - MOSTLY WORKING" from (
- select '2022-05-04 16:29:59.268160-04:00'::timestamptz as mytz, 'incorrect' AS state union all
- select '2022-05-04 16:29:59.412459-04:00'::timestamptz, 'good' union all
- select '2022-05-08 13:14:42.926221-04:00'::timestamptz, 'incorrect' union all
- select '2022-05-08 13:14:42.132026-04:00'::timestamptz, 'good' union all
- select '2022-05-10 07:38:58.987352-04:00'::timestamptz, 'incorrect' union all
- select '2022-05-10 07:38:58.001001-04:00'::timestamptz, 'good' union all
- select '2022-05-12 11:01:23.000000-04:00'::timestamptz, 'ALWAYS incorrect' union all
- select '2022-05-12 11:01:23.000-04:00'::timestamptz, 'ALWAYS incorrect' union all
- select '2022-05-12 11:01:23-04:00'::timestamptz, 'ALWAYS incorrect'
- )x`,
- },
- database: PG_DB_ID,
-};
-
-// time, time(0), time(3)
-const castColumns = 3;
-
-const correctValues = [
- {
- value: "1:29 PM",
- rows: 2,
- },
- {
- value: "10:14 AM",
- rows: 2,
- },
- {
- value: "4:38 AM",
- rows: 2,
- },
- {
- value: "8:01 AM",
- rows: 3,
- },
-];
-
-describe("issue 15876", { tags: "@external" }, () => {
- beforeEach(() => {
- H.restore("postgres-12");
- cy.signInAsAdmin();
- });
-
- it("should correctly cast to `TIME` (metabase#15876)", () => {
- H.createNativeQuestion(questionDetails, { visitQuestion: true });
-
- cy.findByTestId("query-visualization-root").within(() => {
- correctValues.forEach(({ value, rows }) => {
- const count = rows * castColumns;
-
- cy.findAllByText(value).should("have.length", count);
- });
- });
- });
-});
-
describe("issue 17514", () => {
const questionDetails = {
name: "17514",
@@ -377,7 +255,7 @@ describe("issue 17514", () => {
moveColumnToTop("Subtotal");
- openNotebookMode();
+ H.openNotebook();
removeJoinedTable();
@@ -392,7 +270,7 @@ describe("issue 17514", () => {
});
it("should not show the run overlay because of the references to the orphaned fields (metabase#17514-2)", () => {
- openNotebookMode();
+ H.openNotebook();
H.join();
H.miniPicker().within(() => {
@@ -436,10 +314,6 @@ function closeModal() {
});
}
-function openNotebookMode() {
- H.openNotebook();
-}
-
function removeJoinedTable() {
cy.findAllByText("Join data")
.first()
@@ -472,7 +346,7 @@ describe("issue 17910", () => {
cy.intercept("POST", "/api/card").as("card");
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("Save").click();
- cy.findByTestId("save-question-modal").within((modal) => {
+ cy.findByTestId("save-question-modal").within(() => {
cy.findByText("Save").click();
});
cy.wait("@card");
@@ -511,6 +385,7 @@ describe("issues 11914, 18978, 18977, 23857", () => {
);
H.visitQuestion(ORDERS_QUESTION_ID);
cy.findByLabelText("Move, trash, and more…").click();
+ H.popover().findByText("Move").should("be.visible");
H.popover().findByText("Duplicate").should("not.exist");
cy.log(
@@ -520,6 +395,7 @@ describe("issues 11914, 18978, 18977, 23857", () => {
H.commandPaletteSearch("Repro", false);
H.commandPalette().findByText("Repro").click();
cy.findByLabelText("Move, trash, and more…").click();
+ H.popover().findByText("Move").should("be.visible");
H.popover().findByText("Duplicate").should("not.exist");
cy.log(
@@ -631,35 +507,44 @@ describe("issue 19341", () => {
cy.findByText("Sample Database").click();
cy.findByText("Orders").should("exist");
- // Ensure the search doesn't list saved questions
- cy.findByPlaceholderText("Search…").type("Ord");
- cy.findByTestId("loading-indicator").should("not.exist");
-
- cy.findAllByTestId("result-item").then(($result) => {
- const searchResults = $result.toArray();
- const modelTypes = new Set(
- searchResults.map((k) => k.getAttribute("data-model-type")),
- );
-
- expect(modelTypes).not.to.include("card");
- expect(modelTypes).to.include("table");
- });
+ assertSearchListsOnlyTables();
cy.findByText("Orders").click();
});
cy.icon("join_left_outer").click();
H.miniPickerBrowseAll().click();
- H.entityPickerModal().findAllByRole("tab").should("not.exist");
+ H.entityPickerModal().within(() => {
+ H.entityPickerModalItem(0, "Databases").should("be.visible");
+ assertSearchListsOnlyTables();
+ });
// Test "Explore results" button is hidden for native questions
cy.visit("/collection/root");
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText(TEST_NATIVE_QUESTION_NAME).click();
cy.wait("@cardQuery");
+ cy.findByTestId("saved-question-header-title").should(
+ "have.text",
+ TEST_NATIVE_QUESTION_NAME,
+ );
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("Explore results").should("not.exist");
});
+
+ function assertSearchListsOnlyTables() {
+ cy.findByPlaceholderText("Search…").type("Ord");
+ cy.findByTestId("loading-indicator").should("not.exist");
+
+ cy.findAllByTestId("result-item").then(($result) => {
+ const modelTypes = new Set(
+ $result.toArray().map((k) => k.getAttribute("data-model-type")),
+ );
+
+ expect(modelTypes).not.to.include("card");
+ expect(modelTypes).to.include("table");
+ });
+ }
});
describe("issue 19742", () => {
@@ -702,10 +587,10 @@ describe("issue 19742", () => {
H.entityPickerModalItem(0, "Databases").click();
H.entityPickerModalItem(1, "Sample Database").click();
- cy.findByText("Orders").should("not.exist");
cy.findByText("Products").should("exist");
cy.findByText("Reviews").should("exist");
cy.findByText("People").should("exist");
+ cy.findByText("Orders").should("not.exist");
});
});
});
diff --git a/e2e/test/scenarios/question-reproductions/reproductions-2.cy.spec.js b/e2e/test/scenarios/question/reproductions-2.cy.spec.js
similarity index 88%
rename from e2e/test/scenarios/question-reproductions/reproductions-2.cy.spec.js
rename to e2e/test/scenarios/question/reproductions-2.cy.spec.js
index 6043958eb56..981293d713f 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions-2.cy.spec.js
+++ b/e2e/test/scenarios/question/reproductions-2.cy.spec.js
@@ -127,8 +127,7 @@ describe("issue 27462", () => {
cy.button("Visualize").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("200").should("be.visible");
+ H.queryBuilderMain().findByText("200").should("be.visible");
});
});
@@ -138,7 +137,7 @@ describe("issue 28221", () => {
cy.signInAsAdmin();
});
- it("should be able to select see notebook view even if a question custom field metadata is missing#27462", () => {
+ it("should be able to select see notebook view even if a question custom field metadata is missing (metabase#28221)", () => {
const questionName = "Reproduce 28221";
const customFieldName = "Non-existing field";
const questionDetails = {
@@ -219,7 +218,7 @@ describe("issue 28599", () => {
cy.wait("@updateCard");
- cy.findByTestId("time-series-mode-bar").should("not.exist");
+ cy.findByTestId("timeseries-chrome").should("not.exist");
});
});
@@ -256,42 +255,6 @@ describe("issue 28874", () => {
cy.findByText("Product ID").should("not.exist");
});
});
-describe("issue 30165", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/dataset").as("dataset");
- cy.intercept("POST", "/api/card/*/query").as("cardQuery");
- cy.intercept("POST", "/api/card").as("createQuestion");
- cy.intercept("PUT", "/api/card/*").as("updateQuestion");
- });
-
- it("should not autorun native queries after updating a question (metabase#30165)", () => {
- H.startNewNativeQuestion();
- H.NativeEditor.type("SELECT * FROM ORDERS");
- H.saveQuestionToCollection("Q1");
-
- H.NativeEditor.focus().type(" WHERE TOTAL < 20");
- H.queryBuilderHeader().findByText("Save").click();
- cy.findByTestId("save-question-modal").within((modal) => {
- cy.findByText("Save").click();
- });
- cy.wait("@updateQuestion");
-
- H.NativeEditor.focus().type(" LIMIT 10");
- H.queryBuilderHeader().findByText("Save").click();
- cy.findByTestId("save-question-modal").within((modal) => {
- cy.findByText("Save").click();
- });
- cy.wait("@updateQuestion");
-
- cy.get("@dataset.all").should("have.length", 0);
- cy.get("@cardQuery.all").should("have.length", 0);
- cy.findByTestId("query-builder-main")
- .findByText("Here's where your results will appear")
- .should("be.visible");
- });
-});
describe("issue 35290", () => {
beforeEach(() => {
@@ -435,7 +398,7 @@ describe("Custom columns visualization settings", () => {
goToExpressionSidebarVisualizationSettings();
H.popover().within(() => {
- cy.findByLabelText("Display as").as("viewAsDropdown").click();
+ cy.findByLabelText("Display as").click();
});
cy.findAllByRole("option", { name: "Email link" }).click();
diff --git a/e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js b/e2e/test/scenarios/question/reproductions-3.cy.spec.js
similarity index 85%
rename from e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js
rename to e2e/test/scenarios/question/reproductions-3.cy.spec.js
index 46db2611283..2857ce3a51c 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js
+++ b/e2e/test/scenarios/question/reproductions-3.cy.spec.js
@@ -136,61 +136,6 @@ function assertPlanFieldValues() {
cy.findByText("Premium").should("be.visible");
}
-describe("issue 38176", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- cy.intercept("PUT", "/api/card/**").as("updateQuestion");
- });
-
- it("restoring a question to a previous version should preserve the variables (metabase#38176)", () => {
- H.createNativeQuestion(
- {
- name: "38176",
- native: {
- query:
- 'SELECT "COUNTRY" from "ACCOUNTS" WHERE country = {{ country }} LIMIT 5',
- "template-tags": {
- country: {
- type: "text",
- id: "dd06cd10-596b-41d0-9d6e-94e98ceaf989",
- name: "country",
- "display-name": "Country",
- },
- },
- },
- },
- { visitQuestion: true },
- );
-
- cy.findByPlaceholderText("Country").type("NL");
-
- cy.findByTestId("qb-header").icon("play").click();
-
- H.questionInfoButton().click();
- H.sidesheet().within(() => {
- cy.findByPlaceholderText("Add description")
- .type("This is a question")
- .blur();
-
- cy.wait("@updateQuestion");
- cy.wait("@cardQuery");
- cy.findByRole("tab", { name: "History" }).click();
- cy.findByText(/added a description/i);
- cy.findByTestId("question-revert-button").click();
- cy.wait("@cardQuery");
-
- cy.findByRole("tab", { name: "History" }).click();
- cy.findByText(/reverted to an earlier version/i, {
- timeout: 10000,
- }).should("be.visible");
- });
-
- cy.findByLabelText("Close").click();
- H.tableInteractive().should("contain", "NL");
- });
-});
-
describe("issue 38354", { tags: "@external" }, () => {
const QUESTION_DETAILS = {
query: {
@@ -357,7 +302,7 @@ describe("issue 39795", () => {
H.restore();
cy.signInAsAdmin();
- //If you comment out this post, then the test will pass.
+ // 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",
@@ -376,11 +321,21 @@ describe("issue 39795", () => {
},
});
H.openVizSettingsSidebar();
- H.moveColumnDown(H.getDraggableElements().first(), 2);
+ H.getDraggableElements()
+ .eq(0)
+ .should("have.attr", "data-testid", "draggable-item-ID");
+ H.moveDnDKitListElement("draggable-item", {
+ startIndex: 0,
+ dropIndex: 2,
+ useMouseEvents: true,
+ });
- // We are not able to re-order because the dataset will also contain values a column for Product ID
- // This causes the isValid() check to fire, and you are always forced into the default value for table.columns
- H.getDraggableElements().eq(2).should("contain.text", "ID");
+ 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");
});
});
@@ -470,23 +425,6 @@ describe("issue 40435", () => {
});
});
-describe("issue 41381", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should not show an error message when adding a constant-only custom expression (metabase#41381)", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.addCustomColumn();
- H.enterCustomColumnDetails({ formula: "'Test'", name: "Constant" });
- H.popover().within(() => {
- cy.findByText("Invalid expression").should("not.exist");
- cy.button("Done").should("be.enabled");
- });
- });
-});
-
describe(
"issue 42010 -- Unable to filter by mongo id",
{ tags: "@mongo" },
@@ -578,27 +516,6 @@ function removeFilter() {
cy.findByTestId("question-row-count").should("have.text", "Showing 2 rows");
}
-describe("issue 33439", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should show an error message when trying to use convertTimezone on an unsupported db (metabase#33439)", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.addCustomColumn();
- H.enterCustomColumnDetails({
- formula:
- 'convertTimezone("2022-12-28T12:00:00", "Canada/Pacific", "Canada/Eastern")',
- name: "Date",
- });
- H.popover().within(() => {
- cy.findByText("Unsupported function convertTimezone");
- cy.button("Done").should("be.disabled");
- });
- });
-});
-
describe("issue 42244", () => {
const COLUMN_NAME = "Created At".repeat(5);
@@ -628,59 +545,6 @@ describe("issue 42244", () => {
});
});
-describe("issue 40064", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should be able to edit a custom column with the same name as one of the columns used in the expression (metabase#40064)", () => {
- H.createQuestion(
- {
- query: {
- "source-table": ORDERS_ID,
- expressions: {
- Tax: ["*", ["field", ORDERS.TAX, { "base-type": "type/Float" }], 2],
- },
- limit: 1,
- },
- },
- { visitQuestion: true },
- );
-
- cy.log("check the initial expression value");
- H.tableInteractive().findByText("4.14").should("be.visible");
-
- cy.log("update the expression and check the value");
- H.openNotebook();
- H.getNotebookStep("expression").findByText("Tax").click();
- H.enterCustomColumnDetails({ formula: "[Tax] * 3", blur: true });
- H.popover().button("Update").click();
- H.visualize();
- H.tableInteractive().findByText("6.21").should("be.visible");
-
- cy.log("rename the expression and make sure you cannot create a cycle");
- H.openNotebook();
- H.getNotebookStep("expression").findByText("Tax").click();
- H.enterCustomColumnDetails({
- formula: "[Tax] * 3",
- name: "Tax3",
- blur: true,
- });
- H.popover().button("Update").should("not.be.disabled").click();
- H.getNotebookStep("expression").findByText("Tax3").click();
- H.enterCustomColumnDetails({
- formula: "[Tax3] * 3",
- name: "Tax3",
- blur: true,
- });
- H.popover().within(() => {
- cy.findByText("Unknown column: Tax3").should("be.visible");
- cy.button("Update").should("be.disabled");
- });
- });
-});
-
describe("issue 44071", () => {
const questionDetails = {
name: "Test",
@@ -816,7 +680,7 @@ describe("issue 44532", () => {
H.openProductsTable();
});
- it("should update chart metrics and dimensions with each added breakout (metabase #44532)", () => {
+ it("should update chart metrics and dimensions with each added breakout (metabase#44532)", () => {
H.summarize();
H.rightSidebar()
@@ -893,26 +757,6 @@ describe("issue 44532", () => {
});
});
-describe("issue 33441", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should show an error message for an incorrect date expression (metabase#33441)", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.addCustomColumn();
- H.enterCustomColumnDetails({
- formula: 'datetimeDiff([Created At] , now(), "days")',
- name: "Date",
- });
- H.popover().within(() => {
- cy.findByText("Types are incompatible.").should("be.visible");
- cy.button("Done").should("be.disabled");
- });
- });
-});
-
describe("issue 31960", () => {
const questionDetails = {
query: {
@@ -927,7 +771,7 @@ describe("issue 31960", () => {
},
};
- // the dot that corresponds to July 10–16, 2025
+ // the dot that corresponds to July 13–19, 2025
const dotIndex = 10;
const rowCount = 11;
@@ -981,6 +825,7 @@ describe("issue 43294", () => {
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)", () => {
@@ -1000,11 +845,13 @@ describe("issue 43294", () => {
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();
diff --git a/e2e/test/scenarios/question-reproductions/reproductions-4.cy.spec.js b/e2e/test/scenarios/question/reproductions-4.cy.spec.js
similarity index 95%
rename from e2e/test/scenarios/question-reproductions/reproductions-4.cy.spec.js
rename to e2e/test/scenarios/question/reproductions-4.cy.spec.js
index 27476e35895..633370700a9 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions-4.cy.spec.js
+++ b/e2e/test/scenarios/question/reproductions-4.cy.spec.js
@@ -568,35 +568,6 @@ describe("issue 41464", () => {
});
});
-describe("issue 45452", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should only have one scrollbar for the summarize sidebar (metabase#45452)", () => {
- H.openOrdersTable();
- H.summarize();
-
- cy.findByTestId("summarize-aggregation-item-list").then(($el) => {
- const element = $el[0];
- expectNoScrollbarContainer(element);
- });
-
- cy.findByTestId("summarize-breakout-column-list").then(($el) => {
- const element = $el[0];
- expectNoScrollbarContainer(element);
- });
-
- // the sidebar is the only element with a scrollbar
- cy.findByTestId("sidebar-content").then(($el) => {
- const element = $el[0];
- expect(element.scrollHeight > element.clientHeight).to.be.true;
- expect(element.offsetWidth > element.clientWidth).to.be.true;
- });
- });
-});
-
describe("issue 41612", () => {
beforeEach(() => {
H.restore();
@@ -739,34 +710,6 @@ describe("issue 36027", () => {
});
});
-describe("issue 12586", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should not show the run button overlay when an error occurs (metabase#12586)", () => {
- H.openOrdersTable();
- H.summarize();
-
- cy.intercept("POST", "/api/dataset", (req) => req.destroy());
-
- H.rightSidebar().button("Done").click();
- H.main()
- .findByText("We're experiencing server issues")
- .should("be.visible");
- cy.findByTestId("query-builder-main").icon("play").should("not.be.visible");
- });
-});
-
-function expectNoScrollbarContainer(element) {
- const hasScrollbarContainer =
- element.scrollHeight <= element.clientHeight &&
- element.offsetWidth > element.clientWidth;
-
- expect(hasScrollbarContainer).to.be.false;
-}
-
describe("issue 48829", () => {
const questionDetails = {
name: "Issue 48829",
diff --git a/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts b/e2e/test/scenarios/question/reproductions.cy.spec.ts
similarity index 75%
rename from e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
rename to e2e/test/scenarios/question/reproductions.cy.spec.ts
index f3e82b34783..3f7357cce48 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
+++ b/e2e/test/scenarios/question/reproductions.cy.spec.ts
@@ -3,12 +3,8 @@ const { H } = cy;
import { WRITABLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
-import type {
- NativeQuestionDetails,
- StructuredQuestionDetails,
-} from "e2e/support/helpers";
+import type { StructuredQuestionDetails } from "e2e/support/helpers";
import type { Filter, LocalFieldReference } from "metabase-types/api";
-import { createMockParameter } from "metabase-types/api/mocks";
const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
@@ -305,67 +301,7 @@ describe("issue 14124", () => {
cy.findAllByRole("gridcell", { name: "3:00 AM" }).should("be.visible");
});
});
-const MONGO_DB_ID = 2;
-
-describe("issue 47793", () => {
- const questionDetails: NativeQuestionDetails = {
- database: MONGO_DB_ID,
- native: {
- query: `[
- { $match: { quantity: {{quantity}} }},
- {
- "$project": {
- "_id": "$_id",
- "id": "$id",
- "user_id": "$user_id",
- "product_id": "$product_id",
- "subtotal": "$subtotal",
- "tax": "$tax",
- "total": "$total",
- "created_at": "$created_at",
- "quantity": "$quantity",
- "discount": "$discount"
- }
- },
- {
- "$limit": 1048575
- }
-]`,
- "template-tags": {
- quantity: {
- type: "number",
- name: "quantity",
- id: "754ae827-661c-4fc9-b511-c0fb7b6bae2b",
- "display-name": "Quantity",
- default: "10",
- },
- },
- collection: "orders",
- },
- };
-
- beforeEach(() => {
- H.restore("mongo-5");
- cy.signInAsAdmin();
- });
- it(
- "should be able to preview queries for mongodb (metabase#47793)",
- { tags: ["@external", "@mongo"] },
- () => {
- H.createNativeQuestion(questionDetails, { visitQuestion: true });
- cy.findByTestId("visibility-toggler")
- .findByText(/open editor/i)
- .click();
- cy.findByTestId("native-query-editor-container")
- .findByLabelText("Preview the query")
- .click();
- H.modal()
- .should("contain.text", "$project")
- .and("contain.text", "quantity: 10");
- },
- );
-});
describe("issue 49270", () => {
beforeEach(() => {
H.restore();
@@ -436,30 +372,16 @@ describe("issue 53170", () => {
);
});
-describe("issue 54817", () => {
- const placeholder = "Find...";
-
+describe("filter picker and query running state", () => {
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
});
- it("should allow to navigate to the search input in the filter picker via keyboard (metabase#54817)", () => {
- H.openOrdersTable();
- H.filter();
- H.popover().findByPlaceholderText(placeholder).should("be.focused");
- });
-});
-
-describe("issue 57398", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should show the query running state when navigating back (metabase#57398)", () => {
+ it("should focus the filter picker search input and show the query running state when navigating back (metabase#54817, metabase#57398)", () => {
H.openProductsTable();
H.filter();
+ H.popover().findByPlaceholderText("Find...").should("be.focused");
H.popover().within(() => {
cy.log("1st filter");
cy.findByText("Category").click();
@@ -545,7 +467,7 @@ describe("issue 46845", () => {
H.assertQueryBuilderRowCount(1);
});
});
-describe("54205", () => {
+describe("54205", { tags: "@external" }, () => {
beforeEach(() => {
H.restore("postgres-writable");
@@ -561,7 +483,7 @@ describe("54205", () => {
H.resyncDatabase({ dbId: WRITABLE_DB_ID, tableName: "products" });
});
- it("should be able to select a comma separated value", () => {
+ it("should be able to select a comma separated value (metabase#54205)", () => {
H.getTableId({
name: "products",
}).then((tableId) => {
@@ -589,7 +511,6 @@ describe("54205", () => {
name: "Q 54205",
dataset_query: query,
}).then((card) => {
- cy.wrap(card.id).as("questionId");
H.visitQuestion(card.id);
});
});
@@ -623,20 +544,37 @@ describe("issue 55631", () => {
cy.findByTestId("qb-header").button("Save").click();
H.modal().within(() => {
+ cy.findByLabelText("Name").should("have.value", "Orders");
cy.findByLabelText("Name").clear().type("Custom");
cy.findByLabelText("Where do you want to save this?").click();
});
H.pickEntity({ path: ["Our analytics", "First collection"], select: true });
- H.modal().within(() => {
- cy.button("Save").click();
- cy.wait("@cardCreate");
-
- // It is important to have extremely short timeout in order to catch the issue
- // before the dialog closes.
- cy.findByDisplayValue("Orders", { timeout: 10 }).should("not.exist");
+ // The flash happens between the save response and the modal closing,
+ // so record the Name value on every frame until the modal is gone.
+ cy.window().then((win) => {
+ const nameValues: string[] = [];
+ const sample = () => {
+ const input = win.document.querySelector<HTMLInputElement>(
+ '[data-testid="save-question-modal"] input[name="name"]',
+ );
+ if (input) {
+ nameValues.push(input.value);
+ win.requestAnimationFrame(sample);
+ }
+ };
+ sample();
+ cy.wrap(nameValues).as("nameValues");
});
+
+ H.modal().button("Save").click();
+ cy.wait("@cardCreate");
+ cy.findByTestId("save-question-modal").should("not.exist");
+
+ cy.get<string[]>("@nameValues")
+ .should("include", "Custom")
+ .and("not.include", "Orders");
});
});
describe("issue 42723", () => {
@@ -706,7 +644,7 @@ describe("issue 52872", () => {
);
});
- it("Saved questions with a very long title should wrap (metabse#52872)", () => {
+ it("Saved questions with a very long title should wrap (metabase#52872)", () => {
cy.findByDisplayValue(LONG_NAME)
.should("be.visible")
.then(($el) => {
@@ -716,55 +654,10 @@ describe("issue 52872", () => {
});
});
});
-describe("issue 64293", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should be possible to run a query for a empty required parameter without a default value (metabase#64293)", () => {
- const questionDetails: NativeQuestionDetails = {
- name: "Question 1",
- native: {
- query: "SELECT * FROM PEOPLE WHERE state = {{State}}",
- "template-tags": {
- State: {
- type: "text",
- name: "State",
- id: "1",
- "display-name": "State",
- },
- },
- },
- parameters: [
- createMockParameter({
- id: "1",
- slug: "State",
- required: true,
- name: "State",
- }),
- ],
- };
-
- H.createNativeQuestion(questionDetails, { visitQuestion: true });
-
- cy.findByPlaceholderText("State").should("exist");
- cy.findByPlaceholderText("State").type("NY{enter}");
-
- H.runButtonOverlay().should("exist");
- H.runButtonOverlay().click();
-
- H.ensureParameterColumnValue({
- columnName: "STATE",
- columnValue: "NY",
- });
- });
-});
describe("issue #47005", () => {
beforeEach(() => {
H.restore();
- H.restore("postgres-12");
cy.signInAsNormalUser();
H.createQuestion({
@@ -812,7 +705,7 @@ describe("issue 66210", () => {
cy.visit("/");
});
- it("should not allow you to join on metrics", () => {
+ it("should not allow you to join on metrics (metabase#66210)", () => {
H.startNewQuestion();
H.miniPickerBrowseAll().click();
H.entityPickerModalItem(0, "Our analytics").click();
@@ -821,28 +714,12 @@ describe("issue 66210", () => {
H.join();
H.miniPickerBrowseAll().click();
H.entityPickerModalItem(0, "Our analytics").click();
+ H.entityPickerModalItem(1, "Orders").should("be.visible");
H.entityPickerModalLevel(1).findByText(METRIC_NAME).should("not.exist");
});
});
-describe("issue #67903", () => {
- beforeEach(() => {
- cy.viewport(630, 800);
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should not show preview table headers on top of other elements (metabase#67903)", () => {
- H.startNewQuestion();
- H.miniPickerBrowseAll().click();
- H.pickEntity({ path: ["Databases", /Sample Database/, "Orders"] });
- H.getNotebookStep("data").findByTestId("step-preview-button").click();
- H.queryBuilderHeader().findByLabelText("View SQL").click();
- cy.findByTestId("table-header").should("not.be.visible");
- });
-});
-
-describe("issue #67767", () => {
+describe("native query preview on small screens", () => {
const SCREEN_WIDTH = 630;
beforeEach(() => {
@@ -851,12 +728,13 @@ describe("issue #67767", () => {
cy.signInAsAdmin();
});
- it("only show preview query at full width on small screens (metabase#67767)", () => {
+ it("should not show preview table headers on top of other elements and only show preview query at full width on small screens (metabase#67903, metabase#67767)", () => {
H.startNewQuestion();
H.miniPickerBrowseAll().click();
H.pickEntity({ path: ["Databases", /Sample Database/, "Orders"] });
H.getNotebookStep("data").findByTestId("step-preview-button").click();
H.queryBuilderHeader().findByLabelText("View SQL").click();
+ cy.findByTestId("table-header").should("not.be.visible");
H.sidebar()
.findByText("SQL for this question")
.then(($el) => {
@@ -864,85 +742,3 @@ describe("issue #67767", () => {
});
});
});
-
-describe("issue 68574", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- const questionDetails: NativeQuestionDetails = {
- name: "Question 1",
- native: {
- query: "SELECT * FROM ORDERS WHERE CREATED_AT > {{ start }}",
- "template-tags": {
- start: {
- type: "date",
- name: "start",
- "display-name": "Start",
- id: "1",
- },
- },
- },
- parameters: [
- createMockParameter({
- id: "1",
- slug: "start",
- required: true,
- name: "Start",
- type: "date/single",
- target: ["variable", ["template-tag", "start"]],
- }),
- ],
- };
-
- H.createNativeQuestion(questionDetails, { wrapId: true });
- });
-
- it("should be possible to run a query for a empty required parameter without a default value (metabase#68574)", () => {
- updateFormattingSettings({
- date_style: "D MMMM, YYYY",
- date_abbreviate: false,
- });
- visitQuestion("2027-01-01");
- assertParameterFormat("1 January, 2027");
-
- cy.log("change the date format");
- updateFormattingSettings({
- date_style: "dddd, MMMM D, YYYY",
- date_abbreviate: false,
- });
- visitQuestion("2027-01-01");
- assertParameterFormat("Friday, January 1, 2027");
-
- cy.log("enable date abbreviation");
- updateFormattingSettings({
- date_style: "dddd, MMMM D, YYYY",
- date_abbreviate: true,
- });
- visitQuestion("2027-01-01");
- assertParameterFormat("Fri, Jan 1, 2027");
-
- cy.log("even when the setting is unset, it should render a valid format");
- updateFormattingSettings(undefined);
- visitQuestion("2027-01-01");
- assertParameterFormat("January 1, 2027");
- });
-
- function updateFormattingSettings(settings: any) {
- H.updateSetting("custom-formatting", {
- "type/Temporal": settings,
- });
- }
-
- function visitQuestion(value: string) {
- cy.get("@questionId").then((id) => {
- cy.visit(`/question/${id}?start=${value}`);
- });
- }
-
- function assertParameterFormat(value: string) {
- cy.findByTestId("parameter-value-widget-target")
- .should("be.visible")
- .should("contain.text", value);
- }
-});
diff --git a/e2e/test/scenarios/question/saved.cy.spec.js b/e2e/test/scenarios/question/saved.cy.spec.js
index 967c7993e0b..0602601166b 100644
--- a/e2e/test/scenarios/question/saved.cy.spec.js
+++ b/e2e/test/scenarios/question/saved.cy.spec.js
@@ -69,11 +69,22 @@ describe("scenarios > question > saved", () => {
cy.findByText("Started from").should("not.exist");
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("Quantity is equal to 100").should("not.exist");
- });
- it("should duplicate a saved question into a collection", () => {
- cy.intercept("POST", "/api/card").as("cardCreate");
+ H.summarize();
+ H.rightSidebar().within(() => {
+ cy.findByText("Quantity").click();
+ cy.button("Done").click();
+ });
+
+ H.appBar().within(() => {
+ cy.findByText("Started from").should("be.visible");
+ cy.findByText("Orders").click();
+ cy.findByText("Started from").should("not.exist");
+ });
+ });
+ it("should duplicate a saved question into a collection, into a dashboard, and to a collection created on the go", () => {
+ cy.log("into a collection");
H.visitQuestion(ORDERS_QUESTION_ID);
H.openQuestionActions();
@@ -90,11 +101,8 @@ describe("scenarios > question > saved", () => {
cy.findByTestId("qb-header-left-side").within(() => {
cy.findByDisplayValue("Orders - Duplicate");
});
- });
-
- it("should duplicate a saved question into a dashboard", () => {
- cy.intercept("POST", "/api/card").as("cardCreate");
+ cy.log("into a dashboard");
H.visitQuestion(ORDERS_QUESTION_ID);
H.openQuestionActions();
@@ -122,11 +130,8 @@ describe("scenarios > question > saved", () => {
cy.url().should("include", "/dashboard/");
cy.location("hash").should("not.include", "scrollTo");
H.dashboardCards().findByText("Orders - Duplicate").should("be.visible");
- });
-
- it("should duplicate a saved question to a collection created on the go", () => {
- cy.intercept("POST", "/api/card").as("cardCreate");
+ cy.log("to a collection created on the go");
H.visitQuestion(ORDERS_QUESTION_ID);
H.openQuestionActions();
@@ -139,7 +144,7 @@ describe("scenarios > question > saved", () => {
cy.findByTestId("dashboard-and-collection-picker-button").click();
});
- H.entityPickerModal().findByText("New collection").click();
+ H.entityPickerModal().button("New collection").should("be.enabled").click();
const NEW_COLLECTION = "My New collection";
H.collectionOnTheGoModal().then(() => {
@@ -181,6 +186,11 @@ describe("scenarios > question > saved", () => {
H.openQuestionActions();
H.popover().findByText("Duplicate").click();
+ H.modal()
+ .findByLabelText("Name")
+ .should(($input) => {
+ expect($input.val()).to.match(/ - Duplicate$/);
+ });
H.modal().should(($el) => {
const $modal = $el[0];
expect($modal.clientWidth).to.be.equal($modal.scrollWidth);
@@ -200,6 +210,7 @@ describe("scenarios > question > saved", () => {
.blur();
cy.wait("@updateQuestion");
+ cy.findByText("This is a question").should("be.visible");
cy.findByRole("tab", { name: "History" }).click();
cy.findByText(/added a description/i);
@@ -215,7 +226,11 @@ describe("scenarios > question > saved", () => {
cy.findByRole("tab", { name: "History" }).click();
cy.findByText(/reverted to an earlier version/i);
- cy.findByText(/This is a question/i).should("not.exist");
+
+ cy.findByRole("tab", { name: "Overview" }).click();
+ cy.findByPlaceholderText("Add description").should("have.value", "");
+
+ cy.findByRole("tab", { name: "History" }).click();
// Simulate a backend failure on revert and confirm we surface
// the error message as a toast (UXW-310).
@@ -231,16 +246,15 @@ describe("scenarios > question > saved", () => {
H.undoToast().should("contain.text", "Cannot revert: missing card");
});
- it("should show collection breadcrumbs for a saved question in the root collection", () => {
+ it("should show collection breadcrumbs for a saved question in the root and a non-root collection", () => {
H.visitQuestion(ORDERS_QUESTION_ID);
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
H.appBar().within(() => cy.findByText("Our analytics").click());
+ cy.location("pathname").should("eq", "/collection/root");
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders").should("be.visible");
- });
- it("should show collection breadcrumbs for a saved question in a non-root collection", () => {
cy.request("PUT", `/api/card/${ORDERS_QUESTION_ID}`, {
collection_id: SECOND_COLLECTION_ID,
});
@@ -249,6 +263,10 @@ describe("scenarios > question > saved", () => {
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
H.appBar().within(() => cy.findByText("Second collection").click());
+ cy.location("pathname").should(
+ "match",
+ new RegExp(`^/collection/${SECOND_COLLECTION_ID}(-|$)`),
+ );
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders").should("be.visible");
});
@@ -273,26 +291,14 @@ describe("scenarios > question > saved", () => {
cy.findByText("Orders in a dashboard").should("not.exist");
});
+ cy.location("pathname").should(
+ "match",
+ new RegExp(`^/dashboard/${ORDERS_DASHBOARD_ID}(-|$)`),
+ );
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders").should("be.visible");
});
- it("should show the question lineage when a saved question is changed", () => {
- H.visitQuestion(ORDERS_QUESTION_ID);
-
- H.summarize();
- H.rightSidebar().within(() => {
- cy.findByText("Quantity").click();
- cy.button("Done").click();
- });
-
- H.appBar().within(() => {
- cy.findByText("Started from").should("be.visible");
- cy.findByText("Orders").click();
- cy.findByText("Started from").should("not.exist");
- });
- });
-
it("'read-only' user should be able to resize column width (metabase#9772)", () => {
cy.signIn("readonly");
H.visitQuestion(ORDERS_QUESTION_ID);
@@ -376,13 +382,32 @@ describe("scenarios > question > saved", () => {
cy.findByTestId("dataset-edit-bar").button("Save").click();
- cy.findByTestId("save-question-modal").within(() => {
- cy.button("Save").click();
- cy.wait("@cardCreate");
- // It is important to have extremely short timeout in order to catch the issue
- cy.findByDisplayValue("Products - Modified", { timeout: 10 }).should(
- "not.exist",
- );
+ cy.findByTestId("save-question-modal")
+ .findByLabelText("Name")
+ .should("have.value", "Products");
+
+ // The suffix flashes for a frame between the save response and the modal
+ // closing, so record the name on every frame until the modal is gone.
+ const names = [];
+ cy.window().then((win) => {
+ const sample = () => {
+ const input = win.document.querySelector(
+ "[data-testid='save-question-modal'] input[name='name']",
+ );
+ if (input) {
+ names.push(input.value);
+ win.requestAnimationFrame(sample);
+ }
+ };
+ sample();
+ });
+
+ cy.findByTestId("save-question-modal").button("Save").click();
+ cy.wait("@cardCreate");
+ cy.findByTestId("save-question-modal").should("not.exist");
+ cy.wrap(names).should((values) => {
+ expect(values).to.include("Products");
+ expect(values.filter((name) => /- Modified$/.test(name))).to.be.empty;
});
});
@@ -410,24 +435,7 @@ describe("scenarios > question > saved", () => {
}
HIDDEN_TYPES.forEach((visibilityType) => {
- it(`should show a View-only tag when the source table is marked as ${visibilityType}`, () => {
- hideTable({ name: "Orders", id: ORDERS_ID, visibilityType });
-
- H.visitQuestion(ORDERS_QUESTION_ID);
-
- H.queryBuilderHeader()
- .findByText("View-only")
- .should("be.visible")
- .realHover();
- H.popover()
- .findByText(
- "One of the administrators hid the source table “Orders”, making this question view-only.",
- )
- .should("be.visible");
- });
-
- it(`should show a View-only tag when a joined table is marked as ${visibilityType}`, () => {
- cy.signInAsAdmin();
+ it(`should show a View-only tag when a joined or the source table is marked as ${visibilityType}`, () => {
hideTable({ name: "Products", id: PRODUCTS_ID, visibilityType });
H.createQuestion(
{
@@ -437,7 +445,7 @@ describe("scenarios > question > saved", () => {
joins: [
{
"source-table": PRODUCTS_ID,
- alias: "Orders",
+ alias: "Products",
condition: [
"=",
["field", ORDERS.PRODUCT_ID, null],
@@ -461,6 +469,20 @@ describe("scenarios > question > saved", () => {
"One of the administrators hid the source table “Products”, making this question view-only.",
)
.should("be.visible");
+
+ hideTable({ name: "Orders", id: ORDERS_ID, visibilityType });
+
+ H.visitQuestion(ORDERS_QUESTION_ID);
+
+ H.queryBuilderHeader()
+ .findByText("View-only")
+ .should("be.visible")
+ .realHover();
+ H.popover()
+ .findByText(
+ "One of the administrators hid the source table “Orders”, making this question view-only.",
+ )
+ .should("be.visible");
});
});
@@ -482,12 +504,12 @@ describe("scenarios > question > saved", () => {
joins: [
{
"source-table": PRODUCTS_ID,
- alias: "Orders Question",
+ alias: "Products",
fields: "all",
condition: [
"=",
- ["field", PRODUCTS.PRODUCT_ID, null],
- ["field", ORDERS.ID, { "join-alias": "Orders" }],
+ ["field", ORDERS.PRODUCT_ID, null],
+ ["field", PRODUCTS.ID, { "join-alias": "Products" }],
],
},
],
@@ -499,6 +521,14 @@ describe("scenarios > question > saved", () => {
},
);
+ cy.signInAsNormalUser();
+ cy.get("@questionId").then(H.visitQuestion);
+ H.queryBuilderHeader()
+ .findByDisplayValue("Products Question + Orders")
+ .should("be.visible");
+ H.queryBuilderHeader().findByText("View-only").should("not.exist");
+
+ cy.signInAsAdmin();
H.visitQuestion(ORDERS_QUESTION_ID);
moveQuestionTo(/Personal Collection/);
@@ -511,7 +541,6 @@ describe("scenarios > question > saved", () => {
describe("with watermark", () => {
beforeEach(() => {
- H.restore();
cy.signInAsAdmin();
H.activateToken("pro-self-hosted");
diff --git a/e2e/test/scenarios/question/settings.cy.spec.js b/e2e/test/scenarios/question/settings.cy.spec.js
index 14c70307bb3..fbd16f5cf18 100644
--- a/e2e/test/scenarios/question/settings.cy.spec.js
+++ b/e2e/test/scenarios/question/settings.cy.spec.js
@@ -24,6 +24,7 @@ describe("scenarios > question > settings", () => {
cy.findByTestId("sidebar-left").invoke("width").should("be.gt", 350);
cy.findByTestId("sidebar-content").as("tableOptions");
+ H.tableInteractive().contains("Total");
cy.findByRole("button", { name: "Add or remove columns" }).click();
@@ -460,9 +461,9 @@ describe("scenarios > question > settings", () => {
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.contains("Orders").click();
- // This next assertion might not catch bugs where the modal displays after
- // a quick delay. With the previous presentation of this bug, the modal
- // was immediately visible, so I'm not going to add any waits.
+ cy.location("pathname").should("eq", `/table/${ORDERS_ID}-orders`);
+ H.tableInteractive().should("be.visible");
+ H.entityPickerModal().should("not.exist");
H.modal().should("not.exist");
});
});
diff --git a/e2e/test/scenarios/question/summarization.cy.spec.js b/e2e/test/scenarios/question/summarization.cy.spec.js
index 755c78be5c7..81de6823869 100644
--- a/e2e/test/scenarios/question/summarization.cy.spec.js
+++ b/e2e/test/scenarios/question/summarization.cy.spec.js
@@ -1,6 +1,4 @@
const { H } = cy;
-import { dedent } from "ts-dedent";
-
import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
@@ -18,18 +16,7 @@ describe("scenarios > question > summarize sidebar", () => {
H.summarize();
});
- it("removing all aggregations should show add aggregation button with label", () => {
- cy.findByTestId("aggregation-item").within(() => {
- cy.icon("close").click();
- });
-
- cy.findByTestId("add-aggregation-button").should(
- "have.text",
- "Add a function or metric",
- );
- });
-
- it("selected dimensions becomes pinned to the top of the dimensions list", () => {
+ it("selected dimensions become pinned to the top of the dimensions list (with the table alias for another table), and removing all aggregations shows the add aggregation button", () => {
H.getDimensionByName({ name: "Total" })
.should("have.attr", "aria-selected", "false")
.click({ position: "left" });
@@ -65,9 +52,7 @@ describe("scenarios > question > summarize sidebar", () => {
cy.findByTestId("unpinned-dimensions").within(() => {
cy.findByText("Total");
});
- });
- it("selected dimensions from another table includes the table alias when becomes pinned to the top", () => {
H.getDimensionByName({ name: "State" }).click();
cy.button("Done").click();
@@ -86,6 +71,15 @@ describe("scenarios > question > summarize sidebar", () => {
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("User → State").should("not.exist");
+
+ cy.findByTestId("aggregation-item").within(() => {
+ cy.icon("close").click();
+ });
+
+ cy.findByTestId("add-aggregation-button").should(
+ "have.text",
+ "Add a function or metric",
+ );
});
it("selecting a binning adds a dimension", () => {
@@ -111,58 +105,40 @@ describe("scenarios > question > summarize sidebar", () => {
});
});
- it("should allow using `Custom Expression` in orders metrics (metabase#12899)", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.summarize({ mode: "notebook" });
- H.popover().contains("Custom Expression").click();
-
- H.enterCustomColumnDetails({
- formula: "2 * Max([Total])",
- name: "twice max total",
+ it("should only have one scrollbar for the summarize sidebar and not show the run button overlay when an error occurs (metabase#45452, metabase#12586)", () => {
+ cy.findByTestId("summarize-aggregation-item-list").then(($el) => {
+ const element = $el[0];
+ expectNoScrollbar(element);
});
- H.expressionEditorWidget().button("Done").click();
- cy.findByTestId("aggregate-step")
- .contains("twice max total")
- .should("exist");
-
- H.visualize();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("318.7");
- });
-
- it("should keep manually entered parenthesis intact if they affect the result (metabase#13306)", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.summarize({ mode: "notebook" });
+ cy.findByTestId("summarize-breakout-column-list").then(($el) => {
+ const element = $el[0];
+ expectNoScrollbar(element);
+ });
- H.popover().contains("Custom Expression").click();
- H.enterCustomColumnDetails({
- formula: "sum([Total]) / (sum([Product → Price]) * average([Quantity]))",
- format: true,
+ // the sidebar is the only element with a scrollbar
+ cy.findByTestId("sidebar-content").then(($el) => {
+ const element = $el[0];
+ expect(element.scrollHeight > element.clientHeight).to.be.true;
+ expect(element.offsetWidth > element.clientWidth).to.be.true;
});
- H.CustomExpressionEditor.value().should(
- "equal",
- dedent`
- Sum([Total]) /
- (Sum([Product → Price]) * Average([Quantity]))
- `.trim(),
- );
- });
+ cy.intercept("POST", "/api/dataset", (req) => req.destroy());
- it("distinct inside custom expression should suggest non-numeric types (metabase#13469)", () => {
- H.openReviewsTable({ mode: "notebook" });
- H.summarize({ mode: "notebook" });
- H.popover().contains("Custom Expression").click();
+ H.rightSidebar().button("Done").click();
+ H.main()
+ .findByText("We're experiencing server issues")
+ .should("be.visible");
+ cy.findByTestId("query-builder-main").icon("play").should("not.be.visible");
+ });
+});
- H.enterCustomColumnDetails({ formula: "Distinct([R", blur: false });
+describe("scenarios > question > summarize", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
- cy.log(
- "**The point of failure for ANY non-numeric value reported in v0.36.4**",
- );
- // the default type for "Reviewer" is "No semantic type"
- H.CustomExpressionEditor.completion("Reviewer").should("be.visible");
+ cy.intercept("POST", "/api/dataset").as("dataset");
});
it("summarizing by distinct datetime should allow granular selection (metabase#13098)", () => {
@@ -181,6 +157,10 @@ describe("scenarios > question > summarize sidebar", () => {
cy.button("More…").click();
cy.findByText("Hour of day").click();
});
+
+ H.getNotebookStep("summarize")
+ .findByText("Distinct values of Created At: Hour of day")
+ .should("be.visible");
});
it("should handle (removing) multiple metrics when one is sorted (metabase#12625)", () => {
@@ -272,3 +252,14 @@ function removeMetricFromSidebar(metricName) {
cy.findByLabelText(metricName).should("not.exist");
});
}
+
+function expectNoScrollbar(element) {
+ const { borderLeftWidth, borderRightWidth } = getComputedStyle(element);
+ const scrollbarWidth =
+ element.offsetWidth -
+ element.clientWidth -
+ parseFloat(borderLeftWidth) -
+ parseFloat(borderRightWidth);
+
+ expect(scrollbarWidth).to.equal(0);
+}