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 admin e2e tests (#82882)
Ryan Lauriec0fdb3dd07e0
diff --git a/e2e/test/scenarios/admin-2/api-keys.cy.spec.ts b/e2e/test/scenarios/admin/api-keys.cy.spec.tssimilarity index 94%rename from e2e/test/scenarios/admin-2/api-keys.cy.spec.tsrename to e2e/test/scenarios/admin/api-keys.cy.spec.tsindex 47aa3cd2960..2b2edd0e52a 100644--- a/e2e/test/scenarios/admin-2/api-keys.cy.spec.ts+++ b/e2e/test/scenarios/admin/api-keys.cy.spec.ts@@ -25,7 +25,7 @@ describe("scenarios > admin > settings > API keys", () => {cy.signInAsAdmin();});- it("should show number of API keys on auth card", () => {+ it("should show number of API keys on auth card, and list existing API keys", () => {cy.visit("/admin/settings/authentication");cy.wait("@getKeyCount");@@ -40,8 +40,8 @@ describe("scenarios > admin > settings > API keys", () => {.findByTestId("card-badge").findByText("1 API Key");- H.createApiKey("Test API Key Two", ALL_USERS_GROUP_ID);- H.createApiKey("Test API Key Three", ALL_USERS_GROUP_ID);+ H.createApiKey("Test API Key Two", NOSQL_GROUP_ID);+ H.createApiKey("Test API Key Three", READONLY_GROUP_ID);cy.reload();cy.wait("@getKeyCount");@@ -49,13 +49,8 @@ describe("scenarios > admin > settings > API keys", () => {cy.findByTestId("api-keys-setting").findByTestId("card-badge").findByText("3 API Keys");- });-- it("should list existing API keys", () => {- H.createApiKey("Test API Key One", ALL_USERS_GROUP_ID);- H.createApiKey("Test API Key Two", NOSQL_GROUP_ID);- H.createApiKey("Test API Key Three", READONLY_GROUP_ID);+ cy.log("should list existing API keys");visitApiKeySettings();cy.findByTestId("api-keys-table").within(() => {@@ -73,7 +68,7 @@ describe("scenarios > admin > settings > API keys", () => {});});- it("should allow creating an API key", () => {+ it("should allow creating an API key, and show an error when a previously used key name is submitted", () => {const name = "New key";const group = "Administrators";visitApiKeySettings();@@ -86,14 +81,7 @@ describe("scenarios > admin > settings > API keys", () => {cy.button("Done").click();cy.findByTestId("api-keys-table").findByText(name);- });- it("should show an error when a previously used key name is submitted", () => {- const name = "New key";- const group = "Administrators";- visitApiKeySettings();- H.tryToCreateApiKeyViaModal({ name, group });- cy.button("Done").click();H.tryToCreateApiKeyViaModal({ name, group }).then(({ response }) => {expect(response?.statusCode).to.equal(400);});diff --git a/e2e/test/scenarios/admin-2/authentication.cy.spec.ts b/e2e/test/scenarios/admin/authentication.cy.spec.tssimilarity index 100%rename from e2e/test/scenarios/admin-2/authentication.cy.spec.tsrename to e2e/test/scenarios/admin/authentication.cy.spec.tsdiff --git a/e2e/test/scenarios/admin/database-connection-strings.cy.spec.ts b/e2e/test/scenarios/admin/database-connection-strings.cy.spec.tsindex 823b241a221..81d8fec85a8 100644--- a/e2e/test/scenarios/admin/database-connection-strings.cy.spec.ts+++ b/e2e/test/scenarios/admin/database-connection-strings.cy.spec.ts@@ -205,7 +205,20 @@ const databaseTestCases = [];describe("Database connection strings", () => {- it("should parse connection strings for all supported databases", () => {+ it("should enable 'Save' for a valid connection string, and parse connection strings for all supported databases without clearing existing values", () => {+ cy.log(+ "should enable the 'Save' button when the connection string is valid",+ );+ // Runs on a fresh form: engine changes keep earlier values, which could+ // enable Save before the paste+ cy.visit("/admin/databases/create");+ chooseDatabase("MySQL");+ cy.findByLabelText("Connection string (optional)").paste(+ "jdbc:mysql://testuser:testpass@host:3306/dbname?ssl=true",+ );+ cy.button("Save").should("be.enabled");++ cy.log("should parse connection strings for all supported databases");cy.visit("/admin/databases/create");databaseTestCases.forEach(@@ -226,35 +239,12 @@ describe("Database connection strings", () => {});},);- });-- it("should enable the 'Save' button when the connection string is valid", () => {- cy.visit("/admin/databases/create");-- chooseDatabase("MySQL");-- cy.findByLabelText("Connection string (optional)").paste(- "jdbc:mysql://testuser:testpass@host:3306/dbname?ssl=true",- );-- cy.button("Save").should("be.enabled");- });-- it("should show a warning if the connection string is invalid", () => {- cy.visit("/admin/databases/create");-- chooseDatabase("MySQL");-- cy.findByLabelText("Connection string (optional)").paste("invalid");-- cy.findByTextEnsureVisible("Couldn’t use this connection string.");- });-- it("should not clear the existing values", () => {- cy.visit("/admin/databases/create");+ cy.log("should not clear the existing values");+ // Keep this step last: values that the connection string doesn't set are+ // preserved, so running it earlier could leak into the cases above.chooseDatabase("PostgreSQL");- cy.findByLabelText("Port").type("1111");+ cy.findByLabelText("Port").clear().type("1111");cy.findByLabelText("Connection string (optional)").paste("postgresql://postgres:[email protected]/postgres",@@ -373,7 +363,8 @@ describe("Database connection strings events", () => {cy.visit("/admin/databases/create?engine=mysql");});- it("should track success events correctly", () => {+ it("should track success and failure events correctly", () => {+ cy.log("should track success events correctly");const successEvent = {event: "connection_string_parsed_success",triggered_from: "full-page",@@ -397,9 +388,8 @@ describe("Database connection strings events", () => {// Should not track the same event againH.expectUnstructuredSnowplowEvent(successEvent, 1);- });- it("should track failure events correctly", () => {+ cy.log("should track failure events correctly");cy.findByLabelText("Connection string (optional)").focus().paste("broken string")diff --git a/e2e/test/scenarios/admin/database-routing/database-routing-admin.cy.spec.ts b/e2e/test/scenarios/admin/database-routing/database-routing-admin.cy.spec.tsindex f4139581542..c031e3e1540 100644--- a/e2e/test/scenarios/admin/database-routing/database-routing-admin.cy.spec.ts+++ b/e2e/test/scenarios/admin/database-routing/database-routing-admin.cy.spec.ts@@ -284,14 +284,16 @@ describe("admin > database > database routing", () => {.should("not.exist");});- it("should not allow turning on db routing on if other conflicting features are enabled", () => {+ it("should not allow turning on db routing if other conflicting features are enabled", () => {cy.log("setup");setupModelPersistence();visitDatabaseAdminPage(WRITABLE_DB_ID);cy.log("should be disabled if model actions is enabled");cy.findByLabelText("Model actions").should("be.checked");- assertDbRoutingDisabled();+ assertDbRoutingDisabled(+ "Database routing can't be enabled if model actions are enabled.",+ );cy.findByLabelText("Model actions").parent("label").click();@@ -303,7 +305,9 @@ describe("admin > database > database routing", () => {.parent("label").click();- assertDbRoutingDisabled();+ assertDbRoutingDisabled(+ "Database routing can't be enabled if model persistence is enabled.",+ );cy.findAllByTestId("database-model-features-section").findByLabelText("Model persistence").should("be.checked")@@ -311,6 +315,23 @@ describe("admin > database > database routing", () => {.click();assertDbRoutingNotDisabled();+ cy.log("should be disabled if table editing is enabled");+ // Table editing must be the only active conflict here: the routing+ // section shows a single message, and model actions, model persistence,+ // and uploads all take precedence over table editing.+ tableEditingSection()+ .findByLabelText("Editable tables")+ .should("not.be.checked")+ .click({ force: true });+ assertDbRoutingDisabled(+ "Database routing can't be enabled when table editing is enabled.",+ );+ tableEditingSection()+ .findByLabelText("Editable tables")+ .should("be.checked")+ .click({ force: true });+ assertDbRoutingNotDisabled();+cy.log("should be disabled if uploads are enabled for the database");cy.visit("/admin/settings/uploads");cy.findByLabelText("Upload Settings Form")@@ -327,7 +348,9 @@ describe("admin > database > database routing", () => {.click();visitDatabaseAdminPage(WRITABLE_DB_ID);- assertDbRoutingDisabled();+ assertDbRoutingDisabled(+ "Database routing can't be enabled if uploads are enabled for this database.",+ );});it("should highlight that a dabtabase has routing enabled on the permissions pages", () => {@@ -431,143 +454,62 @@ describe("admin > database > database routing", () => {disableModelActionsViaApi(WRITABLE_DB_ID);});- describe("model actions", () => {- it("should not be possible to enable model actions when database routing is enabled", () => {- configureDbRoutingViaAPI({- router_database_id: WRITABLE_DB_ID,- user_attribute: "role",- });-- visitDatabaseAdminPage(WRITABLE_DB_ID);-- modelsSection().within(() => {- cy.findByLabelText("Model actions").should("be.disabled");- cy.findByText(- "Model actions can't be enabled when database routing is enabled.",- )- .scrollIntoView()- .should("be.visible");- });- });-- it("should not be possible to enable database routing when model actions are enabled", () => {- enableModelActionsViaApi(WRITABLE_DB_ID);- visitDatabaseAdminPage(WRITABLE_DB_ID);-- dbRoutingSection().within(() => {- cy.findByLabelText("Enable database routing").should("be.disabled");- cy.findByText(- "Database routing can't be enabled if model actions are enabled.",- )- .scrollIntoView()- .should("be.visible");- });- });- });-- describe("model persistence", () => {- beforeEach(() => {- enableGlobalModelPersistence();- });-- it("should not be possible to enable model persistence when database routing is enabled", () => {- configureDbRoutingViaAPI({- router_database_id: WRITABLE_DB_ID,- user_attribute: "role",- });-- visitDatabaseAdminPage(WRITABLE_DB_ID);- modelsSection().within(() => {- cy.findByLabelText("Model persistence").should("be.disabled");- cy.findByText(- "Model persistence can't be enabled when database routing is enabled.",- )- .scrollIntoView()- .should("be.visible");- });- });-- it("should not be possible to enable database routing when model persistence enabled", () => {- visitDatabaseAdminPage(WRITABLE_DB_ID);- modelsSection()- .findByLabelText("Model persistence")- .click({ force: true });-- dbRoutingSection().within(() => {- cy.findByLabelText("Enable database routing").should("be.disabled");- cy.findByText(- "Database routing can't be enabled if model persistence is enabled.",- )- .scrollIntoView()- .should("be.visible");- });+ it("should not be possible to enable model persistence, model actions, table editing, or uploads when database routing is enabled", () => {+ cy.log("setup");+ enableGlobalModelPersistence();+ configureDbRoutingViaAPI({+ router_database_id: WRITABLE_DB_ID,+ user_attribute: "role",});- });- describe("Table editing", () => {- it("should not be possible to enable table editing when database routing is enabled", () => {- configureDbRoutingViaAPI({- router_database_id: WRITABLE_DB_ID,- user_attribute: "role",- });-- visitDatabaseAdminPage(WRITABLE_DB_ID);+ visitDatabaseAdminPage(WRITABLE_DB_ID);- tableEditingSection().within(() => {- cy.findByLabelText("Editable tables").should("be.disabled");- cy.findByText(- "Table editing can't be enabled when database routing is enabled.",- )- .scrollIntoView()- .should("be.visible");- });+ cy.log(+ "should not be possible to enable model persistence when database routing is enabled",+ );+ modelsSection().within(() => {+ cy.findByLabelText("Model persistence").should("be.disabled");+ cy.findByText(+ "Model persistence can't be enabled when database routing is enabled.",+ )+ .scrollIntoView()+ .should("be.visible");});- it("should not be possible to enable table editing when database routing is enabled", () => {- visitDatabaseAdminPage(WRITABLE_DB_ID);-- tableEditingSection()- .findByLabelText("Editable tables")- .click({ force: true });-- dbRoutingSection().within(() => {- cy.findByLabelText("Enable database routing").should("be.disabled");- cy.findByText(- "Database routing can't be enabled when table editing is enabled.",- )- .scrollIntoView()- .should("be.visible");- });+ cy.log(+ "should not be possible to enable model actions when database routing is enabled",+ );+ modelsSection().within(() => {+ cy.findByLabelText("Model actions").should("be.disabled");+ cy.findByText(+ "Model actions can't be enabled when database routing is enabled.",+ )+ .scrollIntoView()+ .should("be.visible");});- });- describe("Uploads", () => {- it("should not be possible to enable uploads when database routing is enabled", () => {- configureDbRoutingViaAPI({- router_database_id: WRITABLE_DB_ID,- user_attribute: "role",- });-- visitUploadSettingsPage();- cy.findByLabelText("Database to use for uploads").click();- H.popover()- .findByText("Writable Postgres12 (DB Routing Enabled)")+ cy.log(+ "should not be possible to enable table editing when database routing is enabled",+ );+ tableEditingSection().within(() => {+ cy.findByLabelText("Editable tables").should("be.disabled");+ cy.findByText(+ "Table editing can't be enabled when database routing is enabled.",+ )+ .scrollIntoView().should("be.visible");});- it("should not be possible to enable database routing when uploads are enabled", () => {- H.enableUploads("postgres");- visitDatabaseAdminPage(WRITABLE_DB_ID);-- dbRoutingSection().within(() => {- cy.findByLabelText("Enable database routing").should("be.disabled");- cy.findByText(- "Database routing can't be enabled if uploads are enabled for this database.",- )- .scrollIntoView()- .should("be.visible");- });- });+ cy.log(+ "should not be possible to enable uploads when database routing is enabled",+ );+ // Keep this step last: it navigates away from the database page.+ visitUploadSettingsPage();++ cy.findByLabelText("Database to use for uploads").click();+ H.popover()+ .findByText("Writable Postgres12 (DB Routing Enabled)")+ .should("be.visible");});});});@@ -604,11 +546,12 @@ function assertDbRoutingNotDisabled() {H.tooltip().should("not.contain", /Database routing can't be enabled if/);}-function assertDbRoutingDisabled() {+function assertDbRoutingDisabled(message: string) {dbRoutingSection().within(() => {cy.findByLabelText("Enable database routing").should("not.be.checked").should("be.disabled");+ cy.findByText(message).scrollIntoView().should("be.visible");});// Use cy.trigger("mouseenter") instead of realHover() because Chrome v122+// headless hit-tests CDP mouse events to the disabled <input> inside the@@ -618,9 +561,7 @@ function assertDbRoutingDisabled() {dbRoutingSection().findByTestId("database-routing-toggle-wrapper").trigger("mouseenter");- H.tooltip()- .findByText(/Database routing can't be enabled if/)- .should("exist");+ H.tooltip().findByText(message).should("exist");}function setupModelPersistence() {@@ -644,12 +585,6 @@ function disableModelActionsViaApi(databaseId: DatabaseId) {});}-function enableModelActionsViaApi(databaseId: DatabaseId) {- cy.request("PUT", `/api/database/${databaseId}`, {- settings: { "database-enable-actions": true },- });-}-function enableGlobalModelPersistence() {cy.visit("/admin/performance/models");cy.findByLabelText("Disabled").click();diff --git a/e2e/test/scenarios/admin/databases.cy.spec.js b/e2e/test/scenarios/admin/databases.cy.spec.jsindex 36a8cf82020..4a2a4680506 100644--- a/e2e/test/scenarios/admin/databases.cy.spec.js+++ b/e2e/test/scenarios/admin/databases.cy.spec.js@@ -428,7 +428,10 @@ describe("database page > side panel", () => {cy.visit("/admin/databases/create");});- it("should show side panel with help content when 'Help is here' is clicked", () => {+ it("should show side panel with help content and update it when the engine is changed", () => {+ cy.log(+ "should show side panel with help content when 'Help is here' is clicked",+ );cy.findByRole("button", { name: /Help is here/ }).click();cy.findByTestId("database-help-side-panel").within(() => {cy.findByText("Add PostgreSQL").should("be.visible");@@ -440,9 +443,10 @@ describe("database page > side panel", () => {"be.visible",);});- });+ cy.findByRole("button", { name: /Close panel/ }).click();+ cy.findByTestId("database-help-side-panel").should("not.exist");- it("should update the side panel content when the engine is changed", () => {+ cy.log("should update the side panel content when the engine is changed");const enginesMap = [{ name: "Amazon Athena", file: "athena" },{ name: "BigQuery", file: "bigquery" },diff --git a/e2e/test/scenarios/admin/databases/database-writable-connection.cy.spec.ts b/e2e/test/scenarios/admin/databases/database-writable-connection.cy.spec.tsindex 9b6b463e9a1..3859c6cadb4 100644--- a/e2e/test/scenarios/admin/databases/database-writable-connection.cy.spec.ts+++ b/e2e/test/scenarios/admin/databases/database-writable-connection.cy.spec.ts@@ -45,10 +45,32 @@ describe("scenarios > admin > databases > writable connection", () => {dropTable(TRANSFORM_TABLE_NAME);});- it("should be able to create, edit, and remove a writable connection", () => {+ it("should be able to create, edit, and remove a writable connection and show up-to-date connection health status", () => {visitDatabase(WRITABLE_DB_ID);createWritableConnection(DEFAULT_USER);updateWritableConnection(READ_ONLY_USER);++ cy.log("should show up-to-date connection health status");+ getMainConnectionInfoSection().within(() => {+ getDatabaseConnectionHealthInfo().should("have.text", "Connected");+ });+ getWritableConnectionInfoSection().within(() => {+ getDatabaseConnectionHealthInfo().should("have.text", "Connected");+ });++ dropUser(READ_ONLY_USER);+ visitDatabase(WRITABLE_DB_ID);+ getMainConnectionInfoSection().within(() => {+ getDatabaseConnectionHealthInfo().should("have.text", "Connected");+ });+ getWritableConnectionInfoSection().within(() => {+ getDatabaseConnectionHealthInfo().should(+ "contain.text",+ "Could not connect",+ );+ });++ cy.log("should be able to remove a writable connection");removeWritableConnection();getWritableConnectionInfoSection().findByText("Add writable connection")@@ -72,29 +94,6 @@ describe("scenarios > admin > databases > writable connection", () => {);});- it("should show up-to-date connection health status", () => {- visitDatabase(WRITABLE_DB_ID);- createWritableConnection(READ_ONLY_USER);- getMainConnectionInfoSection().within(() => {- getDatabaseConnectionHealthInfo().should("have.text", "Connected");- });- getWritableConnectionInfoSection().within(() => {- getDatabaseConnectionHealthInfo().should("have.text", "Connected");- });-- dropUser(READ_ONLY_USER);- visitDatabase(WRITABLE_DB_ID);- getMainConnectionInfoSection().within(() => {- getDatabaseConnectionHealthInfo().should("have.text", "Connected");- });- getWritableConnectionInfoSection().within(() => {- getDatabaseConnectionHealthInfo().should(- "contain.text",- "Could not connect",- );- });- });-it("should be able to run transforms with a writable connection", () => {visitDatabase(WRITABLE_DB_ID);diff --git a/e2e/test/scenarios/admin/datamodel/datamodel.cy.spec.ts b/e2e/test/scenarios/admin/datamodel/datamodel.cy.spec.tsindex fce8d48e242..36f89932f14 100644--- a/e2e/test/scenarios/admin/datamodel/datamodel.cy.spec.ts+++ b/e2e/test/scenarios/admin/datamodel/datamodel.cy.spec.ts@@ -38,13 +38,31 @@ describe("scenarios > admin > datamodel", () => {cy.intercept("PUT", "/api/table/*").as("updateTable");});- it("should allow to navigate to a table when on a segments page (SEM-484)", () => {+ it("should restore previously selected table when expanding the tree (SEM-435) and allow to navigate to a table when on a segments page (SEM-484)", () => {H.DataModel.visit({databaseId: SAMPLE_DB_ID,schemaId: SAMPLE_DB_SCHEMA_ID,tableId: ORDERS_ID,});+ cy.log(+ "should restore previously selected table when expanding the tree (SEM-435)",+ );+ H.DataModel.TablePicker.getDatabase("Sample Database").click();+ cy.location("pathname").should(+ "eq",+ `/admin/datamodel/database/${SAMPLE_DB_ID}/schema/${SAMPLE_DB_SCHEMA_ID}/table/${ORDERS_ID}`,+ );++ H.DataModel.TablePicker.getDatabase("Sample Database").click();+ cy.location("pathname").should(+ "eq",+ `/admin/datamodel/database/${SAMPLE_DB_ID}/schema/${SAMPLE_DB_SCHEMA_ID}/table/${ORDERS_ID}`,+ );++ cy.log(+ "should allow to navigate to a table when on a segments page (SEM-484)",+ );cy.findByRole("link", { name: /Segments/ }).click();cy.location("pathname").should("eq", "/admin/datamodel/segments");cy.wait("@schema");@@ -85,26 +103,6 @@ describe("scenarios > admin > datamodel", () => {TablePicker.getSchemas().should("have.length", 0);TablePicker.getTables().should("have.length", 8);});-- it("should restore previously selected table when expanding the tree (SEM-435)", () => {- H.DataModel.visit({- databaseId: SAMPLE_DB_ID,- schemaId: SAMPLE_DB_SCHEMA_ID,- tableId: ORDERS_ID,- });-- TablePicker.getDatabase("Sample Database").click();- cy.location("pathname").should(- "eq",- `/admin/datamodel/database/${SAMPLE_DB_ID}/schema/${SAMPLE_DB_SCHEMA_ID}/table/${ORDERS_ID}`,- );-- TablePicker.getDatabase("Sample Database").click();- cy.location("pathname").should(- "eq",- `/admin/datamodel/database/${SAMPLE_DB_ID}/schema/${SAMPLE_DB_SCHEMA_ID}/table/${ORDERS_ID}`,- );- });});describe(@@ -117,7 +115,7 @@ describe("scenarios > admin > datamodel", () => {H.resyncDatabase({ dbId: WRITABLE_DB_ID });});- it("should allow to search for tables", () => {+ it("should allow to search for tables and restore previously selected table when expanding the tree (SEM-435)", () => {H.DataModel.visit();TablePicker.getSearchInput().type("rd");@@ -145,9 +143,11 @@ describe("scenarios > admin > datamodel", () => {TablePicker.getDatabases().should("have.length", 2);TablePicker.getSchemas().should("have.length", 2);TablePicker.getTables().should("have.length", 2);- });- it("should restore previously selected table when expanding the tree (SEM-435)", () => {+ cy.log(+ "should restore previously selected table when expanding the tree (SEM-435)",+ );+ // Reload so the tree starts fully collapsed, as the tree state is not persistedH.DataModel.visit();TablePicker.getDatabase("Writable Postgres12").click();@@ -170,7 +170,7 @@ describe("scenarios > admin > datamodel", () => {);describe("Table visibility", () => {- it("should allow changing the table visibility", () => {+ it("should allow changing the table visibility and not prevent editing related question after turning table visibility off (metabase#15947)", () => {H.DataModel.visit({databaseId: SAMPLE_DB_ID,schemaId: SAMPLE_DB_SCHEMA_ID,@@ -189,6 +189,12 @@ describe("scenarios > admin > datamodel", () => {cy.findByText("Orders").should("not.exist");});+ cy.log(+ "shouldn't prevent editing related question after turning table visibility off - simple question (metabase#15947-1)",+ );+ H.visitQuestion(ORDERS_QUESTION_ID);+ H.queryBuilderHeader().findByText("View-only").should("be.visible");+H.DataModel.visit({databaseId: SAMPLE_DB_ID,schemaId: SAMPLE_DB_SCHEMA_ID,@@ -285,7 +291,7 @@ describe("scenarios > admin > datamodel", () => {});it(- "should allow hiding and restoring all tables in a single-schema database",+ "should allow hiding and restoring all tables in a multi-schema database",{ tags: ["@external"] },() => {H.restore("postgres-writable");@@ -408,15 +414,6 @@ describe("scenarios > admin > datamodel", () => {cy.contains("Orders").should("not.exist");});});-- describe("shouldn't prevent editing related question after turning table visibility off (metabase#15947)", () => {- it("simple question (metabase#15947-1)", () => {- turnTableVisibilityOff(ORDERS_ID);- H.visitQuestion(ORDERS_QUESTION_ID);-- H.queryBuilderHeader().findByText("View-only").should("be.visible");- });- });});});@@ -521,18 +518,8 @@ describe("scenarios > admin > datamodel", () => {});describe("Sorting", () => {- it("should allow sorting fields as in the database", () => {- H.DataModel.visit({- databaseId: SAMPLE_DB_ID,- schemaId: SAMPLE_DB_SCHEMA_ID,- tableId: PRODUCTS_ID,- });-- TableSection.getSortButton().click();- TableSection.getSortOrderInput()- .findByDisplayValue("database")- .should("be.checked");-+ it("should allow sorting fields alphabetically and smartly", () => {+ cy.log("fields are sorted as in the database by default");H.openProductsTable();H.assertTableData({columns: [@@ -546,9 +533,7 @@ describe("scenarios > admin > datamodel", () => {"Created At",],});- });- it("should allow sorting fields alphabetically", () => {H.DataModel.visit({databaseId: SAMPLE_DB_ID,schemaId: SAMPLE_DB_SCHEMA_ID,@@ -556,6 +541,10 @@ describe("scenarios > admin > datamodel", () => {});TableSection.getSortButton().click();+ TableSection.getSortOrderInput()+ .findByDisplayValue("database")+ .should("be.checked");+TableSection.getSortOrderInput().findByLabelText("Alphabetical order").click();@@ -578,9 +567,8 @@ describe("scenarios > admin > datamodel", () => {"Vendor",],});- });- it("should allow sorting fields smartly", () => {+ cy.log("should allow sorting fields smartly");H.DataModel.visit({databaseId: SAMPLE_DB_ID,schemaId: SAMPLE_DB_SCHEMA_ID,@@ -610,52 +598,7 @@ describe("scenarios > admin > datamodel", () => {});});- it("should allow sorting fields in the custom order", () => {- H.DataModel.visit({- databaseId: SAMPLE_DB_ID,- schemaId: SAMPLE_DB_SCHEMA_ID,- tableId: PRODUCTS_ID,- });-- TableSection.getSortButton().click();- TableSection.getSortOrderInput()- .findByDisplayValue("database")- .should("be.checked");-- TableSection.getSortableField("ID").as("dragElement");- H.moveDnDKitElementByAlias("@dragElement", {- vertical: 50,- });- cy.wait("@updateFieldOrder");- verifyAndCloseToast("Field order updated");-- cy.log(- "should not show loading state after an update (metabase#56482)",- );- cy.findByTestId("loading-indicator", { timeout: 0 }).should(- "not.exist",- );-- TableSection.getSortOrderInput()- .findByDisplayValue("custom")- .should("be.checked");-- H.openProductsTable();- H.assertTableData({- columns: [- "Ean",- "ID",- "Title",- "Category",- "Vendor",- "Price",- "Rating",- "Created At",- ],- });- });-- it("should allow switching to predefined order after drag & drop (metabase#56482)", () => {+ it("should allow sorting fields in a custom order and switching back to predefined order (metabase#56482)", () => {H.DataModel.visit({databaseId: SAMPLE_DB_ID,schemaId: SAMPLE_DB_SCHEMA_ID,@@ -724,6 +667,21 @@ describe("scenarios > admin > datamodel", () => {expect($items[0].textContent).to.equal("Ean");expect($items[1].textContent).to.equal("ID");});++ cy.log("custom order is applied in the query builder");+ H.openProductsTable();+ H.assertTableData({+ columns: [+ "Ean",+ "ID",+ "Title",+ "Category",+ "Vendor",+ "Price",+ "Rating",+ "Created At",+ ],+ });});});@@ -880,29 +838,6 @@ describe("scenarios > admin > datamodel", () => {});cy.findByLabelText("Left column").should("contain.text", "User ID");});-- it("should not allow setting foreign key target for inaccessible tables", () => {- H.activateToken("pro-self-hosted");- setDataModelPermissions({ tableIds: [REVIEWS_ID] });-- cy.signIn("none");- H.DataModel.visit({- databaseId: SAMPLE_DB_ID,- schemaId: SAMPLE_DB_SCHEMA_ID,- tableId: REVIEWS_ID,- fieldId: REVIEWS.PRODUCT_ID,- });- FieldSection.getDisplayValuesInput().click();-- H.popover().within(() => {- cy.findByRole("option", { name: /Use original value/ })- .should("be.visible")- .and("not.have.attr", "data-combobox-disabled");- cy.findByRole("option", { name: /Use foreign key/ })- .should("be.visible")- .and("have.attr", "data-combobox-disabled", "true");- });- });});});@@ -937,11 +872,35 @@ describe("scenarios > admin > datamodel", () => {cy.findByText("Rustic Paper Wallet").should("be.visible");});- it("should show a proper error message when using custom mapping", () => {+ it("should not allow setting foreign key target for inaccessible tables and show a proper error message when using custom mapping", () => {H.activateToken("pro-self-hosted");setDataModelPermissions({ tableIds: [REVIEWS_ID] });cy.signIn("none");++ cy.log(+ "should not allow setting foreign key target for inaccessible tables",+ );+ H.DataModel.visit({+ databaseId: SAMPLE_DB_ID,+ schemaId: SAMPLE_DB_SCHEMA_ID,+ tableId: REVIEWS_ID,+ fieldId: REVIEWS.PRODUCT_ID,+ });+ FieldSection.getDisplayValuesInput().click();++ H.popover().within(() => {+ cy.findByRole("option", { name: /Use original value/ })+ .should("be.visible")+ .and("not.have.attr", "data-combobox-disabled");+ cy.findByRole("option", { name: /Use foreign key/ })+ .should("be.visible")+ .and("have.attr", "data-combobox-disabled", "true");+ });++ cy.log(+ "should show a proper error message when using custom mapping",+ );H.DataModel.visit({databaseId: SAMPLE_DB_ID,schemaId: SAMPLE_DB_SCHEMA_ID,@@ -991,7 +950,7 @@ describe("scenarios > admin > datamodel", () => {describe("Preview section", () => {describe("Esc key", () => {- it("should allow closing the preview with Esc key", () => {+ it("should not close the preview when hitting Esc key while modal is open, and allow closing it with Esc key otherwise", () => {H.DataModel.visit({databaseId: SAMPLE_DB_ID,schemaId: SAMPLE_DB_SCHEMA_ID,@@ -1004,21 +963,6 @@ describe("scenarios > admin > datamodel", () => {FieldSection.getPreviewButton().click();PreviewSection.get().should("be.visible");- cy.realPress("Escape");- PreviewSection.get().should("not.exist");- });-- it("should not close the preview when hitting Esc key while modal is open", () => {- H.DataModel.visit({- databaseId: SAMPLE_DB_ID,- schemaId: SAMPLE_DB_SCHEMA_ID,- tableId: ORDERS_ID,- fieldId: ORDERS.PRODUCT_ID,- });-- FieldSection.getPreviewButton().click();- PreviewSection.get().should("be.visible");-TableSection.getSyncOptionsButton().click();H.modal().should("be.visible");@@ -1032,28 +976,15 @@ describe("scenarios > admin > datamodel", () => {cy.realPress("Escape");H.modal().should("not.exist");PreviewSection.get().should("be.visible");- });-- it("should not close the preview when hitting Esc key while popover is open", () => {- H.DataModel.visit({- databaseId: SAMPLE_DB_ID,- schemaId: SAMPLE_DB_SCHEMA_ID,- tableId: ORDERS_ID,- fieldId: ORDERS.PRODUCT_ID,- });-- FieldSection.getPreviewButton().click();- PreviewSection.get().should("be.visible");-- FieldSection.getSemanticTypeInput().click();- H.popover().should("be.visible");+ cy.log("should allow closing the preview with Esc key");+ // Focus returns to the "Field values" button once the modal closes. Esc is+ // ignored while an input is focused, so this must not follow the popover case.cy.realPress("Escape");- H.popover({ skipVisibilityCheck: true }).should("not.be.visible");- PreviewSection.get().should("be.visible");+ PreviewSection.get().should("not.exist");});- it("should not close the preview when hitting Esc key while command palette is open", () => {+ it("should not close the preview when hitting Esc key while command palette or popover is open", () => {H.DataModel.visit({databaseId: SAMPLE_DB_ID,schemaId: SAMPLE_DB_SCHEMA_ID,@@ -1070,6 +1001,16 @@ describe("scenarios > admin > datamodel", () => {cy.realPress("Escape");H.commandPalette().should("not.exist");PreviewSection.get().should("be.visible");++ cy.log(+ "should not close the preview when hitting Esc key while popover is open",+ );+ FieldSection.getSemanticTypeInput().click();+ H.popover().should("be.visible");++ cy.realPress("Escape");+ H.popover({ skipVisibilityCheck: true }).should("not.be.visible");+ PreviewSection.get().should("be.visible");});});@@ -1225,13 +1166,6 @@ describe("scenarios > admin > datamodel", () => {});});-function turnTableVisibilityOff(tableId: TableId) {- cy.request("PUT", "/api/table", {- ids: [tableId],- visibility_type: "hidden",- });-}-const setDataModelPermissions = ({tableIds = [],}: {diff --git a/e2e/test/scenarios/admin/datamodel/segments.cy.spec.ts b/e2e/test/scenarios/admin/datamodel/segments.cy.spec.tsindex f0e01264cae..1f5c9981eca 100644--- a/e2e/test/scenarios/admin/datamodel/segments.cy.spec.ts+++ b/e2e/test/scenarios/admin/datamodel/segments.cy.spec.ts@@ -12,29 +12,6 @@ describe("scenarios > admin > datamodel > segments", () => {});describe("with no segments", () => {- it("should have 'Custom expression' in a filter list (metabase#13069)", () => {- cy.visit("/admin/datamodel/segments");-- cy.log("should initially show no segments in UI");- cy.get("main").findByText(- "Create segments to add them to the Filter dropdown in the query builder",- );-- cy.button("New segment").click();-- cy.findByTestId("segment-editor").findByText("Select a table").click();- H.pickEntity({ path: ["Databases", /Sample Database/, "Orders"] });-- cy.findByTestId("segment-editor").findByText("Orders").should("exist");-- cy.findByTestId("segment-editor")- .findByText("Add filters to narrow your answer")- .click();-- cy.log("Fails in v0.36.0 and v0.36.3. It exists in v0.35.4");- H.popover().findByText("Custom Expression");- });-it("should show no segments", () => {cy.visit("/reference/segments");@@ -44,13 +21,18 @@ describe("scenarios > admin > datamodel > segments", () => {cy.button("Learn how to create segments").should("be.visible");});- it("should track segment_created event when saving a new segment", () => {+ it("should have 'Custom Expression' in a filter list and track segment_created event when saving a new segment (metabase#13069)", () => {cy.intercept("POST", "/api/segment").as("createSegment");cy.intercept("GET", `/api/table/${ORDERS_ID}/query_metadata`).as("getTable",);cy.visit("/admin/datamodel/segments");+ cy.log("should initially show no segments in UI");+ cy.get("main").findByText(+ "Create segments to add them to the Filter dropdown in the query builder",+ );+cy.button("New segment").click();cy.log("verify segment_create_started event was tracked");@@ -62,6 +44,7 @@ describe("scenarios > admin > datamodel > segments", () => {cy.findByTestId("segment-editor").findByText("Select a table").click();H.pickEntity({ path: ["Databases", /Sample Database/, "Orders"] });cy.wait("@getTable");+ cy.findByTestId("segment-editor").findByText("Orders").should("exist");cy.log("add filter");// The "Add filters" button stays disabled until the segment query is built@@ -71,6 +54,12 @@ describe("scenarios > admin > datamodel > segments", () => {.findByRole("button", { name: /Add filters to narrow your answer/ }).should("be.enabled").click();++ cy.log(+ "should have 'Custom Expression' in a filter list (metabase#13069). Fails in v0.36.0 and v0.36.3. It exists in v0.35.4",+ );+ H.popover().findByText("Custom Expression").should("exist");+H.popover().findByText("Total").click();H.selectFilterOperator("Greater than");H.popover().within(() => {@@ -120,7 +109,7 @@ describe("scenarios > admin > datamodel > segments", () => {});});- it("should show the segment fields list and detail view", () => {+ it("should show the segment fields list and detail view, and not crash when editing a field in segment field detail page (metabase#55322)", () => {// In the listcy.visit("/reference/segments");@@ -145,9 +134,10 @@ describe("scenarios > admin > datamodel > segments", () => {.eq(0).scrollIntoView().should("be.visible");- });- it("should not crash when editing field in segment field detail page (metabase#55322)", () => {+ cy.log(+ "should not crash when editing field in segment field detail page (metabase#55322)",+ );cy.get("@segmentId").then((segmentId) => {cy.visit(`/reference/segments/${segmentId}/fields/${ORDERS.TAX}`);});@@ -158,32 +148,6 @@ describe("scenarios > admin > datamodel > segments", () => {cy.get("main").findByText("Something’s gone wrong").should("not.exist");});- it("should show up in UI list and should show the segment details of a specific id", () => {- cy.visit("/admin/datamodel/segments");-- cy.findByRole("table").within(() => {- cy.findByText("Filtered by Total is less than 100").should(- "be.visible",- );- cy.findByText("Sample Database").should("be.visible");- cy.findByText("Orders").should("be.visible");- });- cy.findByRole("link", { name: /Orders < 100/ })- .should("be.visible")- .click();-- cy.get("form").within(() => {- cy.findByText("Edit Your Segment").should("be.visible");- cy.findByText("Sample Database").should("be.visible");- cy.findByText("Orders").should("be.visible");- });- cy.findByPlaceholderText("Something descriptive but not too long").should(- "have.value",- SEGMENT_NAME,- );- cy.findByRole("link", { name: "Preview" }).should("be.visible");- });-it("should see a newly asked question in its questions list", () => {cy.intercept("GET", "/api/table/*/query_metadata*").as("metadata");// Ask question@@ -217,7 +181,35 @@ describe("scenarios > admin > datamodel > segments", () => {.should("be.visible");});- it("should update that segment", () => {+ it("should show up in UI list, show the segment details of a specific id, and update that segment", () => {+ cy.log(+ "should show up in UI list and should show the segment details of a specific id",+ );+ cy.visit("/admin/datamodel/segments");++ cy.findByRole("table").within(() => {+ cy.findByText("Filtered by Total is less than 100").should(+ "be.visible",+ );+ cy.findByText("Sample Database").should("be.visible");+ cy.findByText("Orders").should("be.visible");+ });+ cy.findByRole("link", { name: /Orders < 100/ })+ .should("be.visible")+ .click();++ cy.get("form").within(() => {+ cy.findByText("Edit Your Segment").should("be.visible");+ cy.findByText("Sample Database").should("be.visible");+ cy.findByText("Orders").should("be.visible");+ });+ cy.findByPlaceholderText("Something descriptive but not too long").should(+ "have.value",+ SEGMENT_NAME,+ );+ cy.findByRole("link", { name: "Preview" }).should("be.visible");++ cy.log("should update that segment");cy.visit("/admin");cy.findByTestId("admin-navbar-items").contains("Table Metadata").click();cy.findByRole("link", { name: /Segments/ }).click();diff --git a/e2e/test/scenarios/admin-2/error-reporting.cy.spec.ts b/e2e/test/scenarios/admin/error-reporting.cy.spec.tssimilarity index 85%rename from e2e/test/scenarios/admin-2/error-reporting.cy.spec.tsrename to e2e/test/scenarios/admin/error-reporting.cy.spec.tsindex 4f109973022..ca09d8e9d0a 100644--- a/e2e/test/scenarios/admin-2/error-reporting.cy.spec.ts+++ b/e2e/test/scenarios/admin/error-reporting.cy.spec.ts@@ -128,39 +128,6 @@ describe("error reporting modal", () => {});});- it("can include query data on question pages", () => {- cy.signInAsAdmin();- H.createQuestion(- {- name: "Diagnostic Question 1",- query: { "source-table": 1, limit: 10 },- },- { visitQuestion: true },- );-- H.tableInteractive().realClick();- cy.realPress(["Control", "F1"]);-- H.modal().within(() => {- cy.findByText("Gather diagnostic information").should("be.visible");- cy.findByLabelText("Query results").should("not.be.checked");- cy.findByLabelText("Query results").click(); // off by default- cy.findByLabelText("Query results").should("be.checked");- cy.button(/Download/i).click();- });-- getDiagnosticInfoFile().then((fileContent) => {- expect(fileContent.entityName).to.equal("question");- expect(fileContent).to.have.property("frontendErrors");- expect(fileContent).to.have.property("backendErrors");- expect(fileContent).to.have.property("userLogs");- expect(fileContent).to.have.property("logs");- expect(fileContent).to.have.property("bugReportDetails");- expect(fileContent).to.have.property("entityInfo");- expect(fileContent).to.have.property("queryResults");- });- });-it("should include the hydrated dashboard definition for a dashboard", () => {cy.signInAsAdmin();H.visitDashboard(ORDERS_DASHBOARD_ID);diff --git a/e2e/test/scenarios/admin/help.cy.spec.ts b/e2e/test/scenarios/admin/help.cy.spec.tsindex ce746c571d9..d2987f7a197 100644--- a/e2e/test/scenarios/admin/help.cy.spec.ts+++ b/e2e/test/scenarios/admin/help.cy.spec.ts@@ -24,27 +24,6 @@ describe("scenarios > admin > help", { tags: "@OSS" }, () => {});});-describe("scenarios > admin > help (EE)", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- H.activateToken("pro-self-hosted");- });-- it("should link `Get Help` to help-premium", () => {- cy.visit("/admin/help");-- cy.findByTestId("admin-layout-content")- .findByText("Get help")- .parents("a")- .should("have.prop", "href")- .and(- "match",- /^https:\/\/www\.metabase\.com\/help-premium\?utm_source=in-product&utm_medium=troubleshooting&utm_campaign=help&instance_version=v.+&diag=%7B.+%7D$/,- );- });-});-describe("scenarios > admin > help > helping hand", () => {const executeCreateGrantAccessFlow = (durationOption?: "96 hours" | "48 hours" | "24 hours",@@ -89,7 +68,7 @@ describe("scenarios > admin > help > helping hand", () => {H.mockSessionPropertiesTokenFeatures({ "support-users": true });});- it("should only display the `Helping hand` section for cloud customers", () => {+ it("should only display the `Helping hand` section for cloud customers, and link `Get help` to help-premium on paid plans", () => {cy.visit("/admin/help");cy.findByRole("heading", { name: "Helping hand" }).should("not.exist");@@ -97,6 +76,16 @@ describe("scenarios > admin > help > helping hand", () => {cy.reload();cy.findByRole("heading", { name: "Helping hand" }).should("not.exist");+ cy.log("should link `Get help` to help-premium");+ cy.findByTestId("admin-layout-content")+ .findByText("Get help")+ .parents("a")+ .should("have.prop", "href")+ .and(+ "match",+ /^https:\/\/www\.metabase\.com\/help-premium\?utm_source=in-product&utm_medium=troubleshooting&utm_campaign=help&instance_version=v.+&diag=%7B.+%7D$/,+ );+H.activateToken("starter");cy.reload();cy.findByRole("heading", { name: "Helping hand" }).should("be.visible");@@ -106,20 +95,6 @@ describe("scenarios > admin > help > helping hand", () => {cy.findByRole("heading", { name: "Helping hand" }).should("be.visible");});- it("should allow creating a new access grant", () => {- H.activateToken("pro-cloud");- cy.visit("/admin/help");-- cy.findByTestId("access-grant-list-table").should("not.exist");-- executeCreateGrantAccessFlow();-- cy.findByTestId("access-grant-list-table").should("be.visible");- cy.findByTestId("access-grant-list-table").within(() => {- cy.get("tbody").findAllByRole("row").should("have.length", 1);- });- });-it("allow creating an access grant with a ticket number and custom notes", () => {H.activateToken("pro-cloud");cy.visit("/admin/help");@@ -136,26 +111,28 @@ describe("scenarios > admin > help > helping hand", () => {});});- it("should disallow more than one active access grant", () => {+ it("should allow creating a new access grant, disallow more than one active access grant, and revoke it", () => {H.activateToken("pro-cloud");cy.visit("/admin/help");+ cy.findByTestId("access-grant-list-table").should("not.exist");+executeCreateGrantAccessFlow();+ cy.log("should allow creating a new access grant");+ cy.findByTestId("access-grant-list-table").should("be.visible");+ cy.findByTestId("access-grant-list-table").within(() => {+ cy.get("tbody").findAllByRole("row").should("have.length", 1);+ });++ cy.log("should disallow more than one active access grant");cy.button("Request a helping hand").should("be.disabled");cy.button("Request a helping hand").siblings().findByText("You can only have one active request at a time").should("be.visible");- });-- it("can revoke an access grant", () => {- H.activateToken("pro-cloud");- cy.visit("/admin/help");-- executeCreateGrantAccessFlow();- cy.button("Request a helping hand").should("be.disabled");+ cy.log("can revoke an access grant");H.undoToast().icon("close").click();cy.findByTestId("access-grant-list-table")diff --git a/e2e/test/scenarios/admin/i18n/content-translation/dashboards.cy.spec.ts b/e2e/test/scenarios/admin/i18n/content-translation/dashboards.cy.spec.tsindex cf1c1df67d4..999f0239db1 100644--- a/e2e/test/scenarios/admin/i18n/content-translation/dashboards.cy.spec.ts+++ b/e2e/test/scenarios/admin/i18n/content-translation/dashboards.cy.spec.ts@@ -73,7 +73,7 @@ describe("scenarios > content translation > static embeds > dashboards", () => {});});- it("should assign the proper colors to a pie", () => {+ it("should translate the renamed column title of a pivot table", () => {H.createDashboard({name: "the_dashboard",}).then(({ body: { id: dashboardId } }) => {@@ -1044,21 +1044,19 @@ describe("scenarios > content translation > static embeds > dashboards", () => {};});- it("should translate text in dashboard tab names", () => {+ it("should translate dashboard tab names, heading cards and text cards", () => {visitEmbeddedDashboard();++ cy.log("tab names");cy.findByRole("tab", { name: "Reiter 1" }).should("be.visible");cy.findByRole("tab", { name: "Reiter 2" }).should("be.visible");- });- it("should translate content in heading cards", () => {- visitEmbeddedDashboard();+ cy.log("heading cards");H.getDashboardCard(0).findByText(/Beispielüberschrift/).should("be.visible");- });- it("should translate content in text cards", () => {- visitEmbeddedDashboard();+ cy.log("text cards");H.getDashboardCard(1).findByText(/Beispieltext/).should("be.visible");@@ -1077,8 +1075,6 @@ describe("scenarios > content translation > static embeds > dashboards", () => {});});- describe("Boolean content", () => {});-describe("funnel chart with translated dimension values (metabase#71488)", () => {beforeEach(() => {H.restore();diff --git a/e2e/test/scenarios/admin/i18n/content-translation/helpers/constants.ts b/e2e/test/scenarios/admin/i18n/content-translation/helpers/constants.tsindex dacf9e5cb85..a412c60b297 100644--- a/e2e/test/scenarios/admin/i18n/content-translation/helpers/constants.ts+++ b/e2e/test/scenarios/admin/i18n/content-translation/helpers/constants.ts@@ -60,9 +60,6 @@ export const nonAsciiFieldNames: DictionaryArray = [export const columnNamesWithTypeText = ["Title", "Category", "Vendor"];-export const invalidLocaleXX = clone(germanFieldNames);-invalidLocaleXX[0].locale = "xx";-export const multipleInvalidLocales = clone(germanFieldNames);multipleInvalidLocales[0].locale = "ze";multipleInvalidLocales[3].locale = "qe";diff --git a/e2e/test/scenarios/admin/i18n/content-translation/upload-and-download.cy.spec.ts b/e2e/test/scenarios/admin/i18n/content-translation/upload-and-download.cy.spec.tsindex 1803cfa864e..9d49aa43019 100644--- a/e2e/test/scenarios/admin/i18n/content-translation/upload-and-download.cy.spec.ts+++ b/e2e/test/scenarios/admin/i18n/content-translation/upload-and-download.cy.spec.ts@@ -7,7 +7,6 @@ import {import {germanFieldNames,- invalidLocaleXX,multipleInvalidLocales,nonAsciiFieldNames,portugueseFieldNames,@@ -70,17 +69,11 @@ describe("scenarios > admin > embedding > guest embeds> content translation", ()});describe("The translation upload form", () => {- it("accepts a CSV upload with ASCII characters", () => {- uploadTranslationDictionary(germanFieldNames);- cy.findByRole("status").findByText("Dictionary uploaded");- cy.findByTestId("content-localization-setting").findByText(- "Dictionary uploaded",- );- assertOnlyTheseTranslationsAreStored(germanFieldNames);- });-- it("accepts a CSV upload with non-ASCII characters", () => {- uploadTranslationDictionary(nonAsciiFieldNames);+ it("accepts a CSV upload with non-ASCII characters and hyphenated locales", () => {+ uploadTranslationDictionary([+ ...nonAsciiFieldNames,+ ...portugueseFieldNames,+ ]);cy.findByTestId("content-localization-setting").findByText("Dictionary uploaded",);@@ -90,14 +83,8 @@ describe("scenarios > admin > embedding > guest embeds> content translation", ()locale,);});- });- it("accepts a CSV upload with a hyphenated locale", () => {- uploadTranslationDictionary(portugueseFieldNames);- cy.findByTestId("content-localization-setting").findByText(- "Dictionary uploaded",- );- cy.signInAsNormalUser();+ cy.log("accepts a CSV upload with a hyphenated locale (pt-BR)");assertOnlyTheseTranslationsAreStored(portugueseFieldNames, "pt-BR");});@@ -143,44 +130,48 @@ describe("scenarios > admin > embedding > guest embeds> content translation", ().should("exist");});- it("rejects a CSV upload with invalid locale in one row", () => {- uploadTranslationDictionary(invalidLocaleXX);- cy.findAllByRole("alert")- .contains(/couldn.*t upload the file/)- .should("exist");- cy.findAllByRole("alert")- .contains(/Row 2: Invalid locale: xx/)- .should("exist");- });-- it("erases previously stored translations when a new CSV is uploaded", () => {+ it("accepts a CSV upload with ASCII characters, and erases previously stored translations when a new CSV is uploaded", () => {uploadTranslationDictionary(germanFieldNames);++ cy.log("accepts a CSV upload with ASCII characters");+ cy.findByRole("status").findByText("Dictionary uploaded");+ cy.findByTestId("content-localization-setting").findByText(+ "Dictionary uploaded",+ );assertOnlyTheseTranslationsAreStored(germanFieldNames).then(() => {+ cy.log(+ "erases previously stored translations when a new CSV is uploaded",+ );const oneArabicFieldName = [nonAsciiFieldNames[0]];uploadTranslationDictionary(oneArabicFieldName);assertOnlyTheseTranslationsAreStored(oneArabicFieldName, "ar");++ cy.log("the German translations from the first upload are gone");+ assertOnlyTheseTranslationsAreStored([], "de");});});- it("does not erase previously stored translations when an upload fails", () => {+ it("rejects a CSV upload with invalid locales in multiple rows, without erasing previously stored translations", () => {uploadTranslationDictionary(germanFieldNames);assertOnlyTheseTranslationsAreStored(germanFieldNames);- uploadTranslationDictionary(invalidLocaleXX);- assertOnlyTheseTranslationsAreStored(germanFieldNames);- });-- it("rejects a CSV upload with invalid locales in multiple rows", () => {uploadTranslationDictionary(multipleInvalidLocales);++ cy.log("rejects a CSV upload with invalid locales in multiple rows");cy.findAllByRole("alert").contains(/couldn.*t upload the file/).should("exist");cy.log("The first error is in row 2 (the first row is the header)");cy.findAllByRole("alert")- .contains(/Row 2: Invalid locale/)+ .contains(/Row 2: Invalid locale: ze/).should("exist");cy.findAllByRole("alert")- .contains(/Row 5: Invalid locale/)+ .contains(/Row 5: Invalid locale: qe/).should("exist");++ cy.log(+ "does not erase previously stored translations when an upload fails",+ );+ assertOnlyTheseTranslationsAreStored(germanFieldNames);});it("rejects, in the frontend, a CSV upload that is too big", () => {diff --git a/e2e/test/scenarios/admin-2/multi-factor-auth.cy.spec.ts b/e2e/test/scenarios/admin/multi-factor-auth.cy.spec.tssimilarity index 89%rename from e2e/test/scenarios/admin-2/multi-factor-auth.cy.spec.tsrename to e2e/test/scenarios/admin/multi-factor-auth.cy.spec.tsindex c8716461b45..c5fa2656b50 100644--- a/e2e/test/scenarios/admin-2/multi-factor-auth.cy.spec.ts+++ b/e2e/test/scenarios/admin/multi-factor-auth.cy.spec.ts@@ -32,36 +32,34 @@ describe("scenarios > admin > settings > multi-factor authentication", () => {describe("optional", () => {describe("admin settings", () => {- it("admin can enable and disable 2FA in authentication settings", () => {+ it("admin can search the users-without-2FA list and remove a user's enrollment to unlock them", () => {+ enableMfa();+ enrollUser();++ cy.signInAsAdmin();cy.visit("/admin/settings/authentication");- mfaSetting().scrollIntoView();- mfaSetting()- .findByText("Two-factor authentication")- .should("be.visible");- mfaToggle().should("not.be.checked").click();- cy.wait("@updateSettings");- mfaSetting()- .should("contain", "0 enrolled users")- .and("contain", "users without 2FA");- cy.log("Enabling it leaves enforcement optional");- enforcementOption("Don't require").should("be.checked");+ cy.log("Admin searches the users-without-2FA list");+ mfaSetting()+ .scrollIntoView()+ .findByText(/users? without 2FA/)+ .click();- cy.log("Disable it again");- mfaToggle().should("be.checked").click();- cy.wait("@updateSettings");- mfaToggle().should("not.be.checked");- mfaSetting().should("not.contain", "enrolled");- });+ cy.log(+ "The enrolled user is absent — they already have a second factor",+ );+ unenrolledUsersTable().should("contain", nodata.email);+ unenrolledUsersTable().should("not.contain", normal.email);- it("admin can remove a user's enrollment to unlock them", () => {- enableMfa();- enrollUser();+ cy.log("Searching narrows to a single person");+ cy.findByPlaceholderText("Search…").type(admin.first_name);+ unenrolledUsersTable()+ .should("contain", admin.email)+ .and("not.contain", nodata.email);cy.log("Admin drills into the enrolled list from the count on the card",);- cy.signInAsAdmin();cy.visit("/admin/settings/authentication");mfaSetting().scrollIntoView().findByText("1 enrolled user").click();@@ -97,30 +95,6 @@ describe("scenarios > admin > settings > multi-factor authentication", () => {cy.findByTestId("greeting-message").should("be.visible");cy.url().should("not.contain", "/auth/login");});-- it("admin can search the users-without-2FA list", () => {- enableMfa();- enrollUser();-- cy.signInAsAdmin();- cy.visit("/admin/settings/authentication");- mfaSetting()- .scrollIntoView()- .findByText(/users? without 2FA/)- .click();-- cy.log(- "The enrolled user is absent — they already have a second factor",- );- unenrolledUsersTable().should("not.contain", normal.email);-- cy.log("Searching narrows to a single person");- unenrolledUsersTable().should("contain", nodata.email);- cy.findByPlaceholderText("Search…").type(admin.first_name);- unenrolledUsersTable()- .should("contain", admin.email)- .and("not.contain", nodata.email);- });});describe("enrollment", () => {@@ -355,11 +329,14 @@ describe("scenarios > admin > settings > multi-factor authentication", () => {describe("required", () => {describe("admin", () => {- it("allows user to set mfa to required, sets default grace period", () => {+ it("admin can enable and disable 2FA, and set it to required with a default grace period", () => {const deadline = dayjs().add(GRACE_PERIOD_DAYS, "day");cy.visit("/admin/settings/authentication");mfaSetting().scrollIntoView();+ mfaSetting()+ .findByText("Two-factor authentication")+ .should("be.visible");cy.log("Enforcement and the deadline only exist once 2FA is allowed");mfaSetting().should("not.contain", "Require now");@@ -367,6 +344,12 @@ describe("scenarios > admin > settings > multi-factor authentication", () => {mfaToggle().should("not.be.checked").click();cy.wait("@updateSettings");+ mfaSetting()+ .should("contain", "0 enrolled users")+ .and("contain", "users without 2FA");++ cy.log("Enabling it leaves enforcement optional");+ enforcementOption("Don't require").should("be.checked");// Because the admin has not enrolled, they cannot set two factor to requiredenforcementOption("Require by a certain date").should("be.disabled");@@ -374,6 +357,17 @@ describe("scenarios > admin > settings > multi-factor authentication", () => {.findByText(/account before requiring it/).should("be.visible");+ cy.log("Admin can disable 2FA again");+ mfaToggle().should("be.checked").click();+ cy.wait("@updateSettings");+ mfaToggle().should("not.be.checked");+ mfaSetting().should("not.contain", "enrolled");++ cy.log("Allow 2FA again so the admin can enroll");+ mfaToggle().click();+ cy.wait("@updateSettings");+ mfaToggle().should("be.checked");+enrollUser("admin");cy.reload();@@ -413,70 +407,86 @@ describe("scenarios > admin > settings > multi-factor authentication", () => {);});- it("should immediately invalidate current LDAP sessions when enforcement is required", () => {- H.setupLdap();- signInWithLdap();- cy.findByTestId("greeting-message").should("be.visible");- H.openNavigationSidebar();- H.navigationSidebar()- .findByText("Your personal collection")- .should("be.visible");+ it(+ "should immediately invalidate current LDAP sessions when enforcement is required",+ { tags: "@external" },+ () => {+ H.setupLdap();+ signInWithLdap();+ cy.findByTestId("greeting-message").should("be.visible");+ H.openNavigationSidebar();+ H.navigationSidebar()+ .findByText("Your personal collection")+ .should("be.visible");- cy.log("An admin turns enforcement on part-way through their session");- cy.task("requestAsAdmin", {- method: "PUT",- url: "/api/setting",- body: {- "mfa-enforcement": "required",- "mfa-requirement-deadline": null,- },- });+ cy.log(+ "An admin turns enforcement on part-way through their session",+ );+ cy.task("requestAsAdmin", {+ method: "PUT",+ url: "/api/setting",+ body: {+ "mfa-enforcement": "required",+ "mfa-requirement-deadline": null,+ },+ });- cy.log("next api request should return unauthenticated");- H.navigationSidebar().findByText("Your personal collection").click();+ cy.log("next api request should return unauthenticated");+ H.navigationSidebar().findByText("Your personal collection").click();- cy.log("should be brought to login screen");- cy.findByRole("heading", { name: "Sign in to Metabase" }).should(- "be.visible",- );- });+ cy.log("should be brought to login screen");+ cy.findByRole("heading", { name: "Sign in to Metabase" }).should(+ "be.visible",+ );+ },+ );- it("should not invalidate sessions created via SAML, even when enforcement is required", () => {- H.setupSaml();- createSamlUser();+ it(+ "should not invalidate sessions created via SAML, even when enforcement is required",+ { tags: "@external" },+ () => {+ H.setupSaml();+ createSamlUser();- cy.signOut();- cy.visit("/auth/login");- cy.button("Sign in with SSO").click();+ cy.signOut();+ cy.visit("/auth/login");+ cy.button("Sign in with SSO").click();- cy.log("The IdP takes over — any password works, the domain is fixed");- cy.get("#username").type(SAML_USER.username);- cy.get("#domain").select(SAML_USER.domain);- cy.get("#password").type("anything");- cy.get("button").click();+ cy.log(+ "The IdP takes over — any password works, the domain is fixed",+ );+ cy.get("#username").type(SAML_USER.username);+ cy.get("#domain").select(SAML_USER.domain);+ cy.get("#password").type("anything");+ cy.get("button").click();- cy.log("Straight in: SSO providers are exempt from the MFA gate");- cy.findByTestId("greeting-message").should("be.visible");+ cy.log("Straight in: SSO providers are exempt from the MFA gate");+ cy.findByTestId("greeting-message").should("be.visible");- cy.log("An admin turns enforcement on part-way through their session");- cy.task("requestAsAdmin", {- method: "PUT",- url: "/api/setting",- body: {- "mfa-enforcement": "required",- "mfa-requirement-deadline": null,- },- });+ cy.log(+ "An admin turns enforcement on part-way through their session",+ );+ cy.task("requestAsAdmin", {+ method: "PUT",+ url: "/api/setting",+ body: {+ "mfa-enforcement": "required",+ "mfa-requirement-deadline": null,+ },+ });- cy.log("The SAML session survives — the IdP owns MFA for those users");- H.navigationSidebar().findByText("Our analytics").click();- H.collectionTable().findByText("Orders, Count").click();- cy.location("pathname").should(- "contain",- `/question/${ORDERS_COUNT_QUESTION_ID}`,- );- cy.findByTestId("login-page").should("not.exist");- });+ cy.log(+ "The SAML session survives — the IdP owns MFA for those users",+ );+ H.navigationSidebar().findByText("Our analytics").click();+ H.collectionTable().findByText("Orders, Count").click();+ cy.location("pathname").should(+ "contain",+ `/question/${ORDERS_COUNT_QUESTION_ID}`,+ );+ cy.findByTestId("login-page").should("not.exist");+ },+ );});describe("login", () => {diff --git a/e2e/test/scenarios/admin/oauth-authorizations.cy.spec.ts b/e2e/test/scenarios/admin/oauth-authorizations.cy.spec.tsindex 36913f4508c..6c8cf7ed054 100644--- a/e2e/test/scenarios/admin/oauth-authorizations.cy.spec.ts+++ b/e2e/test/scenarios/admin/oauth-authorizations.cy.spec.ts@@ -23,7 +23,7 @@ describe("scenarios > admin > metabot > oauth authorizations", () => {cy.signInAsAdmin();});- it("lists registration, approval, and denial events with client and user details", () => {+ it("lists registration, approval, and denial events with client and user details, and filters events by type via the API", () => {registerClient("E2E MCP Client A");registerClient("E2E MCP Client B", {token_endpoint_auth_method: "client_secret_basic",@@ -32,8 +32,13 @@ describe("scenarios > admin > metabot > oauth authorizations", () => {token_endpoint_auth_method: "client_secret_basic",}).then(denyClient);+ cy.intercept("GET", "/api/oauth/authorizations*").as("list");cy.visit(PATH);+ cy.wait("@list");+ cy.log(+ "lists registration, approval, and denial events with client and user details",+ );// Every client's registration row renders, and each decision event lands in the same row as// its client (and the deciding user). Client A's row also shows the registered redirect URI.assertEventRow("E2E MCP Client A", "Registered", REDIRECT_URI);@@ -41,17 +46,8 @@ describe("scenarios > admin > metabot > oauth authorizations", () => {assertEventRow("E2E MCP Client C", "Registered");assertEventRow("E2E MCP Client B", "Approved", USERS.admin.email);assertEventRow("E2E MCP Client C", "Denied", USERS.admin.email);- });-- it("filters events by type via the API", () => {- registerClient("E2E Filter Client", {- token_endpoint_auth_method: "client_secret_basic",- }).then(approveClient);-- cy.intercept("GET", "/api/oauth/authorizations*").as("list");- cy.visit(PATH);- cy.wait("@list");+ cy.log("filters events by type via the API");cy.findByLabelText("Filter by event").click();cy.findByRole("option", { name: "Approved" }).click();diff --git a/e2e/test/scenarios/admin-2/people.cy.spec.js b/e2e/test/scenarios/admin/people.cy.spec.jssimilarity index 91%rename from e2e/test/scenarios/admin-2/people.cy.spec.jsrename to e2e/test/scenarios/admin/people.cy.spec.jsindex 6f808644c8f..17799a1d535 100644--- a/e2e/test/scenarios/admin-2/people.cy.spec.js+++ b/e2e/test/scenarios/admin/people.cy.spec.js@@ -35,13 +35,28 @@ describe("scenarios > admin > people", () => {});describe("user management", () => {- it("should be possible to switch beteween 'People' and 'Groups' tabs and to add/remove users to groups (metabase-enterprise#210, metabase#12693, metabase#21521)", () => {+ it("should be possible to search people, switch between 'People' and 'Groups' tabs and add/remove users to groups (metabase-enterprise#210, metabase#12693, metabase#21521)", () => {cy.visit("/admin/people");assertTableRowsCount(TOTAL_USERS);// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText(`${TOTAL_USERS} people found`);+ cy.log("should allow to search people");+ cy.findByPlaceholderText("Find someone").type("no");+ cy.findByTestId("people-list-footer").findByText("6 people found");+ assertTableRowsCount(6);++ cy.findByPlaceholderText("Find someone").type("ne");+ cy.findByTestId("people-list-footer").findByText("1 person found");+ assertTableRowsCount(1);++ cy.findByPlaceholderText("Find someone").clear();+ cy.findByTestId("people-list-footer").findByText(+ `${TOTAL_USERS} people found`,+ );+ assertTableRowsCount(TOTAL_USERS);+// A small sidebar selectorcy.findByTestId("admin-layout-sidebar").within(() => {cy.contains("People").should("have.attr", "data-active", "true");@@ -168,11 +183,17 @@ describe("scenarios > admin > people", () => {cy.findByText(email);});- it("should disallow admin to create new users with case mutation of existing user", () => {+ it("should disallow admin to create new users with case mutation of existing user, with the 'Invite someone' button usable on smaller screen sizes (metabase#16350)", () => {+ cy.log(+ "'Invite someone' button shouldn't be covered/blocked on smaller screen sizes (metabase#16350)",+ );+ cy.viewport(1000, 600);+const { first_name, last_name, email } = normal;cy.visit("/admin/people");clickButton("Invite someone");+ // Modal should appear with the following input fieldcy.findByLabelText("First name").type(first_name + "New");cy.findByLabelText("Last name").type(last_name + "New");cy.findByLabelText(/Email/).type(email.toUpperCase());@@ -215,26 +236,7 @@ describe("scenarios > admin > people", () => {});});- it("'Invite someone' button shouldn't be covered/blocked on smaller screen sizes (metabase#16350)", () => {- cy.viewport(1000, 600);-- cy.visit("/admin/people");- cy.button("Invite someone").click();- // Modal should appear with the following input field- cy.findByLabelText("First name");- });-- it("should disallow admin to deactivate themselves", () => {- cy.visit("/admin/people");- showUserOptions(adminUserName);- H.popover().within(() => {- cy.findByText("Edit user");- cy.findByText("Reset password");- cy.findByText("Deactivate user").should("not.exist");- });- });-- it("should allow admin to deactivate and reactivate other admins/users", () => {+ it("should disallow admin to deactivate themselves, and allow admin to deactivate and reactivate other admins/users", () => {// Turn a random existing user into an admincy.request("PUT", `/api/user/${NORMAL_USER_ID}`, {is_superuser: true,@@ -242,6 +244,20 @@ describe("scenarios > admin > people", () => {const FULL_NAME = H.getFullName(user);cy.visit("/admin/people");++ cy.log("should disallow admin to deactivate themselves");+ showUserOptions(adminUserName);+ H.popover().within(() => {+ cy.findByText("Edit user");+ cy.findByText("Reset password");+ cy.findByText("Deactivate user").should("not.exist");+ });+ cy.realPress("Escape");+ H.menu().should("not.exist");++ cy.log(+ "should allow admin to deactivate and reactivate other admins/users",+ );showUserOptions(FULL_NAME);cy.findByText("Deactivate user").click();@@ -289,8 +305,39 @@ describe("scenarios > admin > people", () => {);});- it("should reset user password without SMTP set up", () => {+ it("should generate a password reset link and reset user password without SMTP set up", () => {+ cy.intercept("POST", "/api/user/*/password-reset-url").as("getResetUrl");+cy.visit("/admin/people");++ cy.log("should generate a password reset link without SMTP set up");+ showUserOptions(normalUserName);+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage+ cy.findByText("Reset password").click();++ H.modal().within(() => {+ cy.findByText(`Reset ${normalUserName}'s password?`);+ cy.button("Get reset link").click();+ });++ cy.wait("@getResetUrl");++ H.modal().within(() => {+ cy.findByText(`Password reset link for ${normalUserName}`);+ cy.findByText(+ "Share this link with the user. It will expire in 48 hours.",+ );+ cy.findByRole("textbox")+ .invoke("val")+ .should("contain", "reset_password");+ cy.button("Done").click();+ });++ cy.location().should((loc) =>+ expect(loc.pathname).to.eq("/admin/people"),+ );++ cy.log("should reset user password without SMTP set up");showUserOptions(normalUserName);// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText("Reset password").click();@@ -328,53 +375,6 @@ describe("scenarios > admin > people", () => {);});- it("should generate a password reset link without SMTP set up", () => {- cy.intercept("POST", "/api/user/*/password-reset-url").as("getResetUrl");-- cy.visit("/admin/people");- showUserOptions(normalUserName);- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Reset password").click();-- H.modal().within(() => {- cy.findByText(`Reset ${normalUserName}'s password?`);- cy.button("Get reset link").click();- });-- cy.wait("@getResetUrl");-- H.modal().within(() => {- cy.findByText(`Password reset link for ${normalUserName}`);- cy.findByText(- "Share this link with the user. It will expire in 48 hours.",- );- cy.findByRole("textbox")- .invoke("val")- .should("contain", "reset_password");- cy.button("Done").click();- });-- cy.location().should((loc) =>- expect(loc.pathname).to.eq("/admin/people"),- );- });-- it("should not offer to reset passwords when password login is disabled", () => {- H.activateToken("pro-self-hosted");- cy.request("PUT", "/api/google/settings", {- "google-auth-auto-create-accounts-domain": null,- "google-auth-client-id": "example1.apps.googleusercontent.com",- "google-auth-enabled": true,- });-- cy.request("PUT", "/api/setting", {- "enable-password-login": false,- });- cy.visit("/admin/people");- showUserOptions(normalUserName);- H.popover().findByText("Reset password").should("not.exist");- });-it("should reset user password with SMTP set up",{ tags: "@external" },@@ -412,30 +412,13 @@ describe("scenarios > admin > people", () => {},);- it("should allow to search people", () => {- cy.visit("/admin/people");-- cy.findByPlaceholderText("Find someone").type("no");- cy.findByTestId("people-list-footer").findByText("6 people found");- assertTableRowsCount(6);-- cy.findByPlaceholderText("Find someone").type("ne");- cy.findByTestId("people-list-footer").findByText("1 person found");- assertTableRowsCount(1);-- cy.findByPlaceholderText("Find someone").clear();- cy.findByTestId("people-list-footer").findByText(- `${TOTAL_USERS} people found`,- );- assertTableRowsCount(TOTAL_USERS);- });-- it("should allow group creation and deletion", () => {+ it("should allow group creation and deletion, and display api keys included in a group with a warning when deleting the group", () => {const longGroupName ="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";cy.intercept("POST", "/api/permissions/group").as("createGroup");cy.intercept("DELETE", "/api/permissions/group/*").as("deleteGroup");+ H.createApiKey("MyApiKey", COLLECTION_GROUP_ID);cy.visit("/admin/people/groups");cy.wait(["@getGroups", "@listApiKeys"]);@@ -484,13 +467,10 @@ describe("scenarios > admin > people", () => {cy.findByTestId("admin-panel").findByText("My New Group").should("not.exist");- });-- it("should display api keys included in a group and display a warning when deleting the group", () => {- H.createApiKey("MyApiKey", COLLECTION_GROUP_ID);- cy.visit("/admin/people/groups");- cy.wait(["@getGroups", "@listApiKeys"]);+ cy.log(+ "should display api keys included in a group and display a warning when deleting the group",+ );cy.findByTestId("admin-panel").findByText("collection").closest("tr")@@ -528,7 +508,7 @@ describe("scenarios > admin > people", () => {setupGoogleAuth();});- it("invite member when SSO is not configured", () => {+ it("invite member when Google SSO is configured but password login is still enabled", () => {const { first_name, last_name, email } = TEST_USER;const FULL_NAME = `${first_name} ${last_name}`;cy.visit("/admin/people");@@ -567,7 +547,7 @@ describe("scenarios > admin > people", () => {cy.intercept("GET", "/api/permissions/membership").as("memberships");});- it("should allow paginating people forward and backward", () => {+ it("should allow paginating people and group members forward and backward", () => {const PAGE_SIZE = 25;const footer = () =>@@ -607,25 +587,24 @@ describe("scenarios > admin > people", () => {assertTableRowsCount(PAGE_SIZE);footer().should("contain", `1 - ${PAGE_SIZE}`);- });- it("should allow paginating group members forward and backward", () => {- const PAGE_SIZE = 25;- cy.visit(`admin/people/groups/${ALL_USERS_GROUP}`);+ cy.log("should allow paginating group members forward and backward");+ cy.visit(`/admin/people/groups/${ALL_USERS_GROUP}`);// Total- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText(`${NEW_TOTAL_USERS} members`);+ cy.findByTestId("admin-layout-content").findByText(+ `${NEW_TOTAL_USERS} members`,+ );// Page 1- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText(`1 - ${PAGE_SIZE}`);+ cy.findByTestId("admin-layout-content").findByText(`1 - ${PAGE_SIZE}`);assertTableRowsCount(PAGE_SIZE);cy.findByLabelText("Previous page").should("be.disabled");cy.findByLabelText("Next page").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Loading...").should("not.exist");+ cy.findByTestId("admin-layout-content")+ .findByText("Loading...")+ .should("not.exist");// Page 2cy.findByTextEnsureVisible(`${PAGE_SIZE + 1} - ${NEW_TOTAL_USERS}`);@@ -633,12 +612,12 @@ describe("scenarios > admin > people", () => {cy.findByLabelText("Next page").should("be.disabled");cy.findByLabelText("Previous page").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Loading...").should("not.exist");+ cy.findByTestId("admin-layout-content")+ .findByText("Loading...")+ .should("not.exist");// Page 1- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText(`1 - ${PAGE_SIZE}`);+ cy.findByTestId("admin-layout-content").findByText(`1 - ${PAGE_SIZE}`);assertTableRowsCount(PAGE_SIZE);});});@@ -689,7 +668,7 @@ describe("scenarios > admin > people", () => {cy.findByText("Dashboard").should("not.exist");});- it("invite member when SSO is configured metabase#23630", () => {+ it("invite member when SSO is configured and not offer to reset passwords when password login is disabled (metabase#23630)", () => {H.setupSMTP();setupGoogleAuth();cy.request("PUT", "/api/setting", { "enable-password-login": false });@@ -724,6 +703,12 @@ describe("scenarios > admin > people", () => {});cy.findByTestId("admin-people-list-table").should("contain", FULL_NAME);++ cy.log(+ "should not offer to reset passwords when password login is disabled",+ );+ showUserOptions(normalUserName);+ H.popover().findByText("Reset password").should("not.exist");});});diff --git a/e2e/test/scenarios/admin/remote-sync.cy.spec.ts b/e2e/test/scenarios/admin/remote-sync.cy.spec.tsindex a9e57a4549b..ef7d7f01254 100644--- a/e2e/test/scenarios/admin/remote-sync.cy.spec.ts+++ b/e2e/test/scenarios/admin/remote-sync.cy.spec.ts@@ -508,40 +508,6 @@ describe("Remote Sync", () => {H.getGitSyncControls().should("contain.text", "main");});- it("can set up read-only mode", () => {- // Set up a Synced Collection to connect to, otherwise read-only mode will be empty- // Copy some files- H.copySyncedCollectionFixture();-- // Commit those files to the main branch- H.commitToRepo();-- cy.visit("/admin/settings/remote-sync");- cy.findByLabelText(/repository url/i)- .should("be.visible")- .click()- .clear()- .type(LOCAL_GIT_URL);-- cy.findByTestId("admin-layout-content").findByText("Read-only").click();- cy.button("Set up remote sync").click();- cy.findByTestId("admin-layout-content")- .findByText("Success")- .should("exist");-- // Read-only setup runs an initial import; close its confirmation modal (GHY-3747).- H.closeSyncResultModal();- H.modal().should("not.exist");- H.goToMainApp();-- // In read-only mode, git sync controls should not be visible in app bar- H.getGitSyncControls().should("not.exist");-- H.navigationSidebar().within(() => {- cy.findByRole("treeitem", { name: /Synced Collection/ }).click();- });- });-it("should disable 'Set up remote sync' button if git url is not set (#65653)", () => {cy.visit("/admin/settings/remote-sync");cy.button("Set up remote sync").should("be.disabled");@@ -792,75 +758,109 @@ describe("Remote Sync", () => {setup();});- it("can change branches", { requestTimeout: 15000 }, () => {- const UPDATED_REMOTE_QUESTION_NAME = "New Name";+ it(+ "can set up read-only mode from the settings page and change branches",+ { requestTimeout: 15000 },+ () => {+ const UPDATED_REMOTE_QUESTION_NAME = "New Name";- H.copySyncedCollectionFixture();- H.commitToRepo();- H.configureGitAndPullChanges("read-only");+ // Set up a Synced Collection to connect to, otherwise read-only mode will be empty+ H.copySyncedCollectionFixture();+ H.commitToRepo();- cy.intercept("GET", /\/api\/collection\/\d+\/items/).as(- "mainBranchItems",- );- cy.visit("/");+ cy.log("Set up read-only mode from the admin settings page");+ cy.visit("/admin/settings/remote-sync");+ cy.findByLabelText(/repository url/i)+ .should("be.visible")+ .click()+ .clear()+ .type(LOCAL_GIT_URL);++ cy.findByTestId("admin-layout-content").findByText("Read-only").click();+ cy.button("Set up remote sync").click();+ cy.findByTestId("admin-layout-content")+ .findByText("Success")+ .should("exist");- H.navigationSidebar()- .findByRole("treeitem", { name: /Synced Collection/ })- .click();- cy.wait(["@mainBranchItems", "@mainBranchItems"]);- H.collectionTable().findByText(REMOTE_QUESTION_NAME);+ cy.log(+ "Read-only setup runs an initial import; close its confirmation modal (GHY-3747)",+ );+ H.closeSyncResultModal();+ H.modal().should("not.exist");+ H.goToMainApp();- // Make a change, and commit it to the branch- H.checkoutSyncedCollectionBranch("test");- H.updateRemoteQuestion((doc) => {- doc.name = UPDATED_REMOTE_QUESTION_NAME;- return doc;- });+ cy.log(+ "In read-only mode, git sync controls are not shown in the app bar",+ );+ H.navigationSidebar()+ .findByRole("treeitem", { name: /Synced Collection/ })+ .click();+ H.collectionTable().findByText(REMOTE_QUESTION_NAME).should("exist");+ H.getGitSyncControls().should("not.exist");- cy.intercept("GET", "/api/session/properties").as("sessionProperties");- cy.intercept("GET", "/api/setting").as("settingDetails");- cy.intercept("GET", "/api/collection/root/items?*").as("rootItems");- cy.intercept("GET", "/api/ee/library").as("libraryCollection");- cy.visit("/admin/settings/remote-sync");- cy.wait([- "@sessionProperties",- "@settingDetails",- "@rootItems",- "@libraryCollection",- ]);-- cy.findByLabelText("Sync branch")- .scrollIntoView()- .clear()- .type("test")- .should("have.value", "test");- cy.findByTestId("remote-sync-submit-button").click();+ cy.intercept("GET", /\/api\/collection\/\d+\/items/).as(+ "mainBranchItems",+ );+ cy.visit("/");- cy.findByTestId("admin-layout-content")- .findByText("Success")- .should("exist");+ H.navigationSidebar()+ .findByRole("treeitem", { name: /Synced Collection/ })+ .click();+ cy.wait(["@mainBranchItems", "@mainBranchItems"]);+ H.collectionTable().findByText(REMOTE_QUESTION_NAME);- cy.findByRole("dialog", { name: "Switch branches?" })- .button("Continue")- .click();+ // Make a change, and commit it to the branch+ H.checkoutSyncedCollectionBranch("test");+ H.updateRemoteQuestion((doc) => {+ doc.name = UPDATED_REMOTE_QUESTION_NAME;+ return doc;+ });- H.waitForTask({ taskName: "import" });+ cy.intercept("GET", "/api/session/properties").as("sessionProperties");+ cy.intercept("GET", "/api/setting").as("settingDetails");+ cy.intercept("GET", "/api/collection/root/items?*").as("rootItems");+ cy.intercept("GET", "/api/ee/library").as("libraryCollection");+ cy.visit("/admin/settings/remote-sync");+ cy.wait([+ "@sessionProperties",+ "@settingDetails",+ "@rootItems",+ "@libraryCollection",+ ]);++ cy.findByLabelText("Sync branch")+ .scrollIntoView()+ .clear()+ .type("test")+ .should("have.value", "test");+ cy.findByTestId("remote-sync-submit-button").click();- cy.findByTestId("remote-sync-submit-button").should("be.disabled");+ cy.findByTestId("admin-layout-content")+ .findByText("Success")+ .should("exist");- H.pollForTask({ taskName: "import" });+ cy.findByRole("dialog", { name: "Switch branches?" })+ .button("Continue")+ .click();- cy.intercept("GET", /\/api\/collection\/\d+\/items/).as(- "testBranchItems",- );- cy.visit("/");+ H.waitForTask({ taskName: "import" });- H.navigationSidebar()- .findByRole("treeitem", { name: /Synced Collection/ })- .click();- cy.wait(["@testBranchItems", "@testBranchItems"]);- H.collectionTable().findByText(UPDATED_REMOTE_QUESTION_NAME);- });+ cy.findByTestId("remote-sync-submit-button").should("be.disabled");++ H.pollForTask({ taskName: "import" });++ cy.intercept("GET", /\/api\/collection\/\d+\/items/).as(+ "testBranchItems",+ );+ cy.visit("/");++ H.navigationSidebar()+ .findByRole("treeitem", { name: /Synced Collection/ })+ .click();+ cy.wait(["@testBranchItems", "@testBranchItems"]);+ H.collectionTable().findByText(UPDATED_REMOTE_QUESTION_NAME);+ },+ );it("keeps the Embed sharing option available for a question in a read-only synced collection (metabase#72752)", () => {H.copySyncedCollectionFixture();@@ -896,55 +896,17 @@ describe("Remote Sync", () => {});describe("admin settings", () => {- it("should show shared tenant collections section when tenants are enabled and remote sync is configured", () => {- // First set up remote sync- H.configureGitAndPullChanges("read-write");-- // Create some tenant collections- H.createSharedTenantCollection("Tenant A Shared");- H.createSharedTenantCollection("Tenant B Shared");-+ it("shows the shared tenant collections section, with an empty state, only when remote sync is configured and tenants are enabled", () => {+ cy.log(+ "Collections to sync section is hidden when remote sync is not enabled",+ );cy.visit("/admin/settings/remote-sync");-cy.findByTestId("admin-layout-content").within(() => {- // Main section should be visible- cy.findByText("Collections to sync").should("exist");-- // Shared collections sub-section should be visible- cy.findByText("Shared collections").should("exist");-- // Should show the tenant collections- cy.findByText("Tenant A Shared").should("exist");- cy.findByText("Tenant B Shared").should("exist");-- // Each collection should have a sync toggle- cy.findAllByRole("switch").should("have.length.at.least", 2);+ // Wait for the form to render so the negative assertion is meaningful+ cy.button("Set up remote sync").should("exist");+ cy.findByText("Collections to sync").should("not.exist");});- });-- it("should not show shared tenant collections section when tenants are disabled", () => {- // Disable tenants- cy.request("PUT", "/api/setting/use-tenants", { value: false });-- H.configureGitAndPullChanges("read-write");- cy.visit("/admin/settings/remote-sync");-- // Shared collections sub-section should NOT be visible- cy.findByTestId("admin-layout-content")- .findByText("Shared collections")- .should("not.exist");- });-- it("should not show shared tenant collections section when remote sync is not enabled", () => {- cy.visit("/admin/settings/remote-sync");- // Collections to sync section should NOT be visible (remote sync not yet configured)- cy.findByTestId("admin-layout-content")- .findByText("Collections to sync")- .should("not.exist");- });-- it("should show empty state when no shared tenant collections exist", () => {H.configureGitAndPullChanges("read-write");cy.visit("/admin/settings/remote-sync");@@ -952,27 +914,16 @@ describe("Remote Sync", () => {cy.findByText("Shared collections").should("exist");cy.findByText("No shared tenant collections found").should("exist");});- });-- it("can toggle sync for a shared tenant collection", () => {- H.configureGitAndPullChanges("read-write");-- // Create a tenant collection- H.createSharedTenantCollection("Tenant Collection To Sync");-- cy.visit("/admin/settings/remote-sync");+ cy.log(+ "Shared collections sub-section is hidden when tenants are disabled",+ );+ cy.request("PUT", "/api/setting/use-tenants", { value: false });+ cy.reload();cy.findByTestId("admin-layout-content").within(() => {- // Find the collection row and toggle sync on- cy.findByRole("switch", {- name: "Sync Tenant Collection To Sync",- }).click({ force: true });-- // Save changes- cy.button("Save changes").click();-- // Verify the setting was saved- cy.findByText(/success/i).should("exist");+ // Wait for the section to render so the negative assertion is meaningful+ cy.findByText("Collections to sync").should("exist");+ cy.findByText("Shared collections").should("not.exist");});});@@ -1027,16 +978,32 @@ describe("Remote Sync", () => {});describe("syncing tenant collections", () => {- it("can push changes from a synced tenant collection", () => {+ it("lists shared tenant collections in settings and can push changes from a synced one", () => {H.configureGitAndPullChanges("read-write");+ // A second, unsynced tenant collection so the settings list shows more than one row+ H.createSharedTenantCollection("Second Tenant Collection");+// Create a tenant collectionH.createSharedTenantCollection("Syncable Tenant Collection").then((response) => {const tenantCollectionId = response.body.id;- // Enable sync for this collection via admin settingscy.visit("/admin/settings/remote-sync");++ cy.log(+ "Shared tenant collections section is shown when tenants are enabled and remote sync is configured",+ );+ cy.findByTestId("admin-layout-content").within(() => {+ cy.findByText("Collections to sync").should("exist");+ cy.findByText("Shared collections").should("exist");+ cy.findByText("Syncable Tenant Collection").should("exist");+ cy.findByText("Second Tenant Collection").should("exist");+ // Each collection should have a sync toggle+ cy.findAllByRole("switch").should("have.length.at.least", 2);+ });++ // Enable sync for this collection via admin settings// Mantine Switch has a hidden input (0x0 pixels), so we need force: truecy.findByTestId("admin-layout-content").findByRole("switch", { name: "Sync Syncable Tenant Collection" })@@ -1044,6 +1011,9 @@ describe("Remote Sync", () => {cy.findByTestId("admin-layout-content").button("Save changes").click();+ cy.findByTestId("admin-layout-content")+ .findByText(/success/i)+ .should("exist");// Create a question in the tenant collectionH.createQuestion({@@ -1056,8 +1026,11 @@ describe("Remote Sync", () => {cy.visit("/");- // Verify sync status indicator appears- H.getSyncStatusIndicators().should("have.length.greaterThan", 0);+ // Verify the sync status badge appears on the tenant collection+ H.navigationSidebar()+ .findByRole("treeitem", { name: /Syncable Tenant Collection/ })+ .findByTestId("remote-sync-status")+ .should("exist");// Push changesH.clickPushOption();@@ -1074,42 +1047,6 @@ describe("Remote Sync", () => {},);});-- it("shows sync status badge on synced tenant collections in sidebar", () => {- H.configureGitAndPullChanges("read-write");-- // Create a tenant collection- H.createSharedTenantCollection("Badge Test Collection").then(- (response) => {- const collectionId = response.body.id;-- // Enable sync- cy.visit("/admin/settings/remote-sync");- // Mantine Switch has a hidden input (0x0 pixels), so we need force: true- cy.findByTestId("admin-layout-content")- .findByRole("switch", { name: "Sync Badge Test Collection" })- .click({ force: true });- cy.findByTestId("admin-layout-content")- .button("Save changes")- .click();-- // Create content to trigger dirty state- H.createQuestion({- name: "Status Badge Test Question",- query: { "source-table": PRODUCTS_ID },- collection_id: collectionId,- });-- cy.visit("/");-- // Verify the sync status badge appears on the tenant collection- H.navigationSidebar()- .findByRole("treeitem", { name: /Badge Test Collection/ })- .findByTestId("remote-sync-status")- .should("exist");- },- );- });});});diff --git a/e2e/test/scenarios/admin/security-center-snowplow.cy.spec.ts b/e2e/test/scenarios/admin/security-center-snowplow.cy.spec.tsdeleted file mode 100644index fe003987498..00000000000--- a/e2e/test/scenarios/admin/security-center-snowplow.cy.spec.ts+++ /dev/null@@ -1,41 +0,0 @@-const { H } = cy;-const IS_ENTERPRISE = Cypress.expose("IS_ENTERPRISE");--describe("Security Center > Snowplow tracking", { tags: "@enterprise" }, () => {- before(() => {- if (!IS_ENTERPRISE) {- cy.log("Skipping — requires EE build");- return;- }- });-- beforeEach(function () {- if (!IS_ENTERPRISE) {- this.skip();- }- H.resetSnowplow();- H.restore();- cy.signInAsAdmin();- H.enableTracking();- H.activateToken("pro-self-hosted");- // Stub the API so the page renders without a real EE backend- cy.intercept("GET", "/api/ee/security-center", {- last_checked_at: null,- advisories: [],- });- cy.intercept("GET", "/api/user/recipients", { data: [] });- cy.intercept("GET", "/api/channel", { channels: {} });- });-- afterEach(() => {- H.expectNoBadSnowplowEvents();- });-- it("should send a page viewed event when visiting the security center", () => {- cy.visit("/admin/security-center");- cy.findByRole("heading", { name: "Security Center" });- H.expectUnstructuredSnowplowEvent({- event: "security_center_page_viewed",- });- });-});diff --git a/e2e/test/scenarios/admin-2/security-center.cy.spec.ts b/e2e/test/scenarios/admin/security-center.cy.spec.tssimilarity index 95%rename from e2e/test/scenarios/admin-2/security-center.cy.spec.tsrename to e2e/test/scenarios/admin/security-center.cy.spec.tsindex 48a0043397d..7f10c512297 100644--- a/e2e/test/scenarios/admin-2/security-center.cy.spec.ts+++ b/e2e/test/scenarios/admin/security-center.cy.spec.ts@@ -208,15 +208,22 @@ describe("scenarios > admin > security center", { tags: "@EE" }, () => {});});- it("should trigger sync when clicking Check now", () => {+ it("should send a page viewed event and trigger sync when clicking Check now", () => {+ H.resetSnowplow();+ H.enableTracking();cy.intercept("POST", "/api/ee/security-center/sync").as("sync");cy.visit("/admin/security-center");securityCenterContent().within(() => {cy.findByText("Security Center").should("be.visible");});+ H.expectUnstructuredSnowplowEvent({+ event: "security_center_page_viewed",+ });cy.findByTestId("sync-advisories").click();cy.wait("@sync");++ H.expectNoBadSnowplowEvents();});describe("per-version download link", () => {@@ -236,8 +243,11 @@ describe("scenarios > admin > security center", { tags: "@EE" }, () => {updated_at: "2026-03-24T00:00:00Z",} as const;- it("stores and returns download_jar_urls through the real backend", () => {+ it("stores download_jar_urls and shows a single download button for the fix matching the instance major version", () => {+ H.mockSessionProperty("version", { tag: "v0.59.3" });H.seedSecurityAdvisories([DOWNLOADABLE_ADVISORY]);++ cy.log("The backend stores and returns download_jar_urls");cy.request("GET", "/api/ee/security-center").then(({ body }) => {const advisory = body.advisories.find((a: { advisory_id: string }) => a.advisory_id === "TEST-DL",@@ -247,11 +257,7 @@ describe("scenarios > admin > security center", { tags: "@EE" }, () => {{ version: "0.59.11", url: "https://downloads.example.com/59.jar" },]);});- });- it("shows a single download button for the fix matching the instance major version", () => {- H.mockSessionProperty("version", { tag: "v0.59.3" });- H.seedSecurityAdvisories([DOWNLOADABLE_ADVISORY]);cy.visit("/admin/security-center");cy.findAllByTestId("advisory-card")diff --git a/e2e/test/scenarios/admin-2/settings.cy.spec.js b/e2e/test/scenarios/admin/settings.cy.spec.jssimilarity index 90%rename from e2e/test/scenarios/admin-2/settings.cy.spec.jsrename to e2e/test/scenarios/admin/settings.cy.spec.jsindex f5d5506df99..5d41a862cd6 100644--- a/e2e/test/scenarios/admin-2/settings.cy.spec.js+++ b/e2e/test/scenarios/admin/settings.cy.spec.js@@ -38,40 +38,16 @@ describe("scenarios > admin > settings", () => {},);- it("should surface an error when validation for any field fails (metabase#4506)", () => {+ it("should save a setting, surface a validation error (metabase#4506), and check for working https before enabling a redirect", () => {const BASE_URL = Cypress.config().baseUrl;const DOMAIN_AND_PORT = BASE_URL.replace("http://", "");- cy.intercept("PUT", "/api/setting/site-url").as("url");-- cy.visit("/admin/settings/general");-- // Needed to strip down the protocol from URL to accomodate our UI (<select> PORT | <input> DOMAIN_AND_PORT)- cy.findByDisplayValue(DOMAIN_AND_PORT) // findByDisplayValue comes from @testing-library/cypress- .click()- .type("foo", { delay: 100 })- .blur();-- cy.wait("@url").should(({ response }) => {- expect(response.statusCode).to.eq(500);- // Switching to regex match for assertions - the test was flaky because of the "typing" issue- // i.e. it sometimes doesn't type the whole string "foo", but only "oo".- // We only care that the `cause` is starting with "Invalid site URL"- expect(response.body.cause).to.match(/^Invalid site URL/);- });-- // NOTE: This test is not concerned with HOW we style the error message - only that there is one.- // If we update UI in the future (for example: we show an error within a popup/modal), the test in current form could fail.- cy.log("Making sure we display an error message in UI");- // Same reasoning for regex as above- H.undoToast().contains(/^Invalid site URL/);- });-- it("should save a setting", () => {cy.intercept("PUT", "**/admin-email").as("saveSettings");+ cy.intercept("PUT", "/api/setting/site-url").as("url");cy.visit("/admin/settings/general");+ cy.log("should save a setting");// aliases don't last past refreshes, so create a function to grab the input// rather than aliasing it with .as()const emailInput = () =>@@ -94,14 +70,39 @@ describe("scenarios > admin > settings", () => {.blur();cy.wait("@saveSettings");+ // The visit also clears the "Changes saved" toast, so the error toast below is the only onecy.visit("/admin/settings/general");// after we refreshed, the field should still be "other.email"emailInput().should("have.value", "[email protected]");- });- it("should check for working https before enabling a redirect", () => {- cy.visit("/admin/settings/general");+ cy.log(+ "should surface an error when validation for any field fails (metabase#4506)",+ );+ // Needed to strip down the protocol from URL to accomodate our UI (<select> PORT | <input> DOMAIN_AND_PORT)+ cy.findByDisplayValue(DOMAIN_AND_PORT) // findByDisplayValue comes from @testing-library/cypress+ .click()+ .type("foo", { delay: 100 })+ .blur();+ cy.wait("@url").should(({ response }) => {+ expect(response.statusCode).to.eq(500);+ // Switching to regex match for assertions - the test was flaky because of the "typing" issue+ // i.e. it sometimes doesn't type the whole string "foo", but only "oo".+ // We only care that the `cause` is starting with "Invalid site URL"+ expect(response.body.cause).to.match(/^Invalid site URL/);+ });++ // NOTE: This test is not concerned with HOW we style the error message - only that there is one.+ // If we update UI in the future (for example: we show an error within a popup/modal), the test in current form could fail.+ cy.log("Making sure we display an error message in UI");+ // Same reasoning for regex as above+ H.undoToast().contains(/^Invalid site URL/);++ // The site URL input keeps the rejected text after a failed save, so reload+ // before switching the protocol; otherwise the invalid URL would be sent again+ cy.reload();++ cy.log("should check for working https before enabling a redirect");cy.intercept("GET", "**/api/health", "ok").as("httpsCheck");cy.findByTestId("admin-layout-content").within(() => {@@ -126,55 +127,6 @@ describe("scenarios > admin > settings", () => {H.restore(); // avoid leaving https site url});- it("should correctly apply the globalized date formats (metabase#11394) and update the formatting", () => {- cy.intercept("PUT", "**/custom-formatting").as("saveFormatting");-- cy.request("PUT", `/api/field/${ORDERS.CREATED_AT}`, {- semantic_type: null,- });-- cy.visit("/admin/settings/localization");-- cy.findByTestId("date_style-formatting-setting")- .findByDisplayValue("January 31, 2018")- .click({ force: true });-- H.popover().findByText("2018/1/31").click({ force: true });- cy.wait("@saveFormatting");-- cy.findByTestId("date_style-formatting-setting").findByDisplayValue(- "2018/1/31",- );-- cy.findByTestId("custom-formatting-setting")- .findByText("17:24 (24-hour clock)")- .click();- cy.wait("@saveFormatting");- cy.findByDisplayValue("HH:mm").should("be.checked");-- H.openOrdersTable({ limit: 2 });-- cy.findByTextEnsureVisible("Created At");- cy.get("[data-testid=cell-data]")- .should("contain", "Created At")- .and("contain", "2028/2/11, 21:40");-- // Go back to the settings and reset the time formatting- cy.visit("/admin/settings/localization");-- cy.findByTestId("custom-formatting-setting")- .findByText("5:24 PM (12-hour clock)")- .click();-- cy.wait("@saveFormatting");- cy.findByDisplayValue("h:mm A").should("be.checked");-- H.openOrdersTable({ limit: 2 });-- cy.findByTextEnsureVisible("Created At");- cy.get("[data-testid=cell-data]").and("contain", "2028/2/11, 9:40 PM");- });-it("should show where to display the unit of currency (metabase#table-metadata-missing-38021 and update the formatting", () => {// Set the semantic type of total to currencycy.request("PUT", `/api/field/${ORDERS.TOTAL}`, {@@ -206,18 +158,6 @@ describe("scenarios > admin > settings", () => {});});- it("should search for and select a new timezone", () => {- cy.intercept("PUT", "**/report-timezone").as("reportTimezone");- cy.visit("/admin/settings/localization");- cy.findByRole("textbox", { name: /timezone/i })- .as("timezoneSelect")- .clear()- .type("Centr");- H.selectDropdown().findByText("US/Central").click();- cy.wait("@reportTimezone");- cy.get("@timezoneSelect").should("have.value", "US/Central");- });-it("'General' admin settings should handle setup via `MB_SITE_URL` environment variable (metabase#14900)", () => {// 1. Get the array of ALL available settingscy.request("GET", "/api/setting").then(({ body }) => {@@ -286,7 +226,7 @@ describe("scenarios > admin > settings (EE)", () => {it("should hide the store link when running Metabase EE", () => {cy.visit("/admin/settings/license");- cy.findByTestId("admin-layout-content")+ cy.findByLabelText("Navigation bar").findByLabelText("store icon").should("not.exist");});@@ -430,35 +370,38 @@ describe("scenarios > admin > settings > email settings", () => {H.expectNoBadSnowplowEvents();});- it("should show an error if test email fails", () => {- // Reuse Email setup without relying on the previous test- cy.request("PUT", "/api/setting", {- "email-from-address": "[email protected]",- "email-from-name": "Metabase Admin",- "email-reply-to": ["[email protected]"],- "email-smtp-host": "localhost",- "email-smtp-password": null,- "email-smtp-port": "1234",- "email-smtp-security": "none",- "email-smtp-username": null,- });- cy.visit("/admin/settings/email");-- cy.findByTestId("admin-layout-content").within(() => {- cy.button("Send test email").click();- cy.findByText(- "Couldn't connect to host, port: localhost, 1234; timeout -1",- );- });- });-it(- "should send a test email for a valid SMTP configuration",+ "should show an error if test email fails and send a test email for a valid SMTP configuration",{ tags: "@external" },() => {+ cy.log("should show an error if test email fails");+ // Reuse Email setup without relying on the previous test+ cy.request("PUT", "/api/setting", {+ "email-from-address": "[email protected]",+ "email-from-name": "Metabase Admin",+ "email-reply-to": ["[email protected]"],+ "email-smtp-host": "localhost",+ "email-smtp-password": null,+ "email-smtp-port": "1234",+ "email-smtp-security": "none",+ "email-smtp-username": null,+ });+ cy.visit("/admin/settings/email");++ cy.findByTestId("admin-layout-content").within(() => {+ cy.button("Send test email").click();+ cy.findByText(+ "Couldn't connect to host, port: localhost, 1234; timeout -1",+ );+ });++ cy.log("should send a test email for a valid SMTP configuration");H.setupSMTP();+ // The visit also clears the error toast above, so "Email sent!" is the only toastcy.visit("/admin/settings/email");- cy.button("Send test email").click();+ cy.findByTestId("admin-layout-content")+ .button("Send test email")+ .click();H.undoToast().findByText("Email sent!").should("be.visible");cy.request("GET", `http://localhost:${WEB_PORT}/email`).then(({ body }) => {@@ -737,7 +680,8 @@ describe("scenarios > admin > localization", () => {});});- it("should use currency settings for number columns with style set to currency (metabase#10787)", () => {+ it("should use currency settings for number columns with style set to currency (metabase#10787) and search for and select a new timezone", () => {+ cy.intercept("PUT", "**/report-timezone").as("reportTimezone");cy.visit("/admin/settings/localization");// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage@@ -747,6 +691,19 @@ describe("scenarios > admin > localization", () => {cy.findByText("Euro").click();H.undoToast().findByText("Changes saved").should("be.visible");+ // Runs after the currency toast assertion because saving the timezone shows another toast+ cy.log("should search for and select a new timezone");+ cy.findByRole("textbox", { name: /timezone/i })+ .as("timezoneSelect")+ .clear()+ .type("Centr");+ H.selectDropdown().findByText("US/Central").click();+ cy.wait("@reportTimezone");+ cy.get("@timezoneSelect").should("have.value", "US/Central");++ cy.log(+ "should use currency settings for number columns with style set to currency (metabase#10787)",+ );H.visitQuestionAdhoc({display: "scalar",dataset_query: {@@ -770,12 +727,16 @@ describe("scenarios > admin > localization", () => {cy.findByText("€10.00");});- it("should use fix up clj unit testsdate and time styling settings in the date filter widget (metabase#9151, metabase#12472)", () => {+ it("should apply date and time style settings to table cells and the date filter widget (metabase#11394, metabase#9151, metabase#12472)", () => {cy.intercept("POST", "/api/dataset").as("dataset");cy.intercept("PUT", "/api/setting/custom-formatting").as("updateFormatting",);+ cy.request("PUT", `/api/field/${ORDERS.CREATED_AT}`, {+ semantic_type: null,+ });+cy.visit("/admin/settings/localization");cy.findByTestId("custom-formatting-setting").within(() => {@@ -796,6 +757,19 @@ describe("scenarios > admin > localization", () => {cy.findByDisplayValue("HH:mm").should("be.checked");});+ cy.log(+ "Globalized date formats are applied to table cells (metabase#11394)",+ );+ H.openOrdersTable({ limit: 2 });++ cy.findByTextEnsureVisible("Created At");+ cy.findAllByTestId("cell-data")+ .should("contain", "Created At")+ .and("contain", "2028/2/11, 21:40");++ cy.log(+ "Date and time styles are applied in the date filter widget (metabase#9151, metabase#12472)",+ );H.visitQuestion(ORDERS_QUESTION_ID);// create a date filter and set it to the 'On' view to see a specific date@@ -830,6 +804,20 @@ describe("scenarios > admin > localization", () => {cy.findByText("2027/5/15, 19:56");cy.findByText("127.52");});++ cy.log("Switching back to the 12-hour clock updates the formatting");+ cy.visit("/admin/settings/localization");++ cy.findByTestId("custom-formatting-setting").within(() => {+ cy.findByText("5:24 PM (12-hour clock)").click();+ cy.wait("@updateFormatting");+ cy.findByDisplayValue("h:mm A").should("be.checked");+ });++ H.openOrdersTable({ limit: 2 });++ cy.findByTextEnsureVisible("Created At");+ cy.findAllByTestId("cell-data").should("contain", "2028/2/11, 9:40 PM");});});@@ -840,19 +828,23 @@ describe("scenarios > admin > settings > map settings", () => {cy.signInAsAdmin();});- it("should be able to load and save a custom map", () => {+ it("should be able to load a custom map before a name is added, then save it (#14635)", () => {cy.visit("/admin/settings/maps");cy.button("Add a map").click();- cy.findByPlaceholderText("e.g. United Kingdom, Brazil, Mars").type(- "Test Map",- );cy.findByPlaceholderText("Like https://my-mb-server.com/maps/my-map.json",).type("https://raw.githubusercontent.com/metabase/metabase/master/resources/frontend_client/app/assets/geojson/world.json",);+ cy.log("Loading works before a map name is entered (#14635)");cy.button("Load").click();- cy.wait("@getGeoJson");+ cy.wait("@getGeoJson").then((interception) => {+ expect(interception.response.statusCode).to.eq(200);+ });++ cy.findByPlaceholderText("e.g. United Kingdom, Brazil, Mars").type(+ "Test Map",+ );cy.findByTestId("map-region-key-select").click();H.selectDropdown().contains("NAME").click();cy.findByTestId("map-region-name-select").click();@@ -863,23 +855,6 @@ describe("scenarios > admin > settings > map settings", () => {cy.contains("Test Map");});});-- it("should be able to load a custom map even if a name has not been added yet (#14635)", () => {- cy.intercept("GET", "/api/geojson*").as("load");- cy.visit("/admin/settings/maps");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Add a map").click();- cy.findByPlaceholderText(- "Like https://my-mb-server.com/maps/my-map.json",- ).type(- "https://raw.githubusercontent.com/metabase/metabase/master/resources/frontend_client/app/assets/geojson/world.json",- );- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Load").click();- cy.wait("@load").then((interception) => {- expect(interception.response.statusCode).to.eq(200);- });- });});// Ensure the webhook tester docker container is runningdiff --git a/e2e/test/scenarios/admin-2/sso/google.cy.spec.js b/e2e/test/scenarios/admin/sso/google.cy.spec.jssimilarity index 79%rename from e2e/test/scenarios/admin-2/sso/google.cy.spec.jsrename to e2e/test/scenarios/admin/sso/google.cy.spec.jsindex 746e99fd5c5..c2cd52ef697 100644--- a/e2e/test/scenarios/admin-2/sso/google.cy.spec.js+++ b/e2e/test/scenarios/admin/sso/google.cy.spec.js@@ -6,17 +6,33 @@ describe("scenarios > admin > settings > SSO > Google", () => {beforeEach(() => {H.restore();cy.signInAsAdmin();- cy.intercept("PUT", "/api/setting").as("updateSettings");+ cy.intercept("PUT", /\/api\/setting$/).as("updateSettings");cy.intercept("PUT", "/api/setting/*").as("updateSetting");cy.intercept("PUT", "/api/google/settings").as("updateGoogleSettings");});- it("should save the client id on subsequent tries (metabase#15974)", () => {+ it("should reject a client id without the correct suffix, then save the client id on subsequent tries (metabase#15974, metabase#15975)", () => {cy.visit("/admin/settings/authentication/google");- H.typeAndBlurUsingLabel("Client ID", "example1.apps.googleusercontent.com");+ cy.log(+ "A client id that does not end with the correct suffix shows an error (metabase#15975)",+ );+ H.typeAndBlurUsingLabel("Client ID", "fake-client-id");cy.button("Save and enable").click();cy.wait("@updateGoogleSettings");+ cy.findByTestId("admin-layout-content")+ .findByText(+ `Invalid Google Sign-In Client ID: must end with ".${CLIENT_ID_SUFFIX}"`,+ )+ .should("be.visible");++ cy.log(+ "A valid client id is saved, and so is a later change to it (metabase#15974)",+ );+ H.typeAndBlurUsingLabel("Client ID", "example1.apps.googleusercontent.com");+ // the submit button reads "Failed" for 5s after the rejected save+ cy.button(/Save and enable|Failed/).click();+ cy.wait("@updateGoogleSettings");cy.reload();cy.findByDisplayValue(`example1.${CLIENT_ID_SUFFIX}`).should("be.visible");@@ -26,7 +42,7 @@ describe("scenarios > admin > settings > SSO > Google", () => {cy.findByRole("button", { name: "Success" }).should("be.visible");});- it("should allow to disable and enable google auth (metabase#20442)", () => {+ it("should allow to disable and enable google auth, then reset its settings (metabase#20442)", () => {setupGoogleAuth();cy.visit("/admin/settings/authentication");@@ -39,12 +55,8 @@ describe("scenarios > admin > settings > SSO > Google", () => {H.popover().findByText("Resume").click();cy.wait("@updateSetting");getGoogleCard().findByText("Active").should("exist");- });-- it("should allow to reset google settings", () => {- setupGoogleAuth();- cy.visit("/admin/settings/authentication");+ cy.log("Deactivating resets the google settings");getGoogleCard().icon("ellipsis").click();H.popover().findByText("Deactivate").click();H.modal().button("Deactivate").click();@@ -53,18 +65,6 @@ describe("scenarios > admin > settings > SSO > Google", () => {getGoogleCard().findByText("Set up").should("exist");});- it("should show an error message if the client id does not end with the correct suffix (metabase#15975)", () => {- cy.visit("/admin/settings/authentication/google");-- H.typeAndBlurUsingLabel("Client ID", "fake-client-id");- cy.button("Save and enable").click();- cy.findByTestId("admin-layout-content")- .findByText(- `Invalid Google Sign-In Client ID: must end with ".${CLIENT_ID_SUFFIX}"`,- )- .should("be.visible");- });-it("should show the button to sign in via google only when enabled", () => {setupGoogleAuth({ enabled: true });cy.signOut();diff --git a/e2e/test/scenarios/admin-2/sso/jwt.cy.spec.js b/e2e/test/scenarios/admin/sso/jwt.cy.spec.jssimilarity index 85%rename from e2e/test/scenarios/admin-2/sso/jwt.cy.spec.jsrename to e2e/test/scenarios/admin/sso/jwt.cy.spec.jsindex 598fc5976f2..3e42ce16957 100644--- a/e2e/test/scenarios/admin-2/sso/jwt.cy.spec.js+++ b/e2e/test/scenarios/admin/sso/jwt.cy.spec.js@@ -6,7 +6,7 @@ describe("scenarios > admin > settings > SSO > JWT", () => {H.restore();cy.signInAsAdmin();H.activateToken("pro-self-hosted");- cy.intercept("PUT", "/api/setting").as("updateSettings");+ cy.intercept("PUT", /\/api\/setting$/).as("updateSettings");cy.intercept("PUT", "/api/setting/*").as("updateSetting");});@@ -28,7 +28,7 @@ describe("scenarios > admin > settings > SSO > JWT", () => {getJwtCard().findByText("Active").should("exist");});- it("should allow to disable and enable jwt", () => {+ it("should allow to disable and enable jwt, reset its settings, and regenerate its key", () => {enableJwtAuth();cy.visit("/admin/settings/authentication");@@ -41,36 +41,18 @@ describe("scenarios > admin > settings > SSO > JWT", () => {H.popover().findByText("Resume").click();cy.wait("@updateSetting");getJwtCard().findByText("Active").should("exist");- });-- it("should allow the user to enable/disable user provisioning", () => {- enableJwtAuth();- cy.visit("/admin/settings/authentication/jwt");-- cy.findByRole("switch", { name: "User provisioning" })- .should("be.checked")- .click({ force: true });- cy.wait("@updateSetting");-- H.undoToast().findByText("Changes saved").should("be.visible");- cy.findByRole("switch", { name: "User provisioning" }).should(- "not.be.checked",- );- });-- it("should allow to reset jwt settings", () => {- enableJwtAuth();- cy.visit("/admin/settings/authentication");+ cy.log("Deactivating resets the jwt settings");getJwtCard().icon("ellipsis").click();H.popover().findByText("Deactivate").click();H.modal().button("Deactivate").click();cy.wait("@updateSettings");getJwtCard().findByText("Set up").should("exist");- });- it("should allow to regenerate the jwt key and save the settings", () => {+ cy.log("Regenerating the existing jwt key and saving the settings");+ // Kept last: after saving, the form still counts as dirty, so leaving the+ // page opens a "Discard your changes?" modal.enableJwtAuth();cy.visit("/admin/settings/authentication/jwt");@@ -95,6 +77,21 @@ describe("scenarios > admin > settings > SSO > JWT", () => {.should("exist");});+ it("should allow the user to enable/disable user provisioning", () => {+ enableJwtAuth();+ cy.visit("/admin/settings/authentication/jwt");++ cy.findByRole("switch", { name: "User provisioning" })+ .should("be.checked")+ .click({ force: true });+ cy.wait("@updateSetting");++ H.undoToast().findByText("Changes saved").should("be.visible");+ cy.findByRole("switch", { name: "User provisioning" }).should(+ "not.be.checked",+ );+ });+describe("Group mapping", () => {beforeEach(() => {enableJwtAuth();@@ -105,37 +102,59 @@ describe("scenarios > admin > settings > SSO > JWT", () => {cy.visit("/admin/settings/authentication/jwt");});- it("should allow deleting mappings along with deleting, or clearing users of, mapped groups", () => {+ it("should delete or clear mapped groups with their mappings, keep the remaining mappings consistent, and clear all mappings when switching to automatic", () => {cy.log("Every mapping is saved as soon as it is added");selectGroupMappingMode("Manual");addMapping("cn=People1", ["Administrators", "data", "nosql"]);- addMapping("cn=People2", ["collection", "readonly"]);+ addMapping("cn=People2", ["Administrators", "data", "collection"]);+ addMapping("cn=People3", ["collection", "readonly"]);+ cy.log(+ "Deleting a mapping's groups removes them from the other mappings too, but never deletes Administrators",+ );deleteMapping(- "cn=People1",+ "cn=People2",/delete the groups/i,"Remove mapping and delete groups",);cy.wait(["@deleteGroup", "@deleteGroup"]);+ mappingRow("cn=People1").should("contain", "Administrators, nosql");+ mappingRow("cn=People3")+ .should("contain", "readonly")+ .and("not.contain", "collection");cy.log("Deleted groups are no longer offered for new mappings");newMappingButton().click();groupsPicker().click();cy.findByRole("listbox")- .should("contain", "collection")+ .should("contain", "readonly").and("not.contain", "data")- .and("not.contain", "nosql");+ .and("not.contain", "collection");cy.button("Cancel").click();+ cy.log("The same mappings come back after a reload");+ // the row assertions retry until the reloaded page has rendered, so there is nothing to wait on+ cy.reload();+ mappingRow("cn=People1").should("contain", "Administrators, nosql");+ mappingRow("cn=People3")+ .should("contain", "readonly")+ .and("not.contain", "collection");+cy.log(- "Deleting the last mapping clears its groups and turns group mapping off",+ "Clearing the last mappings empties their groups, skips Administrators and turns group mapping off",);deleteMapping(- "cn=People2",+ "cn=People3",/remove all members/i,"Remove mapping and members",);- cy.wait(["@clearGroup", "@clearGroup"]);+ cy.wait("@clearGroup");+ deleteMapping(+ "cn=People1",+ /remove all members/i,+ "Remove mapping and members",+ );+ cy.wait("@clearGroup");groupMappingSection().findByRole("radio", { name: "Off" }).should("be.checked");@@ -143,47 +162,20 @@ describe("scenarios > admin > settings > SSO > JWT", () => {cy.log("Deleted groups are gone and cleared groups have no members");cy.request("GET", "/api/permissions/group").then(({ body: groups }) => {const names = groups.map((group) => group.name);- expect(names).to.include.members(["collection", "readonly"]);+ expect(names).to.include.members(["nosql", "readonly"]);expect(names).not.to.include("data");- expect(names).not.to.include("nosql");+ expect(names).not.to.include("collection");const memberCount = (name) =>groups.find((group) => group.name === name).member_count;- expect(memberCount("collection")).to.equal(0);+ expect(memberCount("nosql")).to.equal(0);expect(memberCount("readonly")).to.equal(0);});- });-- it("should drop deleted groups from the remaining mappings and clear all mappings when switching to automatic", () => {- selectGroupMappingMode("Manual");- addMapping("cn=People1", ["Administrators", "data", "nosql"]);- addMapping("cn=People2", ["data", "collection"]);- addMapping("cn=People3", ["collection", "readonly"]);-- cy.log(- "Deleting a mapping's groups removes them from the other mappings too",- );- deleteMapping(- "cn=People2",- /delete the groups/i,- "Remove mapping and delete groups",- );- cy.wait(["@deleteGroup", "@deleteGroup"]);- mappingRow("cn=People1").should("contain", "Administrators, nosql");- mappingRow("cn=People3")- .should("contain", "readonly")- .and("not.contain", "collection");-- cy.log("The same mappings come back after a reload");- // the row assertions retry until the reloaded page has rendered, so there is nothing to wait on- cy.reload();- mappingRow("cn=People1").should("contain", "Administrators, nosql");- mappingRow("cn=People3")- .should("contain", "readonly")- .and("not.contain", "collection");cy.log("Switching to automatic asks for confirmation and deletes the mappings",);+ selectGroupMappingMode("Manual");+ addMapping("cn=People4", ["readonly"]);selectGroupMappingMode("Automatic");H.modal().within(() => {cy.findByText("Switch to automatic group mapping?").should(diff --git a/e2e/test/scenarios/admin-2/sso/ldap.cy.spec.js b/e2e/test/scenarios/admin/sso/ldap.cy.spec.jssimilarity index 87%rename from e2e/test/scenarios/admin-2/sso/ldap.cy.spec.jsrename to e2e/test/scenarios/admin/sso/ldap.cy.spec.jsindex e4860e672d5..ce477cd8aef 100644--- a/e2e/test/scenarios/admin-2/sso/ldap.cy.spec.js+++ b/e2e/test/scenarios/admin/sso/ldap.cy.spec.js@@ -13,22 +13,17 @@ describe(cy.intercept("POST", "/api/dataset").as("dataset");});- it("should setup ldap (metabase#16173)", () => {- cy.visit("/admin/settings/authentication/ldap");-- enterLdapSettings();- cy.button("Save and enable").click();- cy.wait("@updateLdapSettings");-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Success").should("exist");- });-- it("should update ldap settings", () => {+ it("should update ldap settings and not show the user provisioning UI to OSS users", () => {H.setupLdap();cy.visit("/admin/settings/authentication/ldap");enterLdapPort("389");++ cy.log("User provisioning is not offered to OSS users");+ cy.findByTestId("admin-layout-content")+ .findByText(/User Provisioning/i)+ .should("not.exist");+cy.button("Save changes").click();cy.wait("@updateLdapSettings");@@ -37,7 +32,7 @@ describe(getLdapCard().findByText("Active").should("exist");});- it("should allow to disable and enable ldap", () => {+ it("should allow to disable and enable ldap, then reset its settings", () => {H.setupLdap();cy.visit("/admin/settings/authentication");@@ -50,21 +45,8 @@ describe(H.popover().findByText("Resume").click();cy.wait("@updateSetting");getLdapCard().findByText("Active").should("exist");- });-- it("should not show the user provision UI to OSS users", () => {- H.setupLdap();- cy.visit("/admin/settings/authentication/ldap");-- cy.findByTestId("admin-layout-content")- .findByText(/User Provisioning/i)- .should("not.exist");- });-- it("should allow to reset ldap settings", () => {- H.setupLdap();- cy.visit("/admin/settings/authentication");+ cy.log("Deactivating resets the ldap settings");getLdapCard().icon("ellipsis").click();H.popover().findByText("Deactivate").click();H.modal().button("Deactivate").click();@@ -73,31 +55,7 @@ describe(getLdapCard().findByText("Set up").should("exist");});- it("should not reset previously populated fields when schema validation fails for just one of them", () => {- cy.visit("/admin/settings/authentication/ldap");-- enterLdapSettings();- enterLdapPort("0");- cy.button("Save and enable").click();- cy.wait("@updateLdapSettings");-- cy.findAllByText("nullable integer greater than 0").should("exist");- cy.findByDisplayValue("localhost").should("exist");- });-- it("should not reset previously populated fields when validation fails for just one of them (metabase#16226)", () => {- cy.visit("/admin/settings/authentication/ldap");-- enterLdapSettings();- enterLdapPort("1");- cy.button("Save and enable").click();- cy.wait("@updateLdapSettings");-- cy.findAllByText("Wrong host or port").should("exist");- cy.findByDisplayValue("localhost").should("exist");- });-- it("shouldn't be possible to save a non-integer port (#13313)", () => {+ it("should validate the port, not reset previously populated fields when schema or connection validation fails, and setup ldap once the port is valid (metabase#13313, metabase#16173, metabase#16226)", () => {cy.visit("/admin/settings/authentication/ldap");cy.findByLabelText(/LDAP Port/i)@@ -106,6 +64,8 @@ describe(.as("portSection");enterLdapSettings();++ cy.log("A non-integer port is not accepted (metabase#13313)");enterLdapPort("asd");cy.get("@portSection").findByDisplayValue("asd").should("not.exist");@@ -114,15 +74,37 @@ describe(.findByText("ldap-port must be an integer").should("be.visible");+ cy.log("Schema validation error (metabase#16226)");+ enterLdapPort("0");+ cy.button("Save and enable").click();+ cy.wait("@updateLdapSettings");++ cy.findAllByText("nullable integer greater than 0").should("exist");+ cy.findByDisplayValue("localhost").should("exist");++ cy.log("Connection validation error (metabase#16226)");+ enterLdapPort("1");+ // the submit button reads "Failed" for 5s after a rejected save+ cy.button(/Save and enable|Failed/).click();+ cy.wait("@updateLdapSettings");++ cy.findAllByText("Wrong host or port").should("exist");+ cy.findByDisplayValue("localhost").should("exist");++ cy.log(+ "A valid port, even with a trailing space, sets up ldap (metabase#13313, metabase#16173)",+ );enterLdapPort("389 ");cy.get("@portSection").findByText("That's not a valid port number").should("not.exist");- cy.button("Save and enable").click();+ // the submit button can still read "Failed" from the rejected save above+ cy.button(/Save and enable|Failed/).click();cy.wait("@updateLdapSettings");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Success").should("exist");+ cy.findByTestId("admin-layout-content")+ .findByText("Success")+ .should("exist");});it("should allow user login on OSS when LDAP is enabled", () => {diff --git a/e2e/test/scenarios/admin-2/sso/saml.cy.spec.js b/e2e/test/scenarios/admin/sso/saml.cy.spec.jssimilarity index 82%rename from e2e/test/scenarios/admin-2/sso/saml.cy.spec.jsrename to e2e/test/scenarios/admin/sso/saml.cy.spec.jsindex 1d55f19f67c..c00d0193528 100644--- a/e2e/test/scenarios/admin-2/sso/saml.cy.spec.js+++ b/e2e/test/scenarios/admin/sso/saml.cy.spec.js@@ -1,9 +1,6 @@const { H } = cy;-import {- checkGroupConsistencyAfterDeletingMappings,- crudGroupMappingsWidget,-} from "./shared/group-mappings-widget";+import { checkGroupMappingsWidget } from "./shared/group-mappings-widget";import { getSamlCertificate, setupSaml } from "./shared/helpers";describe("scenarios > admin > settings > SSO > SAML", () => {@@ -11,12 +8,12 @@ describe("scenarios > admin > settings > SSO > SAML", () => {H.restore();cy.signInAsAdmin();H.activateToken("pro-self-hosted");- cy.intercept("PUT", "/api/setting").as("updateSettings");+ cy.intercept("PUT", /\/api\/setting$/).as("updateSettings");cy.intercept("PUT", "/api/setting/*").as("updateSetting");cy.intercept("PUT", "/api/saml/settings").as("updateSamlSettings");});- it("should allow to save and enable saml", () => {+ it("should allow to save and enable saml, then update its settings", () => {cy.visit("/admin/settings/authentication/saml");enterSamlSettings();@@ -27,10 +24,8 @@ describe("scenarios > admin > settings > SSO > SAML", () => {H.goToAuthOverviewPage();getSamlCard().findByText("Active").should("exist");- });- it("should allow to update saml settings", () => {- setupSaml();+ cy.log("Update the existing settings");cy.visit("/admin/settings/authentication/saml");H.typeAndBlurUsingLabel(@@ -47,7 +42,7 @@ describe("scenarios > admin > settings > SSO > SAML", () => {getSamlCard().findByText("Active").should("exist");});- it("should allow to disable and enable saml", () => {+ it("should allow to disable and enable saml, then reset its settings", () => {setupSaml();cy.visit("/admin/settings/authentication");@@ -60,12 +55,8 @@ describe("scenarios > admin > settings > SSO > SAML", () => {H.popover().findByText("Resume").click();cy.wait("@updateSetting");getSamlCard().findByText("Active").should("exist");- });-- it("should allow to reset saml settings", () => {- setupSaml();- cy.visit("/admin/settings/authentication");+ cy.log("Deactivating resets the saml settings");getSamlCard().icon("ellipsis").click();H.popover().findByText("Deactivate").click();H.modal().button("Deactivate").click();@@ -98,12 +89,8 @@ describe("scenarios > admin > settings > SSO > SAML", () => {);});- it("should allow deleting mappings along with deleting, or clearing users of, mapped groups", () => {- crudGroupMappingsWidget("saml");- });-- it("should allow deleting mappings with groups, while keeping remaining mappings consistent with their undeleted groups", () => {- checkGroupConsistencyAfterDeletingMappings("saml");+ it("should allow deleting mappings along with deleting, or clearing users of, mapped groups, while keeping remaining mappings consistent", () => {+ checkGroupMappingsWidget("saml");});});});diff --git a/e2e/test/scenarios/admin-2/sso/shared/group-mappings-widget.js b/e2e/test/scenarios/admin/sso/shared/group-mappings-widget.jssimilarity index 61%rename from e2e/test/scenarios/admin-2/sso/shared/group-mappings-widget.jsrename to e2e/test/scenarios/admin/sso/shared/group-mappings-widget.jsindex 31d4aa960ce..9a945777322 100644--- a/e2e/test/scenarios/admin-2/sso/shared/group-mappings-widget.js+++ b/e2e/test/scenarios/admin/sso/shared/group-mappings-widget.js@@ -1,41 +1,4 @@-export function crudGroupMappingsWidget(authenticationMethod) {- cy.visit("/admin/settings/authentication/" + authenticationMethod);- cy.wait("@getSettings");- cy.wait("@getSessionProperties");-- // Create mapping, then delete it along with its groups- createMapping("cn=People1");- addGroupsToMapping("cn=People1", ["Administrators", "data", "nosql"]);- deleteMappingWithGroups("cn=People1");-- cy.wait(["@deleteGroup", "@deleteGroup"]);-- // Create mapping, then clear its groups of members- createMapping("cn=People2");- addGroupsToMapping("cn=People2", ["collection", "readonly"]);- // Groups deleted along with first mapping should not be offered- cy.findByText("data").should("not.exist");- cy.findByText("nosql").should("not.exist");-- cy.findByTestId("admin-content-table").within(() => {- cy.icon("close").click({ force: true });- });- cy.findByText(/remove all members/i).click();- cy.button("Remove mapping and members").click();-- cy.wait(["@clearGroup", "@clearGroup"]);-- cy.visit("/admin/people/groups");- cy.findByText("data").should("not.exist");- cy.findByText("nosql").should("not.exist");-- checkThatGroupHasNoMembers("collection");- checkThatGroupHasNoMembers("readonly");-}--export function checkGroupConsistencyAfterDeletingMappings(- authenticationMethod,-) {+export function checkGroupMappingsWidget(authenticationMethod) {cy.visit("/admin/settings/authentication/" + authenticationMethod);cy.wait("@getSettings");cy.wait("@getSessionProperties");@@ -44,16 +7,25 @@ export function checkGroupConsistencyAfterDeletingMappings(addGroupsToMapping("cn=People1", ["Administrators", "data", "nosql"]);createMapping("cn=People2");- addGroupsToMapping("cn=People2", ["data", "collection"]);+ // Administrators is never deleted along with a mapping's groups, so+ // cn=People1 keeps it below+ addGroupsToMapping("cn=People2", ["Administrators", "data", "collection"]);createMapping("cn=People3");addGroupsToMapping("cn=People3", ["collection", "readonly"]);- deleteMappingWithGroups("cn=People2");+ cy.log(+ "Deleting a mapping with its groups keeps the remaining mappings consistent",+ );+ deleteMapping(+ "cn=People2",+ /delete the groups/i,+ "Remove mapping and delete groups",+ );+ cy.wait(["@deleteGroup", "@deleteGroup"]);- // Scope to the table: the group dropdown is portaled and stays mounted- // (hidden) after being opened, so a group name can also linger as an- // off-screen option outside the table.+ // Scope to the table: the group dropdown is portaled, so a group name can+ // also show up as an option outside the table.cy.findByTestId("admin-content-table").within(() => {// cn=People1 will have Admin and nosql as groupscy.findByText("1 other group");@@ -61,23 +33,53 @@ export function checkGroupConsistencyAfterDeletingMappings(cy.findByText("readonly");});- // Ensure mappings are as expected after a page reload+ cy.log("Deleted groups are no longer offered for mappings");+ mappingRow("cn=People3").findByText("readonly").click();+ cy.findByRole("option", { name: "readonly" }).should("exist");+ cy.findByRole("option", { name: "data" }).should("not.exist");+ cy.findByRole("option", { name: "collection" }).should("not.exist");+ cy.realPress("{esc}");++ cy.log("Mappings are as expected after a page reload");cy.visit("/admin/settings/authentication/" + authenticationMethod);cy.findByTestId("admin-content-table").within(() => {cy.findByText("1 other group");cy.findByText("readonly");});++ cy.log(+ "Deleting mappings while clearing their groups empties the groups, skipping Administrators",+ );+ deleteMapping(+ "cn=People3",+ /remove all members/i,+ "Remove mapping and members",+ );+ cy.wait("@clearGroup");+ deleteMapping(+ "cn=People1",+ /remove all members/i,+ "Remove mapping and members",+ );+ cy.wait("@clearGroup");++ cy.visit("/admin/people/groups");+ cy.findByText("data").should("not.exist");+ cy.findByText("collection").should("not.exist");++ checkThatGroupHasNoMembers("nosql");+ checkThatGroupHasNoMembers("readonly");}-const deleteMappingWithGroups = (mappingName) => {- cy.findByText(mappingName)- .closest("tr")- .within(() => {- cy.icon("close").click({ force: true });- });+const mappingRow = (mappingName) => cy.findByText(mappingName).closest("tr");- cy.findByText(/delete the groups/i).click();- cy.button("Remove mapping and delete groups").click();+const deleteMapping = (mappingName, consequenceLabel, confirmLabel) => {+ mappingRow(mappingName).within(() => {+ cy.icon("close").click({ force: true });+ });++ cy.findByText(consequenceLabel).click();+ cy.button(confirmLabel).click();// Removing the mapping PUTs the setting and invalidates session properties,// triggering a refetch. Wait for both to settle so this trailing refetch@@ -100,11 +102,9 @@ const createMapping = (name) => {};const addGroupsToMapping = (mappingName, groups) => {- cy.findByText(mappingName)- .closest("tr")- .within(() => {- cy.findByText("Default").click();- });+ mappingRow(mappingName).within(() => {+ cy.findByText("Default").click();+ });groups.forEach((group) => {cy.findByRole("option", { name: group }).click();diff --git a/e2e/test/scenarios/admin-2/sso/shared/helpers.js b/e2e/test/scenarios/admin/sso/shared/helpers.jssimilarity index 100%rename from e2e/test/scenarios/admin-2/sso/shared/helpers.jsrename to e2e/test/scenarios/admin/sso/shared/helpers.jsdiff --git a/e2e/test/scenarios/admin-2/tenants.cy.spec.ts b/e2e/test/scenarios/admin/tenants.cy.spec.tssimilarity index 98%rename from e2e/test/scenarios/admin-2/tenants.cy.spec.tsrename to e2e/test/scenarios/admin/tenants.cy.spec.tsindex ad4e550f7bd..829047a6468 100644--- a/e2e/test/scenarios/admin-2/tenants.cy.spec.ts+++ b/e2e/test/scenarios/admin/tenants.cy.spec.ts@@ -430,49 +430,6 @@ describe("Tenants - management", () => {lacksGlobeIcon("All internal users");});- it("should show 'All tenant users' in permission warning tooltip for tenant groups (UXW-2474)", () => {- cy.request("PUT", "/api/setting", { "use-tenants": true });-- // Create a tenant group- cy.request("POST", "/api/permissions/group", {- name: "Test Tenant Group",- is_tenant_group: true,- }).then(({ body: group }) => {- const tenantGroupId = group.id;-- cy.visit(`/admin/permissions/data/group/${tenantGroupId}`);-- cy.findByRole("tab", { name: "Groups" }).click({ force: true });-- cy.findByRole("menuitem", { name: "All tenant users" }).click();-- cy.log("sample database's view data permission should be 'Can view'");- getPermissionRowPermissions("Sample Database")- .first()- .should("contain", "Can view");-- cy.findByRole("menuitem", { name: "Test Tenant Group" }).click();-- cy.log("tenant group view data permission should be 'Blocked'");- getPermissionRowPermissions("Sample Database")- .first()- .should("contain", "Blocked");-- cy.log("tenant group permission should contain a warning");- getPermissionRowPermissions("Sample Database")- .first()- .findByLabelText("warning icon")- .realHover();-- // Tooltip must reference "All tenant users" not "All internal users"- H.tooltip().should(- "contain",- 'The "All tenant users" group has a higher level of access',- );- H.tooltip().should("not.contain", "All internal users");- });- });-it("should show 'All internal users' in permission warning modal for internal groups on tenant collections (EMB-1143)", () => {cy.request("PUT", "/api/setting", { "use-tenants": true });@@ -522,14 +479,53 @@ describe("Tenants - management", () => {});});- it("should show 'All tenant users' in permission warning tooltip and modal for tenant groups on data permissions (UXW-2624)", () => {+ it("should show 'All tenant users' in permission warning tooltip and modal for tenant groups on data permissions, in both the group and database views (UXW-2474, UXW-2624)", () => {cy.request("PUT", "/api/setting", { "use-tenants": true });cy.request("POST", "/api/permissions/group", {name: "Test Tenant Group",is_tenant_group: true,+ }).then(({ body: group }) => {+ const tenantGroupId = group.id;++ cy.log(+ "should show 'All tenant users' in permission warning tooltip for tenant groups in the group view (UXW-2474)",+ );+ cy.visit(`/admin/permissions/data/group/${tenantGroupId}`);++ cy.findByRole("tab", { name: "Groups" }).click({ force: true });++ cy.findByRole("menuitem", { name: "All tenant users" }).click();++ cy.log("sample database's view data permission should be 'Can view'");+ getPermissionRowPermissions("Sample Database")+ .first()+ .should("contain", "Can view");++ cy.findByRole("menuitem", { name: "Test Tenant Group" }).click();++ cy.log("tenant group view data permission should be 'Blocked'");+ getPermissionRowPermissions("Sample Database")+ .first()+ .should("contain", "Blocked");++ cy.log("tenant group permission should contain a warning");+ getPermissionRowPermissions("Sample Database")+ .first()+ .findByLabelText("warning icon")+ .realHover();++ // Tooltip must reference "All tenant users" not "All internal users"+ H.tooltip().should(+ "contain",+ 'The "All tenant users" group has a higher level of access',+ );+ H.tooltip().should("not.contain", "All internal users");});+ cy.log(+ "should show 'All tenant users' in permission warning tooltip and modal for tenant groups in the database view (UXW-2624)",+ );cy.visit("/admin/permissions/data/database/1");cy.log("all tenant users should have 'Can view' access");diff --git a/e2e/test/scenarios/admin-2/whitelabel.cy.spec.js b/e2e/test/scenarios/admin/whitelabel.cy.spec.jssimilarity index 90%rename from e2e/test/scenarios/admin-2/whitelabel.cy.spec.jsrename to e2e/test/scenarios/admin/whitelabel.cy.spec.jsindex b04153a2c68..dffe28bbad5 100644--- a/e2e/test/scenarios/admin-2/whitelabel.cy.spec.js+++ b/e2e/test/scenarios/admin/whitelabel.cy.spec.js@@ -67,14 +67,16 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {cy.findByDisplayValue(NEW_COMPANY_NAME);});- it("should not show the old name in the admin panel (metabase#17043)", () => {+ it("should not show the old name in the admin panel (metabase#17043) and should show the new name in the main app", () => {+ cy.log(+ "should not show the old name in the admin panel (metabase#17043)",+ );cy.visit("/admin/settings/general");cy.findByTestId("site-name-setting").findByText(`The name used for this instance of ${NEW_COMPANY_NAME}.`).should("be.visible");- });- it("should show the new name in the main app", () => {+ cy.log("should show the new name in the main app");cy.visit("/");H.getProfileLink().click();H.popover().findByText("Help").click();@@ -99,38 +101,25 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {);});- it("changes should reflect on admin's dashboard", () => {+ it("changes should reflect on admin's dashboard, on user's dashboard, and while signed out", () => {+ cy.log("changes should reflect on admin's dashboard");cy.visit("/");checkLogo();- });- it("changes should reflect while signed out", () => {- cy.signOut();+ cy.log("changes should reflect on user's dashboard");+ cy.signInAsNormalUser();cy.visit("/");checkLogo();- });- it("changes should reflect on user's dashboard", () => {- cy.signInAsNormalUser();+ cy.log("changes should reflect while signed out");+ cy.signOut();cy.visit("/");checkLogo();});});describe("favicon", () => {- it("should work for people that set favicon URL before we change the input to file input", () => {- const faviconUrl =- "https://cdn.ecosia.org/assets/images/ico/favicon.ico";- H.updateSetting("application-favicon-url", faviconUrl);- checkFavicon(faviconUrl);- cy.signInAsNormalUser();- cy.visit("/");- cy.get('head link[rel="icon"]')- .get('[href="https://cdn.ecosia.org/assets/images/ico/favicon.ico"]')- .should("have.length", 1);- });-- it("should show up in user's HTML", () => {+ it("should show up in user's HTML, including a favicon URL set before we changed the input to a file input", () => {cy.visit("/admin/settings/whitelabel");cy.log("Add favicon");@@ -156,6 +145,20 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {.get(`[href="${faviconUrl}"]`).should("have.length", 1);});++ cy.log(+ "should work for people that set favicon URL before we change the input to file input",+ );+ const legacyFaviconUrl =+ "https://cdn.ecosia.org/assets/images/ico/favicon.ico";+ cy.signInAsAdmin();+ H.updateSetting("application-favicon-url", legacyFaviconUrl);+ checkFavicon(legacyFaviconUrl);+ cy.signInAsNormalUser();+ cy.visit("/");+ cy.get('head link[rel="icon"]')+ .get(`[href="${legacyFaviconUrl}"]`)+ .should("have.length", 1);});});@@ -307,7 +310,7 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {});describe("landing page illustration", () => {- it("should allow display the selected illustration on the landing page", () => {+ it("should allow display the selected illustration on the landing page and toggle metabot visibility", () => {cy.visit("/admin/settings/whitelabel/conceal-metabase");cy.findByTestId("landing-page-illustration-setting")@@ -350,6 +353,21 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {cy.visit("/");cy.findByTestId("landing-page-illustration").should("not.exist");++ // The Metabot greeting (show-metabot) renders independently of the landing page illustration+ cy.log("should toggle metabot visibility");+ cy.findAllByRole("img", { name: "Metabot" }).should("have.length", 2);++ cy.visit("/admin/settings/whitelabel/conceal-metabase");+ cy.findByRole("main")+ .findByText("Display welcome message on the homepage")+ .click();++ H.undoToast().findByText("Changes saved").should("be.visible");++ cy.visit("/");+ cy.findByRole("link", { name: /home/ }).should("exist");+ cy.findByRole("img", { name: "Metabot" }).should("not.exist");});});@@ -534,42 +552,14 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {});});- describe("metabot", () => {- it("should toggle metabot visibility", () => {- cy.visit("/");- cy.findAllByRole("img", { name: "Metabot" }).should("have.length", 2);-- cy.visit("/admin/settings/whitelabel/conceal-metabase");- cy.findByRole("main")- .findByText("Display welcome message on the homepage")- .click();-- H.undoToast().findByText("Changes saved").should("be.visible");-- cy.visit("/");- cy.findByRole("link", { name: /home/ }).should("exist");- cy.findByRole("img", { name: "Metabot" }).should("not.exist");- });- });-describe("font", () => {beforeEach(() => {cy.log("Change Application Font");cy.signInAsAdmin();});- it("should apply correct font", () => {- setApplicationFontTo("Open Sans");- cy.signInAsNormalUser();- cy.visit("/");- cy.get("body").should(- "have.css",- "font-family",- '"Open Sans", Lato, sans-serif',- );- });-- it("should be able to make multiple font changes (metabase#45486)", () => {+ it("should be able to make multiple font changes (metabase#45486) and apply the correct font for other users", () => {+ cy.log("should be able to make multiple font changes (metabase#45486)");cy.intercept("PUT", "/api/setting/application-font").as("saveFont");const fontsWithExpectedFallback = [["Lora", "serif"],@@ -589,6 +579,16 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {`${newFont}, ${fallback}`,);});++ cy.log("should apply correct font");+ setApplicationFontTo("Open Sans");+ cy.signInAsNormalUser();+ cy.visit("/");+ cy.get("body").should(+ "have.css",+ "font-family",+ '"Open Sans", Lato, sans-serif',+ );});});@@ -600,7 +600,7 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {);});- it("should allow customising the help link", () => {+ it("should allow customising the help link, validate the url, and link to metabase help when the whitelabel feature is disabled (eg OSS)", () => {cy.log("Hide Help link");cy.signInAsAdmin();@@ -627,8 +627,33 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {.findByText("Go to a custom destination...").click();+ getHelpLinkCustomDestinationInput().should("have.focus");++ cy.log("it should validate the url");+ getHelpLinkCustomDestinationInput()+ .clear()+ .type("ftp://something")+ .blur();+ H.main()+ .findByText(/This needs to be/i)+ .should("exist");++ getHelpLinkCustomDestinationInput().clear().type("https://").blur();+ // Wait on each custom-destination PUT so the wait below matches the final save+ cy.wait("@putHelpLinkUrl");++ H.main()+ .findByText("Please make sure this is a valid URL")+ .should("exist");++ getHelpLinkCustomDestinationInput().type("example").blur();+ cy.wait("@putHelpLinkUrl");++ H.main()+ .findByText("Please make sure this is a valid URL")+ .should("not.exist");+getHelpLinkCustomDestinationInput()- .should("have.focus").clear().type("https://example.org/custom-destination").blur();@@ -679,9 +704,14 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {helpLink().should("have.attr", "href").and("include", "https://www.metabase.com/help?");- });- it("should link to metabase help when the whitelabel feature is disabled (eg OSS)", () => {+ cy.log(+ "should link to metabase help when the whitelabel feature is disabled (eg OSS)",+ );+ cy.signInAsAdmin();+ // Point the help link at the custom destination first, so only the+ // whitelabel feature gating can bring back the default Metabase help link+ H.updateSetting("help-link", "custom");H.deleteToken();cy.signInAsNormalUser();@@ -692,35 +722,6 @@ describe("formatting > whitelabel", { tags: "@EE" }, () => {.should("have.attr", "href").and("include", "https://www.metabase.com/help?");});-- it("it should validate the url", () => {- cy.signInAsAdmin();- cy.visit("/admin/settings/whitelabel/conceal-metabase");-- cy.findByTestId("help-link-setting")- .findByText("Go to a custom destination...")- .click();-- getHelpLinkCustomDestinationInput()- .clear()- .type("ftp://something")- .blur();- H.main()- .findByText(/This needs to be/i)- .should("exist");-- getHelpLinkCustomDestinationInput().clear().type("https://").blur();-- H.main()- .findByText("Please make sure this is a valid URL")- .should("exist");-- getHelpLinkCustomDestinationInput().type("example").blur();-- H.main()- .findByText("Please make sure this is a valid URL")- .should("not.exist");- });});describe("Landing Page (now moved to general tab metabase#38699)", () => {