The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Consolidate models e2e tests (#83339)
Nemanja Glumacd75a4bdfcda9
diff --git a/e2e/test/scenarios/models/create.cy.spec.js b/e2e/test/scenarios/models/create.cy.spec.jsindex 18344e96869..bbecc16643b 100644--- a/e2e/test/scenarios/models/create.cy.spec.js+++ b/e2e/test/scenarios/models/create.cy.spec.js@@ -10,28 +10,45 @@ describe("scenarios > models > create", () => {it("creates a native query model", () => {const modelName = "m42";+ cy.intercept("POST", "/api/card").as("createModel");navigateToNewModelPage();// Cancel creation with confirmation modalcy.findByTestId("dataset-edit-bar").button("Cancel").click();H.modal().button("Discard changes").click();+ cy.location("pathname").should("eq", "/");- // Now we will create a model- navigateToNewModelPage();+ // Now we will create a model from the browse page+ cy.visit("/browse/models");+ cy.findByLabelText("Create a new model").click();+ cy.findByTestId("new-model-options")+ .findByText("Use a native query")+ .click();// Clicking on metadata should not work until we run a querycy.findByTestId("editor-tabs-columns").should("be.disabled");H.NativeEditor.focus().type("select 42");- cy.findByTestId("native-query-editor-container").icon("play").click();++ cy.log("the editor should not overflow its container (metabase#69722)");+ H.NativeEditor.type("{enter}".repeat(20));+ cy.findByTestId("native-query-editor-container")+ .findByTestId("run-button")+ .should("be.visible");++ cy.findByTestId("native-query-editor-container")+ .findByLabelText("Get Answer")+ .click();cy.wait("@dataset");+ cy.findByTestId("visualization-root").should("contain", "42");cy.findByTestId("dataset-edit-bar").button("Save").click();cy.findByTestId("save-question-modal").within(() => {cy.findByLabelText("Name").type(modelName);cy.button("Save").click();});+ cy.wait("@createModel");// After saving, we land on view mode for the modelcy.location("pathname").should("match", /^\/model\/\d+-.*$/);@@ -39,9 +56,19 @@ describe("scenarios > models > create", () => {});// This covers creating a GUI model from the browse page + nocollection permissions (2 in 1)- it("user without a collection access should still be able to create and save a model in his own personal collection", () => {+ it("user without a collection access should still be able to create and save a model in his own personal collection, and one without native permissions cannot start a model", () => {cy.intercept("POST", "/api/card").as("createModel");+ cy.log(+ "a user without native permissions should not be able to initiate a new model creation",+ );+ cy.signIn("nosql");+ cy.visit("/browse/models");+ cy.findByTestId("browse-models-header").within(() => {+ cy.findByRole("heading").should("contain", "Models").and("be.visible");+ cy.findByLabelText("Create a new model").should("not.exist");+ });+cy.signIn("nocollection");cy.visit("/browse/models");@@ -60,39 +87,6 @@ describe("scenarios > models > create", () => {cy.wait("@createModel");cy.location("pathname").should("match", /^\/model\/\d+-.*$/);});-- it("should be able to create a new native model from the browse page", () => {- cy.intercept("POST", "/api/dataset").as("previewModel");- cy.intercept("POST", "/api/card").as("createModel");-- cy.visit("/browse/models");- cy.findByLabelText("Create a new model").click();- cy.findByTestId("new-model-options")- .findByText("Use a native query")- .click();- H.NativeEditor.focus().type("select 42");- cy.findByTestId("native-query-editor-container")- .findByLabelText("Get Answer")- .click();- cy.wait("@previewModel");- cy.findByTestId("visualization-root").should("contain", "42");- cy.findByTestId("dataset-edit-bar").button("Save").click();- cy.findByTestId("save-question-modal").within(() => {- cy.findByLabelText("Name").type("m42");- cy.button("Save").click();- });- cy.wait("@createModel");- cy.location("pathname").should("match", /^\/model\/\d+-.*$/);- });-- it("should not be possible to initiate a new model creation without native permissions", () => {- cy.signIn("nosql");- cy.visit("/browse/models");- cy.findByTestId("browse-models-header").within(() => {- cy.findByRole("heading").should("contain", "Models").and("be.visible");- cy.findByLabelText("Create a new model").should("not.exist");- });- });});function navigateToNewModelPage(queryType = "native") {diff --git a/e2e/test/scenarios/models/helpers/e2e-models-helpers.js b/e2e/test/scenarios/models/helpers/e2e-models-helpers.jsindex c90f4d97b6b..4fd902313bb 100644--- a/e2e/test/scenarios/models/helpers/e2e-models-helpers.js+++ b/e2e/test/scenarios/models/helpers/e2e-models-helpers.js@@ -26,7 +26,7 @@ export function assertQuestionIsBasedOnModel({cy.findByText(table).should("not.exist");}-export function saveQuestionBasedOnModel({ modelId, name }) {+export function saveQuestionBasedOnModel({ name }) {cy.intercept("POST", "/api/card").as("createCard");cy.findByText("Save").click();@@ -38,6 +38,7 @@ export function saveQuestionBasedOnModel({ modelId, name }) {}cy.findByText("Save").click();});+ cy.wait("@createCard");}export function selectDimensionOptionFromSidebar(name) {diff --git a/e2e/test/scenarios/models/model-indexes.cy.spec.js b/e2e/test/scenarios/models/model-indexes.cy.spec.jsindex 29f4893c102..5bda754e31a 100644--- a/e2e/test/scenarios/models/model-indexes.cy.spec.js+++ b/e2e/test/scenarios/models/model-indexes.cy.spec.js@@ -2,7 +2,7 @@ const { H } = cy;import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";import { createModelIndex } from "e2e/support/helpers/e2e-model-index-helper";-const { PRODUCTS_ID, PEOPLE_ID } = SAMPLE_DATABASE;+const { PRODUCTS_ID } = SAMPLE_DATABASE;describe("scenarios > model indexes", () => {let modelId;@@ -10,7 +10,6 @@ describe("scenarios > model indexes", () => {beforeEach(() => {H.restore();cy.signInAsAdmin();- cy.intercept("GET", "/api/search?q=*").as("searchQuery");cy.intercept("POST", "/api/dataset").as("dataset");cy.intercept("POST", "/api/model-index").as("modelIndexCreate");cy.intercept("DELETE", "/api/model-index/*").as("modelIndexDelete");@@ -36,58 +35,26 @@ describe("scenarios > model indexes", () => {cy.wait("@dataset");editTitleMetadata();-- H.sidebar()- .findByLabelText(/surface individual records/i)- .click({ force: true }); // needs to be forced because Mantine-- cy.findByTestId("dataset-edit-bar").within(() => {- cy.button("Save changes").click();- });-- cy.wait("@modelIndexCreate").then(({ request, response }) => {- expect(request.body.model_id).to.equal(modelId);-- // this will likely change when this becomes an async process- expect(response.body.state).to.equal("indexed");- expect(response.body.id).to.equal(1);- });+ toggleSurfaceIndividualRecords();+ saveModelIndexChanges();+ cy.wait("@modelIndexCreate");+ assertIndexedValueSearchable();editTitleMetadata();-- H.sidebar()- .findByLabelText(/surface individual records/i)- .click({ force: true });-- cy.findByTestId("dataset-edit-bar").within(() => {- cy.button("Save changes").click();- });-- cy.wait("@modelIndexDelete").then(({ request, response }) => {- expect(request.url).to.include("/api/model-index/1");- expect(response.statusCode).to.equal(200);- });-+ getSurfaceIndividualRecordsToggle().should("be.checked");+ toggleSurfaceIndividualRecords();+ saveModelIndexChanges();+ cy.wait("@modelIndexDelete");cy.wait("@dataset");editTitleMetadata();+ getSurfaceIndividualRecordsToggle().should("not.be.checked");+ toggleSurfaceIndividualRecords();+ saveModelIndexChanges();- H.sidebar()- .findByLabelText(/surface individual records/i)- .click({ force: true });-- cy.findByTestId("dataset-edit-bar").within(() => {- cy.button("Save changes").click();- });-- // this tests redux cache invalidation (#31407)- cy.wait("@modelIndexCreate").then(({ request, response }) => {- expect(request.body.model_id).to.equal(modelId);-- // this will likely change when this becomes an async process- expect(response.body.state).to.equal("indexed");- expect(response.body.id).to.equal(2);- });+ // the deleted index must not linger in the cached model index list (metabase#31094)+ cy.wait("@modelIndexCreate");+ assertIndexedValueSearchable();});it("should not allow indexing when a primary key has been unassigned", () => {@@ -95,10 +62,7 @@ describe("scenarios > model indexes", () => {cy.wait("@dataset");editTitleMetadata();-- H.sidebar()- .findByLabelText(/surface individual records/i)- .click({ force: true });+ toggleSurfaceIndividualRecords();H.openColumnOptions("ID");@@ -111,9 +75,12 @@ describe("scenarios > model indexes", () => {.findByText(/foreign key/i).click();- cy.findByTestId("dataset-edit-bar").button("Save changes").click();+ saveModelIndexChanges();cy.wait("@cardUpdate");+ // The editor closes once the model indexes have been updated+ cy.findByTestId("dataset-edit-bar").should("not.exist");+ H.tableInteractive().findByText("Rustic Paper Wallet").should("be.visible");// search should failH.commandPaletteSearch("marble shoes", false);@@ -123,63 +90,6 @@ describe("scenarios > model indexes", () => {.should("exist");});- it("should be able to search model index values and visit detail records", () => {- createModelIndex({ modelId, pkName: "ID", valueName: "TITLE" });-- cy.visit("/");-- H.commandPaletteSearch("marble shoes", false);- H.commandPalette()- .findByRole("option", { name: "Small Marble Shoes" })- .click();-- cy.wait("@dataset");-- cy.findByTestId("object-detail").within(() => {- cy.findByRole("heading", { name: "Small Marble Shoes" }).should(- "be.visible",- );- cy.findAllByText("Small Marble Shoes").should("have.length", 2);- cy.findByText("Doohickey").should("be.visible");- });- });-- it.skip("should be able to see details of a record outside the first 2000", () => {- H.createQuestion(- {- name: "People Model",- query: { "source-table": PEOPLE_ID },- type: "model",- },- {- wrapId: true,- idAlias: "people_model_id",- },- );-- cy.get("@people_model_id").then((peopleModelId) => {- createModelIndex({- modelId: peopleModelId,- pkName: "ID",- valueName: "NAME",- });- });-- cy.visit("/");-- H.commandPaletteSearch("anais", false);- H.commandPalette().findByRole("option", { name: "Anais Zieme" }).click();-- cy.wait("@dataset");- cy.wait("@dataset"); // second query gets the additional record-- cy.findByTestId("object-detail").within(() => {- cy.findByText(/We're a little lost/i).should("not.exist");- cy.findByRole("heading", { name: "Anais Zieme" }).should("be.visible");- cy.findAllByText("Anais Zieme").should("have.length", 2);- });- });-it("should not reload the model for record in the same model", () => {createModelIndex({ modelId, pkName: "ID", valueName: "TITLE" });@@ -210,6 +120,9 @@ describe("scenarios > model indexes", () => {.click();cy.findByTestId("object-detail").within(() => {+ cy.findByRole("heading", { name: "Ergonomic Silk Coat" }).should(+ "be.visible",+ );cy.findByText("Upton, Kovacek and Halvorson");});@@ -226,6 +139,30 @@ function editTitleMetadata() {H.openColumnOptions("Title");}+function getSurfaceIndividualRecordsToggle() {+ return H.sidebar().findByLabelText(/surface individual records/i);+}++function toggleSurfaceIndividualRecords() {+ // needs to be forced because Mantine+ getSurfaceIndividualRecordsToggle().click({ force: true });+}++function saveModelIndexChanges() {+ cy.findByTestId("dataset-edit-bar").button("Save changes").click();+}++function assertIndexedValueSearchable() {+ // The editor closes once the model indexes have been updated+ cy.findByTestId("dataset-edit-bar").should("not.exist");+ H.commandPaletteSearch("marble shoes", false);+ H.commandPalette()+ .findByRole("option", { name: "Small Marble Shoes" })+ .should("exist");+ cy.get("body").type("{esc}");+ H.commandPalette().should("not.exist");+}+const expectCardQueries = (num) =>cy.get("@cardGet.all").then((interceptions) => {expect(interceptions).to.have.length(num);diff --git a/e2e/test/scenarios/models/models-list-view.cy.spec.js b/e2e/test/scenarios/models/models-list-view.cy.spec.jsindex 93bd7c3faee..3b04aeeaf9c 100644--- a/e2e/test/scenarios/models/models-list-view.cy.spec.js+++ b/e2e/test/scenarios/models/models-list-view.cy.spec.js@@ -9,7 +9,6 @@ describe("scenarios > models list view", () => {beforeEach(() => {H.restore();cy.signInAsAdmin();- cy.intercept("POST", "/api/card/*/query").as("cardQuery");cy.intercept("POST", "/api/dataset").as("dataset");H.createNativeQuestion(@@ -20,11 +19,11 @@ describe("scenarios > models list view", () => {query: "SELECT * FROM ORDERS LIMIT 5",},},- { visitQuestion: true },+ { visitQuestion: true, wrapId: true },);});- it("should allow to change default view", () => {+ it("should allow to change default view, keep it on duplicates, and drop it for questions", () => {H.openQuestionActions();H.popover().findByTextEnsureVisible("Edit metadata").click();@@ -55,10 +54,36 @@ describe("scenarios > models list view", () => {cy.wait("@dataset");cy.log("Display data as list after saving");+ cy.findByTestId("dataset-edit-bar").should("not.exist");cy.findByTestId("list-view").should("be.visible");++ cy.log("Preserve list view after model duplication");+ H.openQuestionActions();+ H.popover().findByTextEnsureVisible("Duplicate").click();+ H.modal().findByTextEnsureVisible("Duplicate").click();+ cy.wait("@dataset");++ cy.findByTestId("qb-header").within(() => {+ cy.findByText("Native Model - Duplicate").should("be.visible");+ });+ cy.findByTestId("list-view").should("be.visible");++ cy.log("Change list view to table when saved as question");+ cy.get("@questionId").then((id) => H.visitModel(id));+ cy.findByTestId("qb-header")+ .findByText("Native Model")+ .should("be.visible");+ cy.findByTestId("list-view").should("be.visible");+ H.openQuestionActions();+ H.popover()+ .findByTextEnsureVisible("Turn back to saved question")+ .click();+ H.undoToast().should("contain.text", "This is a question now");+ H.tableInteractive().should("be.visible");+ cy.findByTestId("list-view").should("not.exist");});- it("should allow to customize list view", () => {+ it("should allow to customize list view, and filter and drag-n-drop its columns", () => {H.openQuestionActions();H.popover().findByTextEnsureVisible("Edit metadata").click();@@ -112,6 +137,57 @@ describe("scenarios > models list view", () => {cy.findByText("2.07").should("be.visible");});+ cy.log("Filter and drag-n-drop columns");+ cy.findByTestId("sidebar-right").as("sidebarRight");++ cy.log("Check that used column is not present in unused columns list.");+ cy.get("@sidebarRight").findByText("CREATED_AT").should("be.visible");+ cy.get("@sidebarRight").findByText("PRODUCT_ID").should("not.exist");++ cy.get("@rightColumns").within(() => {+ cy.get("input").type("{Backspace}{Backspace}");+ });++ cy.log(+ "Find a draggable element with 'SUBTOTAL' text in sidebarRight panel and drag it into @rightColumns input",+ );++ cy.get("@sidebarRight").within(() => {+ cy.findByText("SUBTOTAL").should("be.visible");+ });++ cy.get("@listPreview").within(() => {+ cy.findByText("37.65").should("not.exist");+ });++ cy.get("@sidebarRight").find("input").type("SUB");++ H.dragAndDropByElement(+ cy.get("@sidebarRight").findByText("SUBTOTAL"),+ cy.get("@rightColumns").find("input"),+ { dragend: false },+ );++ cy.log("Verify that drag was handled correctly");+ cy.get("@rightColumns").within(() => {+ cy.findByText("SUBTOTAL").should("be.visible");+ });+ cy.get("@sidebarRight").within(() => {+ cy.findByText("SUBTOTAL").should("not.exist");+ cy.findByText("No available columns").should("be.visible");+ });+ cy.get("@listPreview").within(() => {+ cy.findByText("37.65").should("be.visible");+ });++ cy.log("Restore the TAX column removed with the backspaces");+ cy.get("@rightColumns").within(() => {+ cy.get("input").type("TAX");+ });+ H.popover().findByText("TAX").click();+ cy.get("@rightColumns").findByText("TAX").should("be.visible");+ cy.get("@listPreview").findByText("2.07").should("be.visible");+cy.log("Add CREATED_AT column to right columns");cy.get("@rightColumns").within(() => {cy.get("input").type("CR");@@ -208,154 +284,9 @@ describe("scenarios > models list view", () => {cy.findByText("2.07").should("not.exist");});});-- it("should allow to filter and drag-n-drop columns", () => {- H.openQuestionActions();-- H.popover().findByTextEnsureVisible("Edit metadata").click();-- cy.findByTestId("dataset-edit-bar").findByText("Settings").click();-- cy.findByTestId("sidebar-right").within(() => {- cy.findByText("List").click();- });-- cy.findByRole("button", { name: "Customize the List layout" }).click();-- // Alias the main elements for reuse- cy.findByTestId("list-view-right-columns").as("rightColumns");- cy.findByTestId("list-view-preview").as("listPreview");- cy.findByTestId("sidebar-right").as("sidebarRight");-- cy.log("Check that used column is not present in unused columns list.");- cy.get("@sidebarRight").findByText("PRODUCT_ID").should("not.exist");-- cy.get("@rightColumns").within(() => {- cy.get("input").type("{Backspace}{Backspace}");- });-- cy.log(- "Find a draggable element with 'SUBTOTAL' text in sidebarRight panel and drag it into @rightColumns input",- );-- cy.get("@sidebarRight").within(() => {- cy.findByText("SUBTOTAL").should("be.visible");- });-- cy.get("@listPreview").within(() => {- cy.findByText("37.65").should("not.exist");- });-- cy.get("@sidebarRight").find("input").type("SUB");-- H.dragAndDropByElement(- cy.get("@sidebarRight").findByText("SUBTOTAL"),- cy.get("@rightColumns").find("input"),- { dragend: false },- );-- cy.log("Verify that drag was handled correctly");- cy.get("@rightColumns").within(() => {- cy.findByText("SUBTOTAL").should("be.visible");- });- cy.get("@sidebarRight").within(() => {- cy.findByText("SUBTOTAL").should("not.exist");- cy.findByText("No available columns").should("be.visible");- });- cy.get("@listPreview").within(() => {- cy.findByText("37.65").should("be.visible");- });- });});describe("advanced scenarios", () => {- it("should preserve list view after model duplication", () => {- H.restore();- cy.signInAsAdmin();- cy.intercept("POST", "/api/card/*/query").as("cardQuery");- cy.intercept("POST", "/api/dataset").as("dataset");-- H.createNativeQuestion(- {- name: "Native Model",- type: "model",- native: {- query: "SELECT * FROM ORDERS LIMIT 5",- },- },- { visitQuestion: true },- );- H.openQuestionActions();-- // Going through full flow, because for some reason `display: list` is not preserved on BE.- H.popover().findByTextEnsureVisible("Edit metadata").click();-- cy.findByTestId("dataset-edit-bar").findByText("Settings").click();-- cy.findByTestId("sidebar-right").within(() => {- cy.findByText("List").click();- });-- cy.findByTestId("dataset-edit-bar").button("Save changes").click();- cy.wait("@dataset");-- cy.findByTestId("list-view").should("be.visible");-- H.openQuestionActions();-- H.popover().findByTextEnsureVisible("Duplicate").click();- H.modal().findByTextEnsureVisible("Duplicate").click();- cy.wait("@dataset");-- cy.log("Display data as list after duplication");- cy.findByTestId("qb-header").within(() => {- cy.findByText("Native Model - Duplicate").should("be.visible");- });- cy.findByTestId("list-view").should("be.visible");- });-- it("should change list view to table when saved as question", () => {- H.restore();- cy.signInAsAdmin();- cy.intercept("POST", "/api/card/*/query").as("cardQuery");- cy.intercept("POST", "/api/dataset").as("dataset");-- H.createNativeQuestion(- {- name: "Native Model",- type: "model",- native: {- query: "SELECT * FROM ORDERS LIMIT 5",- },- },- { visitQuestion: true },- );- H.openQuestionActions();-- // Going through full flow, because for some reason `display: list` is not preserved on BE.- H.popover().findByTextEnsureVisible("Edit metadata").click();-- cy.findByTestId("dataset-edit-bar").findByText("Settings").click();-- cy.findByTestId("sidebar-right").within(() => {- cy.findByText("List").click();- });-- cy.findByTestId("dataset-edit-bar").button("Save changes").click();- cy.wait("@dataset");-- cy.findByTestId("list-view").should("be.visible");-- H.openQuestionActions();-- H.popover()- .findByTextEnsureVisible("Turn back to saved question")- .click();- cy.wait("@dataset");- H.undoToast().should("contain.text", "This is a question now");- cy.findByTestId("list-view").should("not.exist");- });-it("should consider mini bar chart setting for quantity/score columns", () => {H.restore();cy.signInAsAdmin();@@ -407,7 +338,13 @@ describe("scenarios > models list view", () => {cy.findByTestId("dataset-edit-bar").button("Save changes").click();cy.wait("@dataset");- cy.findByTestId("mini-bar-container").should("not.exist");+ cy.findByTestId("dataset-edit-bar").should("not.exist");+ cy.findByTestId("list-view")+ .should("be.visible")+ .within(() => {+ cy.findAllByText("37.65").should("be.visible");+ cy.findByTestId("mini-bar-container").should("not.exist");+ });});});});diff --git a/e2e/test/scenarios/models/models-metadata.cy.spec.js b/e2e/test/scenarios/models/models-metadata.cy.spec.jsindex e18d266d794..9977667ff83 100644--- a/e2e/test/scenarios/models/models-metadata.cy.spec.js+++ b/e2e/test/scenarios/models/models-metadata.cy.spec.js@@ -28,7 +28,25 @@ describe("scenarios > models metadata", () => {H.createQuestion(modelDetails, { visitQuestion: true, wrapId: true });});- it("should edit GUI model metadata", () => {+ it("should edit GUI model metadata, cancel changes, and clear it when turned back into a question", () => {+ cy.log("cancel metadata changes");+ H.openQuestionActions("Edit metadata");+ H.waitForLoaderToBeRemoved();++ H.openColumnOptions("Subtotal");+ H.renameColumn("Subtotal", "Pre-tax");+ H.setColumnType("No semantic type", "Currency");++ H.datasetEditBar().button("Cancel").click();+ H.modal().button("Discard changes").click();+ H.datasetEditBar().should("not.exist");++ cy.findAllByTestId("header-cell")+ .filter(":contains(Subtotal)")+ .should("not.contain", "$");+ cy.findAllByTestId("header-cell").should("not.contain", "Pre-tax");++ cy.log("edit metadata");H.openQuestionActions();H.popover().findByTextEnsureVisible("89%").realHover();@@ -51,6 +69,10 @@ describe("scenarios > models metadata", () => {H.setColumnType("No semantic type", "Currency");H.saveMetadataChanges();+ cy.findAllByTestId("header-cell")+ .should("contain", "Pre-tax ($)")+ .and("not.contain", "Subtotal");+cy.log("Ensure that a question created from this model inherits its metadata.",);@@ -60,41 +82,12 @@ describe("scenarios > models metadata", () => {cy.findAllByTestId("header-cell").should("contain", "Pre-tax ($)").and("not.contain", "Subtotal");- });-- it("allows for canceling changes", () => {- H.openQuestionActions("Edit metadata");- H.waitForLoaderToBeRemoved();-- const RENAMED_COLUMN = "Pre-tax";- H.openColumnOptions("Subtotal");- H.renameColumn("Subtotal", RENAMED_COLUMN);- H.setColumnType("No semantic type", "Currency");-- H.datasetEditBar().button("Cancel").click();- H.modal().button("Discard changes").click();- H.datasetEditBar().should("not.exist");-- cy.findAllByTestId("header-cell")- .filter(":contains(Subtotal)")- .should("not.contain", "$");- cy.findAllByTestId("header-cell").should("not.contain", RENAMED_COLUMN);- });-- it("clears custom metadata when a model is turned back into a question", () => {- H.openQuestionActions();- H.popover().findByTextEnsureVisible("Edit metadata").click();- H.waitForLoaderToBeRemoved();-- H.openColumnOptions("Subtotal");- H.renameColumn("Subtotal", "Pre-tax");- H.setColumnType("No semantic type", "Currency");- H.saveMetadataChanges();-- cy.findAllByTestId("header-cell")- .should("contain", "Pre-tax ($)")- .and("not.contain", "Subtotal");+ cy.log(+ "clear custom metadata when the model is turned back into a question",+ );+ cy.get("@questionId").then((id) => H.visitModel(id));+ cy.findAllByTestId("header-cell").should("contain", "Pre-tax ($)");H.openQuestionActions();H.popover()@@ -108,7 +101,9 @@ describe("scenarios > models metadata", () => {});});- it("should edit native model metadata", () => {+ it("should keep native model metadata in sync with the query, edit it, and revert to a specific metadata revision", () => {+ cy.intercept("POST", "/api/revision/revert").as("revert");+H.createNativeQuestion({name: "Native Model",@@ -120,6 +115,27 @@ describe("scenarios > models metadata", () => {{ visitQuestion: true },);+ cy.log("keep metadata in sync with the query");+ H.openQuestionActions();+ H.popover().findByTextEnsureVisible("Edit query definition").click();++ H.NativeEditor.clear();+ H.NativeEditor.type("SELECT TOTAL FROM ORDERS LIMIT 5");++ cy.findByTestId("editor-tabs-columns-name").click();+ cy.wait("@dataset");++ cy.findAllByTestId("header-cell")+ .should("have.length", 1)+ .and("have.text", "TOTAL");+ cy.findByLabelText("Display name").should("have.value", "TOTAL");++ H.datasetEditBar().button("Cancel").click();+ H.modal().button("Discard changes").click();+ H.datasetEditBar().should("not.exist");+ cy.findAllByTestId("header-cell").should("contain", "SUBTOTAL");++ cy.log("Revision 1: edit metadata");H.openQuestionActions();H.popover().findByTextEnsureVisible("37%").realHover();@@ -144,88 +160,28 @@ describe("scenarios > models metadata", () => {H.setColumnType("No semantic type", "Currency");H.saveMetadataChanges();- cy.findAllByTestId("header-cell")- .should("contain", "Pre-tax ($)")- .and("not.contain", "Subtotal");-- cy.log(- "Ensure that a question created from this model inherits its metadata.",- );- startQuestionFromModel("Native Model");- H.visualize();-- cy.findAllByTestId("header-cell")- .should("contain", "Pre-tax ($)")- .and("not.contain", "Subtotal");- });-- it("should keep metadata in sync with the query", () => {- H.createNativeQuestion(- {- name: "Native Model",- type: "model",- native: {- query: "SELECT * FROM ORDERS LIMIT 5",- },- },- { visitQuestion: true },- );-- H.openQuestionActions();- H.popover().findByTextEnsureVisible("Edit query definition").click();-- H.NativeEditor.clear();- H.NativeEditor.type("SELECT TOTAL FROM ORDERS LIMIT 5");-- cy.findByTestId("editor-tabs-columns-name").click();- cy.wait("@dataset");-- cy.findAllByTestId("header-cell")- .should("have.length", 1)- .and("have.text", "TOTAL");- cy.findByLabelText("Display name").should("have.value", "TOTAL");- });-- it("should allow reverting to a specific metadata revision", () => {- cy.intercept("POST", "/api/revision/revert").as("revert");-- H.createNativeQuestion({- name: "Native Model",- type: "model",- native: {- query: "SELECT * FROM ORDERS LIMIT 5",- },- }).then(({ body: { id: nativeModelId } }) => {- cy.visit(`/model/${nativeModelId}/columns`);- cy.wait("@cardQuery");- });-- H.openColumnOptions("SUBTOTAL");- H.mapColumnTo({ table: "Orders", column: "Subtotal" });- H.setColumnType("No semantic type", "Currency");- H.saveMetadataChanges();-- cy.log("Revision 1");H.tableInteractive().within(() => {- cy.findByText("Subtotal ($)").should("be.visible");+ cy.findByText("Pre-tax ($)").should("be.visible");cy.findByText("SUBTOTAL").should("not.exist");});+ cy.findAllByTestId("header-cell").should("not.contain", "Subtotal");+ cy.log("Revision 2");H.openQuestionActions();H.popover().findByTextEnsureVisible("Edit metadata").click();H.waitForLoaderToBeRemoved();- cy.log("Revision 2");H.openColumnOptions("TAX");H.mapColumnTo({ table: "Orders", column: "Tax" });H.setColumnType("No semantic type", "Currency");H.saveMetadataChanges();cy.findAllByTestId("header-cell")- .should("contain", "Subtotal ($)")+ .should("contain", "Pre-tax ($)").and("contain", "Tax ($)").and("not.contain", "TAX");+ cy.log("revert to revision 1");cy.reload();H.questionInfoButton().click();@@ -236,9 +192,21 @@ describe("scenarios > models metadata", () => {cy.wait("@revert");cy.findAllByTestId("header-cell")- .should("contain", "Subtotal ($)")+ .should("contain", "Pre-tax ($)").and("not.contain", "Tax ($)").and("contain", "TAX");+ H.sidesheet().findByLabelText("Close").click();+ H.sidesheet().should("not.exist");++ cy.log(+ "Ensure that a question created from this model inherits its metadata.",+ );+ startQuestionFromModel("Native Model");+ H.visualize();++ cy.findAllByTestId("header-cell")+ .should("contain", "Pre-tax ($)")+ .and("not.contain", "Subtotal");});it("should allow reordering columns by the edge of column header (metabase#41419)", () => {@@ -270,20 +238,72 @@ describe("scenarios > models metadata", () => {cy.url().should("include", "/columns");H.waitForLoaderToBeRemoved();- cy.log("move Product -> Price before Products -> Vendor");+ H.tableInteractiveScrollContainer().scrollTo("right");+ H.tableInteractiveScrollContainer().should(($container) => {+ expect($container[0].scrollLeft).to.be.greaterThan(0);+ });+ cy.findAllByTestId("header-cell").should(($cells) => {+ const names = $cells.toArray().map((cell) => cell.textContent);+ expect(names.indexOf("Products → Vendor")).to.be.greaterThan(-1);+ expect(names.indexOf("Products → Vendor")).to.be.lessThan(+ names.indexOf("Products → Price"),+ );+ });++ cy.log("move Products → Price before Products → Vendor");cy.findAllByTestId("header-cell").contains("Products → Price").closest("[data-testid='header-cell']").as("dragHeader");- H.moveDnDKitElementByAlias("@dragHeader", { horizontal: 600 });+ H.moveDnDKitElementByAlias("@dragHeader", { horizontal: -250 });+ cy.findAllByTestId("header-cell").should(($cells) => {+ const names = $cells.toArray().map((cell) => cell.textContent);+ expect(names.indexOf("Products → Price")).to.be.greaterThan(-1);+ expect(names.indexOf("Products → Price")).to.be.lessThan(+ names.indexOf("Products → Vendor"),+ );+ });++ cy.log("the table should keep its scroll position");+ H.tableInteractiveScrollContainer().should(($container) => {+ expect($container[0].scrollLeft).to.be.greaterThan(0);+ });cy.findAllByTestId("header-cell").contains("Products → Vendor").should("be.visible");});+ it("models columns tab should show columns with details-only visibility (metabase#22521)", () => {+ cy.request("PUT", `/api/field/${PRODUCTS.VENDOR}`, {+ visibility_type: "details-only",+ });++ const questionDetails = {+ name: "22521",+ type: "model",+ query: {+ "source-table": PRODUCTS_ID,+ limit: 5,+ },+ };++ H.createQuestion(questionDetails, { visitQuestion: true });+ cy.findAllByTestId("header-cell")+ .should("contain", "Title")+ .and("not.contain", "Vendor");++ H.openQuestionActions();+ H.popover().findByTextEnsureVisible("Edit metadata").click();+ H.waitForLoaderToBeRemoved();++ cy.findAllByTestId("header-cell")+ .contains(/^Vendor$/)+ .should("be.visible");+ });+describe("native models metadata overwrites", { viewportWidth: 1400 }, () => {beforeEach(() => {H.createNativeQuestion(@@ -321,39 +341,6 @@ describe("scenarios > models metadata", () => {});});- // TODO (AlexP 10/09/25) -- fix and unskip this test- it.skip("should allow drills on FK columns", () => {- cy.get("@modelId").then((modelId) => {- cy.visit(`/model/${modelId}`);- cy.wait("@dataset");-- // Drill to People table- // FK column is mapped to real DB column- drillFK({ id: 1 });- cy.wait("@dataset");- cy.findByTestId("object-detail").within(() => {- cy.findByText("68883"); // zip- cy.findAllByText("Hudson Borer");- });-- cy.go("back"); // close Object Details view-- cy.go("back"); // navigate away from drilled table- cy.wait("@dataset");-- cy.findByText("Native Model"); // we are back on the original model-- // Drill to Reviews table- // FK column has a FK semantic type, no mapping to real DB columns- drillFK({ id: 7 });- cy.wait("@dataset");- cy.findByTestId("object-detail").within(() => {- cy.findAllByText("7");- cy.findAllByText("perry.ruecker");- });- });- });-it("should allow drills on FK columns from dashboards (metabase#42130)", () => {cy.get("@modelId").then((modelId) => {H.createDashboard().then((response) => {@@ -390,40 +377,9 @@ describe("scenarios > models metadata", () => {});});});-- it("models metadata tab should show columns with details-only visibility (metabase#22521)", () => {- cy.request("PUT", `/api/field/${PRODUCTS.VENDOR}`, {- visibility_type: "details-only",- });-- const questionDetails = {- name: "22521",- type: "model",- query: {- "source-table": PRODUCTS_ID,- limit: 5,- },- };-- H.createQuestion(questionDetails, { visitQuestion: true });- cy.findAllByTestId("header-cell").should("not.contain", "Vendor");-- H.openQuestionActions();- H.popover().findByTextEnsureVisible("Edit metadata").click();- H.waitForLoaderToBeRemoved();-- cy.findAllByTestId("header-cell")- .contains(/^Vendor$/)- .should("be.visible");- });});});-function drillFK({ id }) {- cy.get(".test-Table-FK").contains(id).first().click();- H.popover().findByTextEnsureVisible("View details").click();-}-function drillDashboardFK({ id }) {cy.get(".test-Table-FK").contains(id).first().click();}diff --git a/e2e/test/scenarios/models/models-query-editor.cy.spec.js b/e2e/test/scenarios/models/models-query-editor.cy.spec.jsindex 7c4ddfbd633..464cadbee01 100644--- a/e2e/test/scenarios/models/models-query-editor.cy.spec.js+++ b/e2e/test/scenarios/models/models-query-editor.cy.spec.js@@ -21,7 +21,7 @@ describe("scenarios > models query editor", () => {});});- it("allows to edit GUI model query", () => {+ it("allows to edit GUI model query, cancel changes, and locks display to table", () => {cy.visit(`/model/${ORDERS_QUESTION_ID}`);cy.wait("@dataset");@@ -29,15 +29,29 @@ describe("scenarios > models query editor", () => {.should("contain", "37.65").and("contain", "109.22");+ cy.log(+ "rerunning the model should not add a query hash (metabase#20045)",+ );+ cy.location("pathname").should(+ "eq",+ `/model/${ORDERS_QUESTION_ID}-orders-model`,+ );+ cy.location("hash").should("eq", "");+ cy.findByTestId("qb-header-action-panel").find(".Icon-refresh").click();+ cy.wait("@dataset");+ cy.location("pathname").should(+ "eq",+ `/model/${ORDERS_QUESTION_ID}-orders-model`,+ );+ cy.location("hash").should("eq", "");++ cy.log("cancel query changes");H.openQuestionActions();H.popover().within(() => {cy.findByText("Edit query definition").click();});- cy.findByTestId("data-step-cell").contains("Orders");- cy.button("Save changes").should("be.disabled");-// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText("Row limit").click();cy.findByPlaceholderText("Enter a limit").type("2").blur();@@ -49,8 +63,9 @@ describe("scenarios > models query editor", () => {.should("contain", "37.65").and("not.contain", "109.22");- cy.button("Save changes").click();- cy.wait("@updateCard");+ cy.button("Cancel").click();+ H.modal().button("Discard changes").click();+ cy.wait("@cardQuery");cy.url().should("include", `/model/${ORDERS_QUESTION_ID}`)@@ -59,23 +74,37 @@ describe("scenarios > models query editor", () => {cy.get("[data-testid=cell-data]").should("contain", "37.65")- .and("not.contain", "109.22");- });+ .and("contain", "109.22");- it("allows for canceling changes", () => {- cy.visit(`/model/${ORDERS_QUESTION_ID}`);+ cy.log("lock display to table");+ cy.visit(`/model/${ORDERS_QUESTION_ID}/query`);++ H.summarize({ mode: "notebook" });++ selectFromDropdown("Count of rows");++ cy.findByTestId("run-button").click();cy.wait("@dataset");- cy.get("[data-testid=cell-data]")- .should("contain", "37.65")- .and("contain", "109.22");+ // FE chooses the scalar visualization to display count of rows for regular questions+ H.tableInteractiveHeader().should("contain", "Count");+ H.tableInteractive().should("contain", "18,760");+ cy.findByTestId("scalar-value").should("not.exist");+ cy.button("Cancel").click();+ H.modal().button("Discard changes").click();+ H.datasetEditBar().should("not.exist");++ cy.log("edit the query");H.openQuestionActions();H.popover().within(() => {cy.findByText("Edit query definition").click();});+ cy.findByTestId("data-step-cell").contains("Orders");+ cy.button("Save changes").should("be.disabled");+// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText("Row limit").click();cy.findByPlaceholderText("Enter a limit").type("2").blur();@@ -87,9 +116,8 @@ describe("scenarios > models query editor", () => {.should("contain", "37.65").and("not.contain", "109.22");- cy.button("Cancel").click();- H.modal().button("Discard changes").click();- cy.wait("@cardQuery");+ cy.button("Save changes").click();+ cy.wait("@updateCard");cy.url().should("include", `/model/${ORDERS_QUESTION_ID}`)@@ -98,27 +126,12 @@ describe("scenarios > models query editor", () => {cy.get("[data-testid=cell-data]").should("contain", "37.65")- .and("contain", "109.22");- });-- it("locks display to table", () => {- cy.visit(`/model/${ORDERS_QUESTION_ID}/query`);-- H.summarize({ mode: "notebook" });-- selectFromDropdown("Count of rows");-- cy.findByTestId("run-button").click();- cy.wait("@dataset");-- // FE chooses the scalar visualization to display count of rows for regular questions- H.tableInteractive();- cy.findByTestId("scalar-value").should("not.exist");+ .and("not.contain", "109.22");});});describe("native models", () => {- it("allows to edit native model query", () => {+ it("allows to edit native model query and cancel changes", () => {H.createNativeQuestion({name: "Native Model",@@ -134,6 +147,7 @@ describe("scenarios > models query editor", () => {.should("contain", "37.65").and("contain", "109.22");+ cy.log("cancel query changes");H.openQuestionActions();H.popover().within(() => {@@ -151,30 +165,15 @@ describe("scenarios > models query editor", () => {.should("contain", "37.65").and("not.contain", "109.22");- cy.button("Save changes").click();- cy.wait("@updateCard");-- cy.get("[data-testid=cell-data]")- .should("contain", "37.65")- .and("not.contain", "109.22");- });-- it("allows for canceling changes", () => {- H.createNativeQuestion(- {- name: "Native Model",- type: "model",- native: {- query: "SELECT * FROM orders limit 5",- },- },- { visitQuestion: true },- );+ cy.button("Cancel").click();+ H.modal().button("Discard changes").click();+ cy.wait("@cardQuery");cy.get("[data-testid=cell-data]").should("contain", "37.65").and("contain", "109.22");+ cy.log("edit the query");H.openQuestionActions();H.popover().within(() => {@@ -192,13 +191,14 @@ describe("scenarios > models query editor", () => {.should("contain", "37.65").and("not.contain", "109.22");- cy.button("Cancel").click();- H.modal().button("Discard changes").click();- cy.wait("@cardQuery");+ cy.button("Save changes").click();+ cy.wait("@updateCard");+ cy.url().should("not.include", "/query");+ H.assertQueryBuilderRowCount(2);cy.get("[data-testid=cell-data]").should("contain", "37.65")- .and("contain", "109.22");+ .and("not.contain", "109.22");});it("handles failing queries", () => {diff --git a/e2e/test/scenarios/models/models.cy.spec.js b/e2e/test/scenarios/models/models.cy.spec.jsindex d15d2bf3755..abedc88bf02 100644--- a/e2e/test/scenarios/models/models.cy.spec.js+++ b/e2e/test/scenarios/models/models.cy.spec.js@@ -1,5 +1,4 @@const { H } = cy;-import { SAMPLE_DB_ID } from "e2e/support/cypress_data";import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";import {ORDERS_BY_YEAR_QUESTION_ID,@@ -23,10 +22,12 @@ describe("scenarios > models", () => {H.restore();cy.signInAsAdmin();cy.intercept("POST", "/api/dataset").as("dataset");+ });+ it("allows to turn a GUI question into a model", () => {H.createQuestion({- name: "Products",+ name: "Products Model",query: { "source-table": PRODUCTS_ID },},{@@ -34,9 +35,6 @@ describe("scenarios > models", () => {idAlias: "productsQuestionId",},);- });-- it("allows to turn a GUI question into a model", () => {H.createQuestion({name: "Accounts Model",@@ -50,9 +48,6 @@ describe("scenarios > models", () => {);cy.get("@productsQuestionId").then((id) => {- cy.request("PUT", `/api/card/${id}`, {- name: "Products Model",- });H.visitQuestion(id);turnIntoModel();@@ -74,7 +69,7 @@ describe("scenarios > models", () => {table: "Products",});- saveQuestionBasedOnModel({ modelId: id, name: "Q1" });+ saveQuestionBasedOnModel({ name: "Q1" });assertQuestionIsBasedOnModel({questionName: "Q1",@@ -82,6 +77,7 @@ describe("scenarios > models", () => {collection: "Our analytics",table: "Products",});+ cy.location("pathname").should("match", /^\/question\/\d+-q1$/);cy.findByTestId("qb-header").findAllByText("Our analytics")@@ -89,8 +85,6 @@ describe("scenarios > models", () => {.click();getCollectionItemRow("Products Model").icon("model");getCollectionItemRow("Q1").icon("table2");-- cy.url().should("not.include", "/question/" + id);});cy.log(@@ -133,7 +127,7 @@ describe("scenarios > models", () => {query: "SELECT * FROM products",},},- { visitQuestion: true, wrapId: true },+ { visitQuestion: true },);turnIntoModel();@@ -155,9 +149,7 @@ describe("scenarios > models", () => {table: "Products",});- cy.get("@questionId").then((questionId) => {- saveQuestionBasedOnModel({ modelId: questionId, name: "Q1" });- });+ saveQuestionBasedOnModel({ name: "Q1" });assertQuestionIsBasedOnModel({questionName: "Q1",@@ -173,7 +165,7 @@ describe("scenarios > models", () => {cy.location("pathname").should("eq", "/collection/root");});- it("changes model's display to table", () => {+ it("allows to undo turning a question into a model, and shows the model info modal only once", () => {H.visitQuestion(ORDERS_BY_YEAR_QUESTION_ID);H.echartsContainer();@@ -181,46 +173,47 @@ describe("scenarios > models", () => {turnIntoModel();+ cy.log("changes model's display to table");H.tableInteractive();H.echartsContainer().should("not.exist");- });-- it("only shows model info modal once when turning a question into a model", () => {- H.visitQuestion(ORDERS_BY_YEAR_QUESTION_ID);- H.echartsContainer();- turnIntoModel();H.undoToast().findByText("This is a model now.").should("exist");H.undo();+ cy.wait("@cardUpdate");+ H.echartsContainer();H.openQuestionActions();+ assertIsQuestion();++ cy.log("only shows model info modal once");H.popover().within(() => {cy.icon("model").click();});+ cy.wait("@cardUpdate");+ H.undoToast().findByText("This is a model now.").should("be.visible");+ H.tableInteractive().should("be.visible");H.modal().should("not.exist");});- it("allows to undo turning a question into a model", () => {- H.visitQuestion(ORDERS_BY_YEAR_QUESTION_ID);- H.echartsContainer();+ it("allows to open, turn back, and duplicate a model", () => {+ cy.intercept("PUT", `/api/card/${ORDERS_QUESTION_ID}`).as("cardUpdate");+ cy.intercept("POST", "/api/card").as("cardCreate");- turnIntoModel();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("This is a model now.");+ cy.log("shows 404 when opening a question with a /model URL");+ cy.visit(`/model/${ORDERS_QUESTION_ID}`);// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Undo").click();-- H.echartsContainer();- H.openQuestionActions();- assertIsQuestion();- });+ cy.findByText(/We're a little lost/i);- it("allows to turn a model back into a saved question", () => {+ cy.log("redirects to /model URL when opening a model with /question URL");cy.request("PUT", `/api/card/${ORDERS_QUESTION_ID}`, { type: "model" });- cy.intercept("PUT", `/api/card/${ORDERS_QUESTION_ID}`).as("cardUpdate");- cy.visit(`/model/${ORDERS_QUESTION_ID}`);-+ // Important - do not use visitQuestion(ORDERS_QUESTION_ID) here!+ cy.visit("/question/" + ORDERS_QUESTION_ID);+ cy.wait("@dataset");H.openQuestionActions();+ assertIsModel();+ cy.url().should("include", "/model");++ cy.log("turns a model back into a saved question");H.popover().within(() => {cy.findByText("Turn back to saved question").click();});@@ -237,14 +230,8 @@ describe("scenarios > models", () => {cy.wait("@cardUpdate");H.openQuestionActions();assertIsModel();- });- it("allows duplicating a model", () => {- cy.request("PUT", `/api/card/${ORDERS_QUESTION_ID}`, { type: "model" });- cy.intercept("POST", "/api/card").as("cardCreate");- cy.visit(`/model/${ORDERS_QUESTION_ID}`);-- H.openQuestionActions();+ cy.log("duplicates a model");H.popover().within(() => {cy.findByText("Duplicate").click();});@@ -256,8 +243,9 @@ describe("scenarios > models", () => {H.entityPickerModal().within(() => {cy.findByText(/Select a collection$/).should("exist"); // title should not have trailing "or dashboard"+ cy.findByText("First collection").should("exist");cy.findByText("Orders in a dashboard").should("not.exist"); // this dashboard would be present if dashboards were an allowed save target- cy.findByText("First collection").should("exist").click();+ cy.findByText("First collection").click();cy.findByRole("button", { name: "Select this collection" }).click();});@@ -267,22 +255,9 @@ describe("scenarios > models", () => {});H.modal().should("not.exist");- });-- it("shows 404 when opening a question with a /dataset URL", () => {- cy.visit(`/model/${ORDERS_QUESTION_ID}`);- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText(/We're a little lost/i);- });-- it("redirects to /model URL when opening a model with /question URL", () => {- cy.request("PUT", `/api/card/${ORDERS_QUESTION_ID}`, { type: "model" });- // Important - do not use visitQuestion(ORDERS_QUESTION_ID) here!- cy.visit("/question/" + ORDERS_QUESTION_ID);- cy.wait("@dataset");- H.openQuestionActions();- assertIsModel();- cy.url().should("include", "/model");+ cy.findByTestId("qb-header")+ .should("contain.text", "Orders - Duplicate")+ .and("contain.text", "First collection");});describe("data picker", () => {@@ -292,6 +267,10 @@ describe("scenarios > models", () => {});it("transforms the data picker", () => {+ H.createQuestion({+ name: "Products",+ query: { "source-table": PRODUCTS_ID },+ });H.startNewQuestion();H.miniPickerBrowseAll().click();@@ -350,8 +329,6 @@ describe("scenarios > models", () => {});it("allows to create a question based on a model", () => {- cy.intercept(`/api/database/${SAMPLE_DB_ID}/schema/PUBLIC`).as("schema");-H.startNewQuestion();H.miniPickerBrowseAll().click();H.entityPickerModal().within(() => {@@ -421,6 +398,18 @@ describe("scenarios > models", () => {cy.findByText("People").should("exist");cy.findByText("Products").should("exist");cy.findByText("Reviews").should("exist");++ cy.findByPlaceholderText("Search…").type("Ord");+ cy.wait("@search");+ cy.findByText("Everywhere").click();+ cy.wait("@search");+ cy.get("[data-testid=result-item][data-model-type=table]").should(+ "contain.text",+ "Orders",+ );+ cy.get("[data-testid=result-item][data-model-type=dataset]").should(+ "not.exist",+ );});});});@@ -433,7 +422,8 @@ describe("scenarios > models", () => {});});- it("can create a question by filtering and summarizing a model", () => {+ it("can create questions from a model and edit its info", () => {+ cy.log("create a question by filtering and summarizing a model");cy.visit(`/model/${ORDERS_QUESTION_ID}`);cy.wait("@dataset");@@ -462,7 +452,7 @@ describe("scenarios > models", () => {table: "Orders",});- saveQuestionBasedOnModel({ modelId: ORDERS_QUESTION_ID, name: "Q1" });+ saveQuestionBasedOnModel({ name: "Q1" });assertQuestionIsBasedOnModel({questionName: "Q1",@@ -471,10 +461,9 @@ describe("scenarios > models", () => {table: "Orders",});- cy.url().should("not.include", "/question/" + ORDERS_QUESTION_ID);- });+ cy.location("pathname").should("match", /^\/question\/\d+-q1$/);- it("can create a question using table click actions", () => {+ cy.log("create a question using table click actions");cy.visit(`/model/${ORDERS_QUESTION_ID}`);cy.wait("@dataset");@@ -488,19 +477,18 @@ describe("scenarios > models", () => {table: "Orders",});- saveQuestionBasedOnModel({ modelId: ORDERS_QUESTION_ID, name: "Q1" });+ saveQuestionBasedOnModel({ name: "Q2" });assertQuestionIsBasedOnModel({- questionName: "Q1",+ questionName: "Q2",model: "Orders Model",collection: "Our analytics",table: "Orders",});- cy.url().should("not.include", "/question/" + ORDERS_QUESTION_ID);- });+ cy.location("pathname").should("match", /^\/question\/\d+-q2$/);- it("can edit model info", () => {+ cy.log("edit model info");cy.intercept("PUT", `/api/card/${ORDERS_QUESTION_ID}`).as("updateCard");cy.visit(`/model/${ORDERS_QUESTION_ID}`);cy.wait("@dataset");@@ -580,28 +568,16 @@ describe("scenarios > models", () => {H.NativeEditor.focus().type("{movetoend}").type(" WHERE {{F", {parseSpecialCharSequences: false,});+ // Blurring flushes the debounced query update that would open the sidebar+ H.NativeEditor.blur();+ H.NativeEditor.get().should("contain", "WHERE {{F");+ cy.findByTestId("dataset-edit-bar").should("be.visible");cy.findByTestId("tag-editor-sidebar").should("not.exist");});});});- it("should correctly show native models for no-data users", () => {- cy.intercept("POST", "/api/card/*/query").as("cardQuery");- H.createNativeQuestion({- name: "TEST MODEL",- type: "model",- native: {- query: "select * from orders",- },- }).then(({ body: { id: modelId } }) => {- cy.signIn("nodata");- cy.visit(`/model/${modelId}`);- cy.wait("@cardQuery");- cy.findByText(/This question is written in SQL/i).should("not.exist");- });- });-- describe("listing", () => {+ describe("dashboards", () => {const modelDetails = {name: "Orders Model 2",query: {diff --git a/e2e/test/scenarios/models/reproductions-1.cy.spec.ts b/e2e/test/scenarios/models/reproductions-1.cy.spec.tsindex 6d0c5aa094e..0c67394e118 100644--- a/e2e/test/scenarios/models/reproductions-1.cy.spec.ts+++ b/e2e/test/scenarios/models/reproductions-1.cy.spec.ts@@ -38,13 +38,16 @@ describe("issue 29943", () => {return H.tableHeaderColumn(name);}+ const ID_DESCRIPTION =+ "This is a unique ID for the product. It is also called the “Invoice number” or “Confirmation number” in customer facing emails and screens.";+beforeEach(() => {H.restore();cy.signInAsAdmin();cy.intercept("POST", "/api/dataset").as("dataset");});- it("selects the right column when clicking a column header (metabase#29943)", () => {+ it("selects the right column when clicking a column header and saves the column order (metabase#29943, metabase#39993, metabase#25884, metabase#34349)", () => {H.createQuestion({type: "model",@@ -52,11 +55,13 @@ describe("issue 29943", () => {"source-table": ORDERS_ID,expressions: {Custom: ["+", 1, 1],+ Country: ["substring", "United States", 1, 20],},fields: [["field", ORDERS.ID, { "base-type": "type/BigInteger" }],["field", ORDERS.TOTAL, { "base-type": "type/Float" }],["expression", "Custom", { "base-type": "type/Integer" }],+ ["expression", "Country", { "base-type": "type/Text" }],],limit: 5, // optimization},@@ -68,6 +73,15 @@ describe("issue 29943", () => {H.popover().findByText("Edit metadata").click();H.waitForLoaderToBeRemoved();+ cy.log(+ "columns without a description show an empty description (metabase#25884, metabase#34349)",+ );+ cy.findByLabelText("Description").should("have.text", ID_DESCRIPTION);+ H.tableHeaderClick("Country");+ cy.findByLabelText("Description").should("have.text", "");+ H.tableHeaderClick("ID");+ cy.findByLabelText("Description").should("have.text", ID_DESCRIPTION);+reorderTotalAndCustomColumns();cy.button("Save changes").click();cy.wait("@dataset");@@ -92,7 +106,7 @@ describe("issue 29943", () => {});});-describe("issues with metadata editing on models with custom expressions", () => {+describe("issue 35711", () => {const { ORDERS_ID, ORDERS } = SAMPLE_DATABASE;const DISCOUNT_FIELD_REF: FieldReference = [@@ -128,7 +142,7 @@ describe("issues with metadata editing on models with custom expressions", () =>cy.signInAsAdmin();});- it("can edit metadata of a model with a custom column (metabase#35711, metabase#39993)", () => {+ it("can edit metadata of a model with a custom column (metabase#35711)", () => {H.createQuestion({type: "model",@@ -151,52 +165,12 @@ describe("issues with metadata editing on models with custom expressions", () =>assertNoError();cy.findByTestId("editor-tabs-query-name").click();+ H.getNotebookStep("data").should("be.visible");+ cy.findByTestId("run-button").should("have.attr", "aria-label", "Refresh");assertNoError();});});-describe("issues 25884 and 34349", () => {- const ID_DESCRIPTION =- "This is a unique ID for the product. It is also called the “Invoice number” or “Confirmation number” in customer facing emails and screens.";-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should show empty description input for columns without description in metadata (metabase#25884, metabase#34349)", () => {- H.createQuestion(- {- type: "model",- query: {- "source-table": ORDERS_ID,- expressions: {- Country: ["substring", "United States", 1, 20],- },- fields: [- ["field", ORDERS.ID, { "base-type": "type/BigInteger" }],- ["expression", "Country", { "base-type": "type/Text" }],- ],- limit: 5, // optimization- },- },- { visitQuestion: true },- );-- H.openQuestionActions();- H.popover().findByText("Edit metadata").click();- H.waitForLoaderToBeRemoved();-- cy.findByLabelText("Description").should("have.text", ID_DESCRIPTION);-- H.tableHeaderClick("Country");- cy.findByLabelText("Description").should("have.text", "");-- H.tableHeaderClick("ID");- cy.findByLabelText("Description").should("have.text", ID_DESCRIPTION);- });-});-describe("issue 41785, issue 46756", () => {beforeEach(() => {H.restore();@@ -595,7 +569,7 @@ describe("issue 33844", () => {H.tableInteractive().findByText("ID").should("be.visible");}- it("should show hidden PKs in model metadata editor and object details after creating a model (metabase#33844)", () => {+ it("should show hidden PKs in model metadata editor and object details after creating and updating a model (metabase#33844, metabase#45924)", () => {cy.visit("/model/new");cy.findByTestId("new-model-options").findByText("Use the notebook editor")@@ -608,30 +582,33 @@ describe("issue 33844", () => {cy.wait("@dataset");cy.findByTestId("dataset-edit-bar").findByText("Columns").click();testModelMetadata(true);- });- it("should show hidden PKs in model metadata editor and object details after updating a model (metabase#33844,metabase#45924)", () => {+ cy.log("update a model");+ // Fresh aliases so waits don't consume requests from model creation+ cy.intercept("POST", "/api/dataset").as("dataset");+ cy.intercept("PUT", "/api/card/*").as("updateModel");H.visitModel(ORDERS_QUESTION_ID);cy.wait("@dataset");H.openQuestionActions();H.popover().findByText("Edit metadata").click();H.waitForLoaderToBeRemoved();testModelMetadata(false);- });-});-describe("issue 45924", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- cy.request("PUT", `/api/card/${ORDERS_QUESTION_ID}`, { type: "model" });- cy.intercept("POST", "/api/dataset").as("dataset");- cy.intercept("PUT", "/api/card/*").as("updateCard");- });-- it("should preserve model metadata when re-running the query (metabase#45924)", () => {- H.visitModel(ORDERS_QUESTION_ID);- cy.wait("@dataset");+ cy.log(+ "preserve model metadata when re-running the query (metabase#45924)",+ );+ cy.intercept("POST", "/api/dataset").as("modelDataset");+ cy.intercept("PUT", "/api/card/*").as("updateCleanModel");+ H.createQuestion(+ {+ name: "Orders Model 45924",+ type: "model",+ query: { "source-table": ORDERS_ID },+ },+ { wrapId: true, idAlias: "cleanModelId" },+ );+ cy.get<CardId>("@cleanModelId").then((modelId) => H.visitModel(modelId));+ cy.wait("@modelDataset");H.openQuestionActions();H.popover().findByText("Edit metadata").click();H.waitForLoaderToBeRemoved();@@ -641,13 +618,13 @@ describe("issue 45924", () => {cy.findByTestId("action-buttons").button("Sort").click();H.popover().findByText("ID").click();cy.findByTestId("run-button").click();- cy.wait("@dataset");+ cy.wait("@modelDataset");cy.findByTestId("dataset-edit-bar").findByText("Columns").click();H.tableHeaderClick("ID1");cy.findByLabelText("Display name").should("have.value", "ID1");cy.findByTestId("dataset-edit-bar").button("Save changes").click();- cy.wait("@updateCard");- cy.wait("@dataset");+ cy.wait("@updateCleanModel");+ cy.wait("@modelDataset");H.tableInteractive().findByText("ID1").should("be.visible");});});@@ -679,7 +656,6 @@ describe("issue 34574", () => {cy.intercept("GET", "/api/card/*/query_metadata").as("metadata");cy.intercept("GET", "/api/card/*").as("card");cy.intercept("PUT", "/api/card/*").as("updateCard");- cy.intercept("GET", "/api/table/*/fks").as("fks");cy.intercept("GET", "/api/collection/root/items?**").as("rootCollection");cy.intercept("POST", "api/dataset").as("dataset");});@@ -827,7 +803,6 @@ describe("issue 34514", () => {H.restore();cy.signInAsAdmin();cy.intercept("POST", "/api/dataset").as("dataset");- cy.intercept("GET", "/api/database/*").as("fetchDatabase");// It's important to navigate via UI so that there are// enough entries in the browser history to go back to.@@ -837,20 +812,6 @@ describe("issue 34514", () => {.click();});- it("should not make network request with invalid query (metabase#34514)", () => {- H.miniPicker().within(() => {- cy.findByText("Sample Database").click();- cy.findByText("Orders").click();- });-- cy.findByTestId("run-button").click();- cy.wait("@dataset");- assertQueryTabState();-- cy.go("back");- assertBackToEmptyState();- });-it("should allow browser history navigation between tabs (metabase#34514, metabase#45787)", () => {H.miniPicker().within(() => {cy.findByText("Sample Database").click();diff --git a/e2e/test/scenarios/models/reproductions-2.cy.spec.ts b/e2e/test/scenarios/models/reproductions-2.cy.spec.tsindex 4a5ff1c95ab..9b0d60d2a96 100644--- a/e2e/test/scenarios/models/reproductions-2.cy.spec.ts+++ b/e2e/test/scenarios/models/reproductions-2.cy.spec.ts@@ -10,7 +10,7 @@ import type {StructuredQuestionDetails,} from "e2e/support/helpers";-const { ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;+const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;describe("issue 46221", () => {const modelDetails: NativeQuestionDetails = {name: "46221",@@ -118,7 +118,7 @@ describe("issue 37300", () => {);});- it("should show the table headers even when there are no results (metabase/metabase#37300)", () => {+ it("should show the table headers even when there are no results (metabase#37300)", () => {H.openQuestionActions();H.popover().findByText("Edit metadata").click();H.waitForLoaderToBeRemoved();@@ -143,7 +143,8 @@ describe("issue 32037", () => {cy.location("pathname").as("modelPathname");});- it("should show unsaved changes modal and allow to discard changes when editing model's query (metabase#32037)", () => {+ it("should show unsaved changes modal and allow to discard changes when editing model's query and metadata (metabase#32037)", () => {+ cy.log("query");H.openQuestionActions("Edit query definition");cy.button("Save changes").should("be.disabled");H.filter({ mode: "notebook" });@@ -156,9 +157,8 @@ describe("issue 32037", () => {cy.go("back");verifyDiscardingChanges();- });- it("should show unsaved changes modal and allow to discard changes when editing model's metadata (metabase#32037)", () => {+ cy.log("metadata");H.openQuestionActions("Edit metadata");H.waitForLoaderToBeRemoved();cy.button("Save changes").should("be.disabled");@@ -246,27 +246,12 @@ describe("issue 51925", () => {});});-describe("issue 53649", () => {+describe("issues 56698 and 57557", () => {beforeEach(() => {H.restore();- cy.signInAsAdmin();- });-- it("should not get caught in an infinite loop when opening the native editor (metabase#53649)", () => {- H.startNewNativeModel();-- // If the app freezes, this won't work- H.NativeEditor.type("select 1");- H.NativeEditor.get().should("contain", "select 1");});-});-describe("issue 56698", () => {- beforeEach(() => {- H.restore();- });-- it("should create an editable ad-hoc query based on a read-only native model (metabase#56698)", () => {+ it("should create an editable ad-hoc query based on a read-only native model, and hide the query definition without data permissions (metabase#56698, metabase#57557)", () => {cy.log("create a native model");cy.signInAsNormalUser();H.createNativeQuestion(@@ -278,38 +263,27 @@ describe("issue 56698", () => {{ wrapId: true, idAlias: "modelId" },);- cy.log("verify that we create an editable ad-hoc query");+ cy.log("verify that we create an editable ad-hoc query (metabase#56698)");cy.signIn("readonlynosql");cy.get("@modelId").then((modelId) => H.visitModel(Number(modelId)));H.assertQueryBuilderRowCount(2);H.summarize();H.rightSidebar().button("Done").click();H.assertQueryBuilderRowCount(1);- });-});--describe("issue 57557", () => {- beforeEach(() => {- H.restore();- });- it("should not allow to see the query definition for a user without data permissions (metabase#57557)", () => {- cy.log("create a native model");- cy.signInAsNormalUser();- H.createNativeQuestion(- {- name: "Native model",- native: { query: "select 1 union all select 2" },- type: "model",- },- { wrapId: true, idAlias: "modelId" },+ cy.log(+ "verify that query editing functionality is hidden (metabase#57557)",);-- cy.log("verify that query editing functionality is hidden");cy.signIn("nodata");cy.get("@modelId").then((modelId) =>H.visitModel(Number(modelId), { hasDataAccess: false }),);+ cy.findByTestId("qb-header")+ .findByText("Native model")+ .should("be.visible");+ cy.findByTestId("query-builder-root")+ .findByText(/This question is written in SQL/i)+ .should("not.exist");H.openQuestionActions();H.popover().within(() => {cy.findByText("Edit metadata").should("be.visible");@@ -322,7 +296,7 @@ describe("issue 57557", () => {});});-describe("issue 56775", () => {+describe("issues 56775 and 55486", () => {const MODEL_NAME = "Model 56775";beforeEach(() => {@@ -340,37 +314,6 @@ describe("issue 56775", () => {);});- it("should render the correct query after using the back button in a model (metabase#56775)", () => {- H.openNotebook();- cy.button("Visualize").click();-- cy.go("back");- H.openQuestionActions("Edit query definition");-- cy.log("verify that the model definition is visible");- H.getNotebookStep("data").findByText(MODEL_NAME).should("not.exist");- H.getNotebookStep("data").findByText("Products").should("be.visible");- });-});-describe("issue 55486", () => {- const MODEL_NAME = "Model 55486";-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- H.createQuestion(- {- type: "model",- name: MODEL_NAME,- query: {- "source-table": PRODUCTS_ID,- limit: 5,- },- },- { visitQuestion: true },- );- });-function checkIsShowingMetadataEditorTab() {cy.findByTestId("editor-tabs-columns").should("be.checked");cy.findByTestId("visualization-root").should("be.visible");@@ -381,9 +324,18 @@ describe("issue 55486", () => {H.getNotebookStep("data").should("be.visible");}- it("should render the correct query after using the back button in a model (metabase#56775)", () => {+ it("should render the correct query and editor tabs after using the back and forward buttons in a model (metabase#56775, metabase#55486)", () => {+ H.openNotebook();+ cy.button("Visualize").click();++ cy.go("back");H.openQuestionActions("Edit query definition");+ cy.log("verify that the model definition is visible (metabase#56775)");+ H.getNotebookStep("data").findByText(MODEL_NAME).should("not.exist");+ H.getNotebookStep("data").findByText("Products").should("be.visible");++ cy.log("navigate between the editor tabs (metabase#55486)");H.datasetEditBar().findByText("Columns").click();checkIsShowingMetadataEditorTab();@@ -398,7 +350,7 @@ describe("issue 55486", () => {cy.go("back");checkIsShowingQueryEditorTab();- cy.log("Forward button should show the query editor");+ cy.log("Forward button should show the metadata editor");cy.go("forward");checkIsShowingMetadataEditorTab();@@ -412,6 +364,7 @@ describe("Issue 30712", () => {beforeEach(() => {H.restore();cy.signInAsNormalUser();+ cy.intercept("POST", "/api/dataset").as("dataset");H.startNewModel();@@ -427,10 +380,14 @@ describe("Issue 30712", () => {it("should not crash the editor when ordering by columns on joined tables (metabase#30712)", () => {H.getNotebookStep("summarize").findByLabelText("Sort").click();H.popover().findByText("Total").click();+ H.getNotebookStep("sort").findByText("Total").should("be.visible");cy.log("no error should be thrown");cy.get("main").findByText("Something's gone wrong").should("not.exist");- cy.findByTestId("run-button").should("be.visible");+ cy.findByTestId("run-button").should("be.visible").click();+ cy.wait("@dataset");+ H.tableInteractive().should("be.visible");+ H.tableInteractiveHeader().findByText("Total").should("be.visible");});});describe("Issue 56913", () => {@@ -438,18 +395,10 @@ describe("Issue 56913", () => {H.restore();cy.signInAsNormalUser();- H.createQuestion(- {- query: {- "source-table": ORDERS_ID,- },- },- { visitQuestion: true },- );-- H.openQuestionActions();- H.popover().findByText("Turn into a model").click();- H.modal().button("Turn this into a model").click();+ const ackUrl =+ "/api/user-key-value/namespace/user_acknowledgement/key/turn_into_model_modal";+ cy.request("PUT", ackUrl, { value: true });+ cy.intercept("GET", ackUrl).as("modelModalAck");H.createNativeQuestion({@@ -472,6 +421,7 @@ describe("Issue 56913", () => {it("should show the error modal when converting a native question with variables into a model, even when the 'turn into a model' modal was previously acknowledged (metabase#56913)", () => {H.openQuestionActions();+ cy.wait("@modelModalAck").its("response.body").should("eq", true);H.popover().findByText("Turn into a model").click();H.modal().findByText("Variables in models aren't supported yet")@@ -526,7 +476,7 @@ describe("issue 38747", () => {cy.signInAsNormalUser();});- it("should allow you to drill through with entity qualified ids", () => {+ it("should allow you to drill through with entity qualified ids (metabase#38747)", () => {cy.visit("/model/new");cy.findByRole("link", { name: /notebook editor/ }).click();@@ -563,7 +513,7 @@ describe("issue 38747", () => {.should("be.visible").click({ waitForAnimations: false });- // Assert that we're at an adhoc question with aproprate filters+ // Assert that we're at an adhoc question with appropriate filterscy.location("pathname").should("equal", "/question");cy.findByTestId("filter-pill").should("contain.text",@@ -572,20 +522,3 @@ describe("issue 38747", () => {H.tableInteractive().should("have.attr", "data-rows-count", "1");});});--describe("issue 69722", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- cy.visit("/model/new");- cy.findByRole("link", { name: /native query/ }).click();- });-- it("should not be possible to overflow the native query editor (metabase#69722)", () => {- H.NativeEditor.type("{enter}".repeat(20));-- cy.findByTestId("native-query-editor-container")- .findByTestId("run-button")- .should("be.visible");- });-});diff --git a/e2e/test/scenarios/models/reproductions-3.cy.spec.ts b/e2e/test/scenarios/models/reproductions-3.cy.spec.tsindex 9e747a04735..dfbe8e19752 100644--- a/e2e/test/scenarios/models/reproductions-3.cy.spec.ts+++ b/e2e/test/scenarios/models/reproductions-3.cy.spec.ts@@ -20,7 +20,7 @@ describe("issue 19180", () => {cy.intercept("/api/card/*/query").as("cardQuery");});- it("shouldn't drop native model query results after leaving the query editor", () => {+ it("shouldn't drop native model query results after leaving the query editor (metabase#19180)", () => {H.createNativeQuestion(QUESTION).then(({ body: { id: QUESTION_ID } }) => {cy.request("PUT", `/api/card/${QUESTION_ID}`, { type: "model" }).then(() => {@@ -57,46 +57,10 @@ describe("issue 20042", () => {cy.wait("@query");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Orders Model");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("37.65");- });-});--describe("issue 20045", () => {- beforeEach(() => {- cy.intercept("POST", "/api/dataset").as("dataset");-- H.restore();- cy.signInAsAdmin();-- cy.request("PUT", `/api/card/${ORDERS_QUESTION_ID}`, {- name: "Orders Model",- type: "model",- });- });-- it("should not add query hash on the rerun (metabase#20045)", () => {- cy.visit(`/model/${ORDERS_QUESTION_ID}`);-- cy.wait("@dataset");-- cy.location("pathname").should(- "eq",- `/model/${ORDERS_QUESTION_ID}-orders-model`,- );- cy.location("hash").should("eq", "");-- cy.findByTestId("qb-header-action-panel").find(".Icon-refresh").click();-- cy.wait("@dataset");-- cy.location("pathname").should(- "eq",- `/model/${ORDERS_QUESTION_ID}-orders-model`,- );- cy.location("hash").should("eq", "");+ cy.findByTestId("qb-header")+ .findByText("Orders Model")+ .should("be.visible");+ H.tableInteractive().findByText("37.65").should("be.visible");});});@@ -155,7 +119,6 @@ describe("issue 26091", () => {beforeEach(() => {H.restore();cy.signInAsAdmin();- cy.intercept("POST", "/api/card").as("saveQuestion");});it("should allow to choose a newly created model in the data picker (metabase#26091)", () => {@@ -175,7 +138,11 @@ describe("issue 26091", () => {startNewQuestion();H.miniPicker().within(() => {cy.findByText("Our analytics").click();- cy.findByText("New model").should("be.visible");+ cy.findByText("New model")+ .should("be.visible")+ .closest("[role=menuitem]")+ .icon("model")+ .should("exist");cy.findByText("Old model").should("be.visible");cy.findByText("Orders Model").should("be.visible");});@@ -291,7 +258,6 @@ describe("issue 29951", { requestTimeout: 10000, viewportWidth: 1600 }, () => {beforeEach(() => {H.restore();cy.signInAsAdmin();- cy.intercept("PUT", "/api/card/*").as("updateCard");});it("should allow to run the model query after changing custom columns (metabase#29951)", () => {@@ -350,12 +316,11 @@ describe("issue 31663", () => {H.tableInteractive().findByText("Product ID").click();cy.wait("@idFields");cy.findByPlaceholderText("Select a target").click();- H.popover().findByText("Orders Model → ID").should("not.exist");- H.popover().findByText("Products Model → ID").should("not.exist");-H.popover().findByText("Orders → ID").should("be.visible");H.popover().findByText("People → ID").should("be.visible");H.popover().findByText("Products → ID").should("be.visible");+ H.popover().findByText("Orders Model → ID").should("not.exist");+ H.popover().findByText("Products Model → ID").should("not.exist");H.popover().scrollTo("bottom").findByText("Reviews → ID")@@ -363,30 +328,7 @@ describe("issue 31663", () => {});});-describe("issue 31905", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- cy.intercept("GET", "/api/card/*").as("card");-- H.createQuestion(- {- name: "Orders Model",- type: "model",- query: { "source-table": ORDERS_ID, limit: 2 },- },- { visitQuestion: true },- );- });-- // TODO: This should be 1, but MainNavbar.tsx RTKQ fetch + QB's call to loadCard makes it 2- it("should not send more than one same api requests to load a model (metabase#31905)", () => {- cy.get("@card.all").should("have.length.lte", 2);- });-});--describe("issue 32963", () => {+describe("issues 31905 and 32963", () => {function assertLineChart() {H.openVizTypeSidebar();H.leftSidebar().within(() => {@@ -406,6 +348,7 @@ describe("issue 32963", () => {beforeEach(() => {H.restore();cy.signInAsAdmin();+ cy.intercept("GET", "/api/card/*").as("card");H.createQuestion({name: "Orders Model",@@ -416,7 +359,11 @@ describe("issue 32963", () => {);});- it("should pick sensible display for model based questions (metabase#32963)", () => {+ it("should load a model once and pick sensible display for model based questions (metabase#31905, metabase#32963)", () => {+ cy.log("should not send more than one same api request (metabase#31905)");+ // TODO: This should be 1, but MainNavbar.tsx RTKQ fetch + QB's call to loadCard makes it 2+ cy.get("@card.all").should("have.length.within", 1, 2);+cy.findByTestId("qb-header").button(/Summarize/).click();diff --git a/e2e/test/scenarios/models/reproductions.cy.spec.js b/e2e/test/scenarios/models/reproductions.cy.spec.jsindex a650050a925..6053eded8e5 100644--- a/e2e/test/scenarios/models/reproductions.cy.spec.js+++ b/e2e/test/scenarios/models/reproductions.cy.spec.js@@ -34,28 +34,7 @@ describe("issue 19737", () => {cy.signInAsAdmin();});- it("should show moved model in the data picker without refreshing (metabase#19737)", () => {- cy.visit("/collection/root");-- moveModel(modelName, personalCollectionName);-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Moved model");-- cy.findByLabelText("Navigation bar").within(() => {- cy.findByText("New").click();- });- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Question").should("be.visible").click();-- H.miniPickerBrowseAll().click();- H.entityPickerModal().within(() => {- cy.findByText(personalCollectionName).click();- cy.findByText(modelName);- });- });-- it("should not show duplicate models in the data picker after it's moved from a custom collection without refreshing (metabase#19737)", () => {+ it("should show a moved model once in the data picker without refreshing (metabase#19737)", () => {// move "Orders Model" to "First collection"cy.visit("/collection/root");@@ -63,7 +42,7 @@ describe("issue 19737", () => {// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText("Moved model");- // Close the modal so the next time we move the model another model will always be shown+ // Close the undo toast so the next time we move the model another model will always be showncy.icon("close:visible").click();cy.findByLabelText("Navigation bar").within(() => {@@ -100,9 +79,14 @@ describe("issue 19737", () => {H.miniPickerBrowseAll().click();H.entityPickerModal().within(() => {- cy.findByText("First collection").should("not.exist");- H.entityPickerModalLevel(1).should("exist");- H.entityPickerModalLevel(2).should("not.exist");+ H.entityPickerModalItem(0, personalCollectionName).click();+ H.entityPickerModalLevel(1).findByText(modelName).should("be.visible");++ H.entityPickerModalItem(0, "Our analytics").click();+ H.entityPickerModalLevel(1).should("be.visible");+ H.entityPickerModalLevel(1)+ .findByText("First collection")+ .should("not.exist");});});});@@ -122,9 +106,6 @@ describe("issue 23024", () => {}beforeEach(() => {- cy.intercept("POST", "/api/card/*/query").as("cardQuery");- cy.intercept("PUT", "/api/card/*").as("updateMetadata");-H.restore();cy.signInAsAdmin();@@ -217,10 +198,18 @@ describe("issue 23421", () => {cy.signInAsAdmin();});- it("`visualization_settings` should not break UI (metabase#23421)", () => {+ it("`visualization_settings` with empty or hidden columns should not break UI (metabase#23421)", () => {H.createNativeQuestion(emptyColumnsQuestionDetails, {- visitQuestion: true,+ wrapId: true,+ idAlias: "emptyColumnsModelId",+ });+ H.createNativeQuestion(hiddenColumnsModelDetails, {+ wrapId: true,+ idAlias: "hiddenColumnsModelId",});++ cy.log("empty columns");+ cy.get("@emptyColumnsModelId").then((id) => H.visitModel(id));H.openQuestionActions();H.popover().findByText("Edit query definition").click();@@ -228,12 +217,9 @@ describe("issue 23421", () => {cy.findByRole("columnheader", { name: "id" }).should("be.visible");cy.findByRole("columnheader", { name: "created_at" }).should("be.visible");cy.button("Save changes").should("be.visible");- });- it("`visualization_settings` with hidden columns should not break UI (metabase#23421)", () => {- H.createNativeQuestion(hiddenColumnsModelDetails, {- visitQuestion: true,- });+ cy.log("hidden columns");+ cy.get("@hiddenColumnsModelId").then((id) => H.visitModel(id));H.openQuestionActions();H.popover().findByText("Edit query definition").click();@@ -250,12 +236,15 @@ describe("issue 23449", () => {const questionDetails = { query: { "source-table": REVIEWS_ID, limit: 2 } };function turnIntoModel() {cy.intercept("PUT", "/api/card/*").as("cardUpdate");+ cy.intercept("POST", "/api/dataset").as("modelQuery");H.openQuestionActions();cy.findByText("Turn into a model").click();cy.findByText("Turn this into a model").click();- cy.wait("@cardUpdate").then(({ response }) => {+ cy.wait("@cardUpdate");+ // Turning the question into a model re-runs its query+ cy.wait("@modelQuery").then(({ response }) => {expect(response.body.error).to.not.exist;});}@@ -285,7 +274,7 @@ describe("issue 23449", () => {cy.findByTextEnsureVisible("Perfecto");turnIntoModel();- cy.findByTextEnsureVisible("Perfecto");+ H.tableInteractive().findByTextEnsureVisible("Perfecto");});});@@ -344,7 +333,7 @@ describe("issue 29378", () => {H.setActionsEnabledForDB(SAMPLE_DB_ID);});- it("should not crash the model detail page after searching for an action (metabase#29378)", () => {+ it("should not crash the model actions page after searching for an action (metabase#29378)", () => {cy.request("PUT", `/api/card/${ORDERS_QUESTION_ID}`, { type: "model" });H.createAction(ACTION_DETAILS);@@ -379,15 +368,15 @@ function mapModelColumnToDatabase({ table, field }) {H.popover().findByRole("option", { name: table }).click();H.popover().findByRole("option", { name: field }).click();cy.contains(`${table} → ${field}`).should("be.visible");- cy.findAllByDisplayValue(field);- cy.findByLabelText("Description").should("not.be.empty");+ cy.findAllByDisplayValue(field).should("exist");+ cy.findByLabelText("Description").should("not.have.value", "");}function selectModelColumn(column) {cy.findAllByTestId("header-cell").contains(column).click();}-describe("issue 29517 - nested question based on native model with remapped values", () => {+describe("issue 29517 - nested question based on native model with columns mapped to database fields", () => {const questionDetails = {name: "29517",type: "model",@@ -454,16 +443,15 @@ describe("issue 29517 - nested question based on native model with remapped valu});});- it("click behavior to custom destination should work (metabase#29517-2)", () => {- cy.intercept("/api/dashboard/*/dashcard/*/card/*/query").as(- "dashcardQuery",- );-+ it("click behavior to custom destination should work (metabase#29517)", () => {H.visitDashboard("@dashboardId");cy.intercept("GET", `/api/dashboard/${ORDERS_DASHBOARD_ID}*`).as("loadTargetDashboard",);+ cy.intercept("/api/dashboard/*/dashcard/*/card/*/query").as(+ "dashcardQuery",+ );H.cartesianChartCircle().eq(25).click({ force: true });cy.wait("@loadTargetDashboard");@@ -471,11 +459,11 @@ describe("issue 29517 - nested question based on native model with remapped valucy.wait("@dashcardQuery");- cy.get("[data-testid=cell-data]").contains("37.65");+ H.getDashboardCard().findAllByText("37.65").should("be.visible");});});-describe("issue 53556 - nested question based on native model with remapped values", () => {+describe("issue 53556 - nested question based on native model with columns mapped to database fields", () => {const questionDetails = {name: "53556",type: "model",