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 onboarding e2e tests (#83417)
Chris Vandoodewaard1ed043bc040a
diff --git a/e2e/test/scenarios/data-reference/glossary.cy.spec.ts b/e2e/test/scenarios/data-reference/glossary.cy.spec.tsdeleted file mode 100644index 1650028e5e5..00000000000--- a/e2e/test/scenarios/data-reference/glossary.cy.spec.ts+++ /dev/null@@ -1,173 +0,0 @@-const { H } = cy;--function executeCreateGlossaryTermFlow() {- cy.intercept("POST", "/api/glossary", (req) => {- expect(req.body).to.deep.equal({- term: "Boat",- definition: "A small vessel for traveling on water.",- });- }).as("createGlossary");-- cy.findByRole("button", { name: /new term/i }).click();-- cy.findByPlaceholderText(/boat/i).type(" Boat ");- cy.findByPlaceholderText(/a small vessel.*/i).type(- " A small vessel for traveling on water. ",- );-- cy.findByLabelText("Save").click();-- cy.wait("@createGlossary");-- cy.get("table").within(() => {- cy.findByText("Boat").should("be.visible");- cy.findByText("A small vessel for traveling on water.").should(- "be.visible",- );- });-}--function executeUpdateGlossaryTermFlow(visitPageFn: VoidFunction) {- cy.request("POST", "/api/glossary", {- term: "Cat",- definition: "Meows",- }).then(({ body }) => {- const { id } = body;-- cy.intercept("PUT", `/api/glossary/${id}`, (req) => {- expect(req.body).to.deep.equal({- term: "Kitten",- definition: "Young cat",- });- }).as("updateGlossary");-- visitPageFn();-- cy.get("table").within(() => {- cy.findByText("Cat").click();- });-- cy.findByPlaceholderText(/boat/i).clear().type("Kitten");- cy.findByPlaceholderText(/a small vessel.*/i)- .clear()- .type("Young cat");-- cy.findByRole("button", { name: /save/i }).click();-- cy.wait("@updateGlossary");-- cy.get("table").within(() => {- cy.findByText("Kitten").should("be.visible");- cy.findByText("Young cat").should("be.visible");- });- });-}--function executeDeleteGlossaryTermFlow(visitPageFn: VoidFunction) {- cy.request("POST", "/api/glossary", {- term: "DeleteMe",- definition: "To be removed",- }).then(({ body }) => {- const { id } = body;- cy.intercept("DELETE", `/api/glossary/${id}`).as("deleteGlossary");-- visitPageFn();-- cy.get("table").within(() => {- cy.findByText("DeleteMe").should("be.visible").realHover();- cy.findByRole("button", { name: /delete/i }).click();- });-- cy.findByRole("dialog").within(() => {- cy.findByRole("button", { name: /delete/i }).click();- });-- cy.wait("@deleteGlossary");-- cy.get("table").within(() => {- cy.findByText("DeleteMe").should("not.exist");- });- });-}--describe("data reference > glossary", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- function visitGlossary() {- cy.visit("/reference/glossary");- }-- it("fetches existing definitions", () => {- cy.intercept("GET", "/api/glossary", {- statusCode: 200,- body: {- data: [- { id: 1, term: "Alpha", definition: "First" },- { id: 2, term: "Beta", definition: "Second" },- ],- can_write: true,- },- }).as("getGlossary");-- visitGlossary();-- cy.wait("@getGlossary");- cy.get("table").within(() => {- cy.findByText("Alpha").should("be.visible");- cy.findByText("Beta").should("be.visible");- });- });-- it("creates a new definition and makes POST /api/glossary with trimmed values", () => {- visitGlossary();- executeCreateGlossaryTermFlow();- });-- it("updates an existing definition and makes PUT /api/glossary/:id", () => {- executeUpdateGlossaryTermFlow(visitGlossary);- });-- it("deletes an existing definition and makes DELETE /api/glossary/:id", () => {- executeDeleteGlossaryTermFlow(visitGlossary);- });-});--describe("data studio > glossary", () => {- beforeEach(() => {- H.restore();- H.resetSnowplow();- cy.signInAsAdmin();- H.activateToken("pro-self-hosted");- });-- function visitDataStudioGlossary() {- H.DataModel.visitDataStudio();- H.DataStudio.nav().findByLabelText("Glossary").click();- cy.findByRole("heading", { name: "Glossary" }).should("be.visible");- }-- it("should allow creating a new definition and trigger tracking event", () => {- visitDataStudioGlossary();- executeCreateGlossaryTermFlow();- H.expectUnstructuredSnowplowEvent({- event: "data_studio_glossary_term_created",- });- });-- it("should allow updating an existing definition and trigger tracking event", () => {- executeUpdateGlossaryTermFlow(visitDataStudioGlossary);- H.expectUnstructuredSnowplowEvent({- event: "data_studio_glossary_term_updated",- });- });-- it("should allow deleting an existing definition and trigger tracking event", () => {- executeDeleteGlossaryTermFlow(visitDataStudioGlossary);- H.expectUnstructuredSnowplowEvent({- event: "data_studio_glossary_term_deleted",- });- });-});diff --git a/e2e/test/scenarios/i18n/i18n.cy.spec.ts b/e2e/test/scenarios/i18n/i18n.cy.spec.tsdeleted file mode 100644index 548300f9bcf..00000000000--- a/e2e/test/scenarios/i18n/i18n.cy.spec.ts+++ /dev/null@@ -1,54 +0,0 @@-const { H } = cy;--const paths = [- "/",- "/getting-started",- "/collection/root",- "/browse/models",- "/browse/databases",- "/browse/metrics",- "/trash",- "/admin",-];--const locales = [- "Chinese (China)",- "Chinese (Taiwan)",- "French",- "German",- "Italian",- "Japanese",- "Korean",- "Portuguese (Brazil)",- "Russian",- "Spanish",-];--describe("Pages accessible within one click from the homepage should work in popular locales", () => {- before(H.restore);-- beforeEach(() => {- cy.signInAsNormalUser();- cy.intercept("PUT", "/api/user/*").as("updateUserSettings");- });-- locales.forEach((localeName) => {- it(`Pages should be reachable when locale is ${localeName}`, () => {- selectLocale(localeName);- paths.forEach((path) => {- cy.visit(path);- cy.findByRole("main");- cy.findAllByTestId("error-boundary").should("not.exist");- });- });- });-});--const selectLocale = (localeName: string) => {- cy.visit("/account/profile");- cy.findByTestId("user-locale-select").findByRole("textbox").click();- H.popover().within(() => cy.findByText(localeName).click());-- cy.get("[type=submit]").click();- cy.wait("@updateUserSettings");-};diff --git a/e2e/test/scenarios/onboarding/auth/forgot_password.cy.spec.js b/e2e/test/scenarios/onboarding/auth/forgot_password.cy.spec.jsindex 81d7e7411cf..4a63381a90d 100644--- a/e2e/test/scenarios/onboarding/auth/forgot_password.cy.spec.js+++ b/e2e/test/scenarios/onboarding/auth/forgot_password.cy.spec.js@@ -37,7 +37,10 @@ describe("scenarios > auth > password", { tags: "@external" }, () => {cy.visit("/auth/forgot_password");- cy.icon("gear").should("not.exist");+ cy.findByRole("button", { name: "Send password reset email" }).should(+ "be.visible",+ );+ H.getProfileLink().should("not.exist");});});diff --git a/e2e/test/scenarios/onboarding/auth/signin.cy.spec.js b/e2e/test/scenarios/onboarding/auth/signin.cy.spec.jsindex d60a20a02ca..e5650ad53ba 100644--- a/e2e/test/scenarios/onboarding/auth/signin.cy.spec.js+++ b/e2e/test/scenarios/onboarding/auth/signin.cy.spec.js@@ -14,11 +14,6 @@ describe("scenarios > auth > signin", () => {cy.intercept("POST", "/api/dataset").as("dataset");});- it("should redirect to /auth/login", () => {- cy.visit("/");- cy.url().should("contain", "auth/login");- });-it("should redirect to / when logged in", () => {cy.signInAsAdmin();cy.visit("/auth/login");@@ -26,52 +21,46 @@ describe("scenarios > auth > signin", () => {H.getProfileLink().should("exist");});- it("should display an error for incorrect passwords", () => {+ it("should reject invalid credentials and allow login regardless of email case", () => {+ cy.intercept("POST", "/api/session").as("signIn");cy.visit("/");- cy.findByLabelText("Email address").type(admin.email);- cy.findByLabelText("Password").type("INVALID" + admin.password);- cy.button("Sign in").click();- cy.findByRole("alert")- .filter(':contains("did not match stored password")')- .should("be.visible");- });-- it("should display same error for unknown users (to avoid leaking the existence of accounts)", () => {- cy.visit("/");- cy.findByLabelText("Email address").type("INVALID" + admin.email);- cy.findByLabelText("Password").type(admin.password);- cy.button("Sign in").click();- cy.findByRole("alert")- .filter(':contains("did not match stored password")')- .should("be.visible");- });-- it("should greet users after successful login", () => {- cy.visit("/auth/login");- cy.findByLabelText("Email address").should("be.focused").type(admin.email);- cy.findByLabelText("Password").type(admin.password);- cy.button("Sign in").click();- cy.findByTestId("greeting-message").should("contain.text", "Bobby");- });+ cy.location("pathname").should("eq", "/auth/login");+ cy.findByLabelText("Email address").should("be.focused");+ cy.clock();++ cy.log("reject invalid credentials");+ [+ { email: admin.email, password: "INVALID" + admin.password },+ { email: "INVALID" + admin.email, password: admin.password },+ ].forEach(({ email, password }) => {+ cy.findByLabelText("Email address").clear();+ cy.findByLabelText("Password").clear();+ cy.findByLabelText("Email address").type(email);+ cy.findByLabelText("Password").type(password);+ cy.button("Sign in").click();+ cy.wait("@signIn").its("response.statusCode").should("eq", 401);+ cy.findByRole("alert")+ .filter(':contains("did not match stored password")')+ .should("be.visible");+ cy.button("Failed").should("be.visible");+ cy.tick(5000);+ cy.button("Sign in").should("be.visible");+ });- it("should allow login regardless of login email case", () => {- cy.visit("/auth/login");+ cy.log("allow login regardless of email case");+ cy.clock().invoke("restore");+ cy.findByLabelText("Email address").clear();+ cy.findByLabelText("Password").clear();cy.findByLabelText("Email address").type(admin.email.toUpperCase());cy.findByLabelText("Password").type(admin.password);+ cy.findByRole("checkbox", { name: "Remember me" }).should("be.checked");+ cy.findByLabelText("Remember me").click();+ cy.findByRole("checkbox", { name: "Remember me" }).should("not.be.checked");cy.button("Sign in").click();+ cy.wait("@signIn").its("response.statusCode").should("eq", 200);cy.findByTestId("greeting-message").should("contain.text", "Bobby");});- it("should allow toggling of Remember Me", () => {- cy.visit("/auth/login");-- // default initial state- cy.findByRole("checkbox").should("be.checked");-- cy.findByLabelText("Remember me").click();- cy.findByRole("checkbox").should("not.be.checked");- });-it("should redirect to an unsaved question after login", () => {cy.signInAsAdmin();cy.visit("/");diff --git a/e2e/test/scenarios/onboarding/auth/sso.cy.spec.js b/e2e/test/scenarios/onboarding/auth/sso.cy.spec.jsindex 6a6f2b6db63..b7575e2ef11 100644--- a/e2e/test/scenarios/onboarding/auth/sso.cy.spec.js+++ b/e2e/test/scenarios/onboarding/auth/sso.cy.spec.js@@ -29,27 +29,14 @@ describe("scenarios > auth > signin > SSO", () => {cy.visit("/");});- it("should show SSO button", () => {- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Sign in with email");-- // Google SSO button is piped through an iframe- cy.get("iframe");- });-- it("should show login form when directed to sign in with email", () => {- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Sign in with email").click();- cy.findByLabelText("Email address");- cy.findByLabelText("Password");- cy.button("Sign in").should("be.disabled");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Sign in with Google");- });-it("should surface login errors with Google sign in enabled (metabase#16122)", () => {+ cy.get("iframe").should("exist");// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText("Sign in with email").click();+ cy.findByLabelText("Email address").should("be.visible");+ cy.findByLabelText("Password").should("be.visible");+ cy.button("Sign in").should("be.disabled");+ H.main().findByText("Sign in with Google").should("be.visible");cy.findByLabelText("Email address").type("[email protected]");cy.findByLabelText("Password").type("123");cy.button("Sign in").click();diff --git a/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts b/e2e/test/scenarios/onboarding/home/browse.cy.spec.tsindex 4b117e5aff3..e9ba8860fef 100644--- a/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts+++ b/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts@@ -204,6 +204,7 @@ describe("scenarios > browse", () => {it("on an open-source instance, the Browse models page has no controls for setting filters", () => {cy.visit("/");H.navigationSidebar().findByLabelText("Browse models").click();+ cy.findByRole("heading", { name: "Orders Model" }).should("be.visible");verifiedFilterToggleButton().should("not.exist");});diff --git a/e2e/test/scenarios/onboarding/home/homepage.cy.spec.js b/e2e/test/scenarios/onboarding/home/homepage.cy.spec.jsindex 9852070f52d..2d44cfe3d2f 100644--- a/e2e/test/scenarios/onboarding/home/homepage.cy.spec.js+++ b/e2e/test/scenarios/onboarding/home/homepage.cy.spec.js@@ -344,6 +344,12 @@ describe("scenarios > home > custom homepage", () => {cy.signInAsAdmin();cy.intercept("GET", "/api/search*").as("search");cy.intercept("PUT", "/api/setting").as("putSettings");+ H.resetSnowplow();+ H.enableTracking();+ });++ afterEach(() => {+ H.expectNoBadSnowplowEvents();});it("should give you the option to set a custom home page in settings", () => {@@ -373,6 +379,11 @@ describe("scenarios > home > custom homepage", () => {"Orders in a dashboard",);+ H.expectUnstructuredSnowplowEvent({+ event: "homepage_dashboard_enabled",+ source: "admin",+ });+cy.log("switching to Default Metabase home should hide the dashboard picker but keep the persisted id",);@@ -458,6 +469,10 @@ describe("scenarios > home > custom homepage", () => {});H.modal().findByRole("button", { name: "Done" }).click();+ H.expectUnstructuredSnowplowEvent({+ event: "homepage_dashboard_enabled",+ source: "homepage",+ });cy.location("pathname").should("equal",`/dashboard/${ORDERS_DASHBOARD_ID}`,@@ -512,6 +527,8 @@ describe("scenarios > home > custom homepage", () => {cy.signIn("nocollection");cy.visit("/");+ cy.findByTestId("home-page").should("be.visible");+ cy.findByTestId("greeting-message").should("be.visible");cy.location("pathname").should("equal", "/");});@@ -637,126 +654,6 @@ describe("scenarios > home > custom homepage", () => {});});-describe("scenarios > setup", () => {- beforeEach(() => {- H.restore();- H.resetSnowplow();- cy.signInAsAdmin();- H.enableTracking();- });-- afterEach(() => {- H.expectNoBadSnowplowEvents();- });-- it("should send snowplow events through admin settings", () => {- cy.intercept("PUT", "/api/setting").as("putSettings");- cy.visit("/admin/settings/general");- cy.findByTestId("homepage-setting")- .findByRole("radio", { name: "Dashboard" })- .click();- cy.wait("@putSettings");- H.undoToast().icon("close").click();-- cy.findByTestId("custom-homepage-dashboard-setting")- .findByRole("button")- .should("be.visible")- .click();-- H.entityPickerModal().findByText("Orders in a dashboard").click();-- H.undoToast().findByText("Changes saved").should("be.visible");-- H.expectUnstructuredSnowplowEvent({- event: "homepage_dashboard_enabled",- source: "admin",- });- });-- it("should send snowplow events through homepage", () => {- cy.visit("/");- cy.get("main").findByText("Customize").click();- H.modal().findByText("Pick a dashboard").click();-- H.entityPickerModal().findByText("Orders in a dashboard").click();- H.modal().findByText("Done").click();- H.expectUnstructuredSnowplowEvent({- event: "homepage_dashboard_enabled",- source: "homepage",- });- });-- it("should track when 'New' button is clicked", () => {- cy.visit("/");-- cy.log("From the app bar");- H.newButton().should("be.visible").click();- cy.findByRole("menu", { name: /new/i }).should("be.visible");- H.expectUnstructuredSnowplowEvent({- event: "new_button_clicked",- triggered_from: "app-bar",- });-- cy.log("Track closing the button as well");- H.newButton().should("be.visible").click();- cy.findByRole("menu", { name: /new/i }).should("not.exist");- H.expectUnstructuredSnowplowEvent(- {- event: "new_button_clicked",- triggered_from: "app-bar",- },- 2,- );-- cy.log("From the empty collection");- H.navigationSidebar().findByText("Your personal collection").click();- cy.findByTestId("collection-empty-state").within(() => {- cy.findByText("This collection is empty").should("be.visible");- cy.findByText("New").click();- });-- cy.findByRole("menu", { name: /new/i }).should("be.visible");- H.expectUnstructuredSnowplowEvent({- event: "new_button_clicked",- triggered_from: "empty-collection",- });- });-- /**- * Until we refactor the NewItem menu component and drop EntityMenu from it,- * the only menu item that can have onClick handler is a "dashboard".- */- it("should track when a 'New' button's menu item is clicked", () => {- cy.visit("/");-- H.newButton().should("be.visible").click();- cy.findByRole("menu", { name: /new/i }).findByText("Dashboard").click();- cy.findByTestId("new-dashboard-modal").should("be.visible");- H.expectUnstructuredSnowplowEvent({- event: "new_button_item_clicked",- triggered_from: "dashboard",- });-- cy.findByTestId("new-dashboard-modal").button("Cancel").click();- cy.findByTestId("new-dashboard-modal").should("not.exist");-- H.navigationSidebar().findByText("Your personal collection").click();- cy.findByTestId("collection-empty-state").within(() => {- cy.findByText("This collection is empty").should("be.visible");- cy.findByText("New").click();- });- cy.findByRole("menu", { name: /new/i }).findByText("Dashboard").click();- cy.findByTestId("new-dashboard-modal").should("be.visible");- H.expectUnstructuredSnowplowEvent(- {- event: "new_button_item_clicked",- triggered_from: "dashboard",- },- 2,- );- });-});-const pinItem = (name) => {cy.findByText(name).closest("tr").icon("ellipsis").click();diff --git a/e2e/test/scenarios/onboarding/i18n.cy.spec.ts b/e2e/test/scenarios/onboarding/i18n.cy.spec.tsnew file mode 100644index 00000000000..a3ffeb788d0--- /dev/null+++ b/e2e/test/scenarios/onboarding/i18n.cy.spec.ts@@ -0,0 +1,110 @@+import { NORMAL_USER_ID } from "e2e/support/cypress_sample_instance_data";+import type { LocaleData } from "metabase-types/api";++const { H } = cy;++const paths = [+ "/",+ "/getting-started",+ "/collection/root",+ "/browse/models",+ "/browse/databases",+ "/browse/metrics",+ "/trash",+ "/admin",+];++const locales = [+ "Chinese (China)",+ "Chinese (Taiwan)",+ "French",+ "German",+ "Italian",+ "Japanese",+ "Korean",+ "Portuguese (Brazil)",+ "Russian",+ "Spanish",+];++describe("Pages accessible within one click from the homepage should work in popular locales", () => {+ before(H.restore);++ beforeEach(() => {+ cy.signInAsNormalUser();+ });++ it("should be able to open the app with every locale from the available locales (metabase#22192)", () => {+ cy.intercept("GET", "/api/user/current").as("getUser");+ cy.request<{ "available-locales": LocaleData[] }>(+ "GET",+ "/api/session/properties",+ ).then(({ body: settings }) => {+ settings["available-locales"].forEach(([locale]) => {+ cy.log(`Using ${locale} locale`);+ cy.request("PUT", `/api/user/${NORMAL_USER_ID}`, { locale });+ cy.visit("/");+ cy.wait("@getUser");+ H.getProfileLink().should("exist");+ });+ });+ });++ locales.forEach((localeName) => {+ it(`Pages should be reachable when locale is ${localeName}`, () => {+ selectLocale(localeName);+ paths.forEach((path) => {+ cy.visit(path);+ if (path === "/admin") {+ cy.location("pathname").should("eq", "/unauthorized");+ H.main().icon("key").should("be.visible");+ H.main().findByRole("status").should("be.visible");+ } else {+ cy.location("pathname").should("eq", path);+ cy.findByRole("main").should("be.visible");+ assertPageContent(path);+ }+ cy.findAllByTestId("error-boundary").should("not.exist");+ });+ });+ });+});++const selectLocale = (localeName: string) => {+ cy.request<{ "available-locales": LocaleData[] }>(+ "GET",+ "/api/session/properties",+ ).then(({ body: settings }) => {+ const locale = settings["available-locales"].find(+ ([, name]) => name === localeName,+ )?.[0];+ expect(locale, localeName).to.be.a("string");+ cy.request("PUT", `/api/user/${NORMAL_USER_ID}`, { locale });+ });+};++function assertPageContent(path: string) {+ switch (path) {+ case "/":+ cy.findByTestId("greeting-message").should("be.visible");+ break;+ case "/getting-started":+ cy.findByTestId("dashboard-item").should("be.visible");+ break;+ case "/collection/root":+ H.collectionTable().should("contain", "Orders");+ break;+ case "/browse/models":+ cy.findByRole("heading", { name: "Orders Model" }).should("be.visible");+ break;+ case "/browse/databases":+ cy.findByTestId("database-browser").should("contain", "Sample Database");+ break;+ case "/browse/metrics":+ H.main().findAllByRole("status").should("be.visible");+ break;+ case "/trash":+ cy.findByTestId("collection-name-heading").should("be.visible");+ break;+ }+}diff --git a/e2e/test/scenarios/onboarding/navbar/new-menu.cy.spec.js b/e2e/test/scenarios/onboarding/navbar/new-menu.cy.spec.jsindex a7ff68c2ec1..7443c5ad6ac 100644--- a/e2e/test/scenarios/onboarding/navbar/new-menu.cy.spec.js+++ b/e2e/test/scenarios/onboarding/navbar/new-menu.cy.spec.js@@ -10,20 +10,78 @@ describe("metabase > scenarios > navbar > new menu", () => {cy.findByText("New").click();});- it("question item opens question notebook editor", () => {+ it("should open the question notebook and SQL query editors", () => {H.popover().within(() => {cy.findByText("Question").click();});- cy.url("should.contain", "/question/notebook#");- });+ cy.location("pathname").should("eq", "/question/notebook");+ H.miniPicker().should("be.visible");- it("question item opens SQL query editor", () => {+ cy.visit("/");+ H.newButton().click();H.popover().within(() => {cy.findByText("SQL query").click();});- cy.url("should.contain", "/question#");+ cy.location("pathname").should("eq", "/question");H.NativeEditor.get().should("be.visible");});});++describe("metabase > scenarios > navbar > new menu tracking", () => {+ beforeEach(() => {+ H.restore();+ H.resetSnowplow();+ cy.signInAsAdmin();+ H.enableTracking();+ });++ afterEach(() => {+ H.expectNoBadSnowplowEvents();+ });++ it("should track opening, closing, and selecting items from both New menus", () => {+ cy.visit("/");+ H.newButton().should("be.visible").click();+ cy.findByRole("menu", { name: /new/i }).should("be.visible");+ H.expectUnstructuredSnowplowEvent({+ event: "new_button_clicked",+ triggered_from: "app-bar",+ });++ H.newButton().click();+ cy.findByRole("menu", { name: /new/i }).should("not.exist");+ H.expectUnstructuredSnowplowEvent(+ { event: "new_button_clicked", triggered_from: "app-bar" },+ 2,+ );++ H.newButton().click();+ cy.findByRole("menu", { name: /new/i }).findByText("Dashboard").click();+ cy.findByTestId("new-dashboard-modal").should("be.visible");+ H.expectUnstructuredSnowplowEvent({+ event: "new_button_item_clicked",+ triggered_from: "dashboard",+ });+ cy.findByTestId("new-dashboard-modal").button("Cancel").click();+ cy.findByTestId("new-dashboard-modal").should("not.exist");++ H.navigationSidebar().findByText("Your personal collection").click();+ cy.findByTestId("collection-empty-state").within(() => {+ cy.findByText("This collection is empty").should("be.visible");+ cy.findByText("New").click();+ });+ cy.findByRole("menu", { name: /new/i }).should("be.visible");+ H.expectUnstructuredSnowplowEvent({+ event: "new_button_clicked",+ triggered_from: "empty-collection",+ });+ cy.findByRole("menu", { name: /new/i }).findByText("Dashboard").click();+ cy.findByTestId("new-dashboard-modal").should("be.visible");+ H.expectUnstructuredSnowplowEvent(+ { event: "new_button_item_clicked", triggered_from: "dashboard" },+ 2,+ );+ });+});diff --git a/e2e/test/scenarios/onboarding/notifications.cy.spec.js b/e2e/test/scenarios/onboarding/notifications.cy.spec.jsindex 919d942d74d..b8287a1b2b2 100644--- a/e2e/test/scenarios/onboarding/notifications.cy.spec.js+++ b/e2e/test/scenarios/onboarding/notifications.cy.spec.js@@ -77,30 +77,6 @@ describe("scenarios > account > notifications", () => {});});- it("should be able to see help info", () => {- openUserNotifications();-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Not seeing one here?").click();-- H.modal().within(() => {- cy.findByText("Not seeing something listed here?");- cy.findByText("Got it").click();- });-- H.modal().should("not.exist");- });-- it("should be able to see alerts notifications", () => {- openUserNotifications();-- cy.findByTestId("notifications-list").within(() => {- cy.findByText("Question");- cy.findByText("Daily at 9:00 am", { exact: false });- cy.findByText("Created by you", { exact: false });- });- });-it("should be able to delete an alert when the user created it and he is a single recipient", () => {openUserNotifications();@@ -110,7 +86,11 @@ describe("scenarios > account > notifications", () => {);cy.intercept("PUT", "/api/notification/*").as("alertDelete");- cy.findByTestId("notifications-list").findByText("Question");+ cy.findByTestId("notifications-list")+ .should("contain", "Question")+ .and("contain", "Check daily at 9:00 AM")+ .and("contain", "Created by you");+ checkNotificationHelp();clickUnsubscribe();@@ -137,7 +117,7 @@ describe("scenarios > account > notifications", () => {.should("exist");H.modal().should("not.exist");- cy.findByTestId("notification-list").should("not.exist");+ cy.findByTestId("notifications-list").should("not.exist");});it("should be able to unsubscribe from an alert when the user has not created it", () => {@@ -235,36 +215,14 @@ describe("scenarios > account > notifications", () => {});});- it("should be able to see help info", () => {- openUserNotifications();-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Not seeing one here?").click();-- H.modal().within(() => {- cy.findByText("Not seeing something listed here?");- cy.findByText("Got it").click();- });-- H.modal().should("not.exist");- });-- it("should be able to see pulses notifications", () => {- openUserNotifications();-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Subscription");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Slack’d hourly", { exact: false });- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Created by you", { exact: false });- });-it("should be able to unsubscribe and delete a pulse when the user has created it", () => {openUserNotifications();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Subscription");+ cy.findByTestId("notifications-list")+ .should("contain", "Subscription")+ .and("contain", "Slack’d hourly")+ .and("contain", "Created by you");+ cy.intercept("PUT", "/api/pulse/*").as("archivePulse");clickUnsubscribe();H.modal().within(() => {@@ -272,8 +230,9 @@ describe("scenarios > account > notifications", () => {cy.findByText("Yes, delete this subscription").click();});- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Subscription").should("not.exist");+ cy.wait("@archivePulse").its("response.body.archived").should("eq", true);+ H.modal().should("not.exist");+ cy.findByTestId("notifications-list").should("not.exist");});});});@@ -289,3 +248,12 @@ function openUserNotifications() {cy.visit("/account/notifications");cy.wait("@loadSubscriptions");}++function checkNotificationHelp() {+ H.main().findByText("Not seeing one here?").click();+ H.modal().within(() => {+ cy.findByText("Not seeing something listed here?").should("be.visible");+ cy.findByRole("button", { name: "Got it" }).click();+ });+ H.modal().should("not.exist");+}diff --git a/e2e/test/scenarios/onboarding/reference/databases.cy.spec.js b/e2e/test/scenarios/onboarding/reference/databases.cy.spec.jsindex 2a066507758..2af9037c129 100644--- a/e2e/test/scenarios/onboarding/reference/databases.cy.spec.js+++ b/e2e/test/scenarios/onboarding/reference/databases.cy.spec.js@@ -10,60 +10,44 @@ describe("scenarios > reference > databases", () => {cy.signInAsAdmin();});- it("should see the listing", () => {+ it("should let an admin browse and edit database details", () => {cy.visit("/reference/databases");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("Sample Database");- });-- xit("should let the user navigate to details", () => {- cy.visit("/reference/databases");- cy.contains("Sample Database").click();- cy.contains("Why this database is interesting");- });-- it("should let an admin edit details about the database", () => {- cy.visit("/reference/databases/1");-- // For some unknown reason, calling .click() causes the form to immediately reset, putting us- // in a state like we never clicked the edit button TODO: Fix+ cy.findByTestId("data-reference-list-item")+ .findByText("Sample Database")+ .click();+ H.main()+ .findByText("Why this database is interesting")+ .should("be.visible");cy.button(/Edit/).trigger("click");- // Q - is there any cleaner way to get a nearby element without having to know the DOM?cy.findByPlaceholderText("No description yet").type("A pretty ok store");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("Save").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("A pretty ok store");+ cy.findByPlaceholderText("Sample Database")+ .clear()+ .type("My definitely profitable business");+ cy.button("Save").click();+ H.main()+ .should("contain", "A pretty ok store")+ .and("contain", "My definitely profitable business");});it("should let an admin start to edit and cancel without saving", () => {cy.visit("/reference/databases/1");- // For some unknown reason, calling .click() causes the form to immediately reset, putting us- // in a state like we never clicked the edit button TODO: Fixcy.button(/Edit/).trigger("click");- // Q - is there any cleaner way to get a nearby element without having to know the DOM?+ cy.findByPlaceholderText("Nothing interesting yet")+ .invoke("val")+ .as("originalInterestingDetails");cy.findByPlaceholderText("Nothing interesting yet").type("Turns out it's not",);- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("Cancel").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("Turns out").should("have.length", 0);- });-- it("should let an admin edit the database name", () => {- cy.visit("/reference/databases/1");- // For some unknown reason, calling .click() causes the form to immediately reset, putting us- // in a state like we never clicked the edit button TODO: Fix+ cy.button("Cancel").click();+ cy.button(/Edit/).should("be.visible");+ H.main().should("not.contain", "Turns out it's not");cy.button(/Edit/).trigger("click");-- cy.findByPlaceholderText("Sample Database")- .clear()- .type("My definitely profitable business");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("Save").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("My definitely profitable business");+ cy.get("@originalInterestingDetails").then((originalValue) => {+ cy.findByPlaceholderText("Nothing interesting yet").should(+ "have.value",+ originalValue,+ );+ });});describe("multiple databases sorting order", () => {@@ -95,8 +79,6 @@ describe("scenarios > reference > databases", () => {"getXrayDashboard",);H.resetSnowplow();- H.restore();- cy.signInAsAdmin();H.enableTracking();});@@ -104,7 +86,7 @@ describe("scenarios > reference > databases", () => {H.expectNoBadSnowplowEvents();});- it("should x-ray a table in a data reference page", () => {+ it("should x-ray a table and a field in data reference pages", () => {cy.visit(`/reference/databases/${SAMPLE_DB_ID}/tables/${PEOPLE_ID}`);cy.findAllByRole("listitem").filter(":contains(X-ray this table)")@@ -116,9 +98,7 @@ describe("scenarios > reference > databases", () => {event_detail: "table",triggered_from: "data_reference",});- });- it("should x-ray a field in a data reference page", () => {cy.visit(`/reference/databases/${SAMPLE_DB_ID}/tables/${PEOPLE_ID}/fields/${PEOPLE.EMAIL}`,);diff --git a/e2e/test/scenarios/onboarding/reference/glossary.cy.spec.ts b/e2e/test/scenarios/onboarding/reference/glossary.cy.spec.tsnew file mode 100644index 00000000000..2f99a612665--- /dev/null+++ b/e2e/test/scenarios/onboarding/reference/glossary.cy.spec.ts@@ -0,0 +1,140 @@+const { H } = cy;++function executeCreateGlossaryTermFlow() {+ cy.intercept("POST", "/api/glossary", (req) => {+ expect(req.body).to.deep.equal({+ term: "Boat",+ definition: "A small vessel for traveling on water.",+ });+ }).as("createGlossary");++ cy.findByRole("button", { name: /new term/i }).click();++ cy.findByPlaceholderText(/boat/i).type(" Boat ");+ cy.findByPlaceholderText(/a small vessel.*/i).type(+ " A small vessel for traveling on water. ",+ );++ cy.findByLabelText("Save").click();++ cy.wait("@createGlossary");++ cy.get("table").within(() => {+ cy.findByText("Boat").should("be.visible");+ cy.findByText("A small vessel for traveling on water.").should(+ "be.visible",+ );+ });+}++function executeUpdateGlossaryTermFlow() {+ cy.intercept("PUT", "/api/glossary/*", (req) => {+ expect(req.body).to.deep.equal({+ term: "Kitten",+ definition: "Young cat",+ });+ }).as("updateGlossary");++ cy.get("table").findByText("Boat").click();+ cy.findByPlaceholderText(/boat/i).clear().type("Kitten");+ cy.findByPlaceholderText(/a small vessel.*/i)+ .clear()+ .type("Young cat");+ cy.findByRole("button", { name: /save/i }).click();+ cy.wait("@updateGlossary");++ cy.get("table").within(() => {+ cy.findByText("Kitten").should("be.visible");+ cy.findByText("Young cat").should("be.visible");+ });+}++function executeDeleteGlossaryTermFlow() {+ cy.intercept("DELETE", "/api/glossary/*").as("deleteGlossary");++ cy.get("table").within(() => {+ cy.findByText("Kitten").should("be.visible").realHover();+ cy.findByRole("button", { name: /delete/i }).click();+ });++ cy.findByRole("dialog").within(() => {+ cy.findByRole("button", { name: /delete/i }).click();+ });++ cy.wait("@deleteGlossary");+ cy.get("table").findByText("Kitten").should("not.exist");+}++describe("data reference > glossary", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ function visitGlossary() {+ cy.visit("/reference/glossary");+ }++ it("fetches existing definitions", () => {+ cy.intercept("GET", "/api/glossary", {+ statusCode: 200,+ body: {+ data: [+ { id: 1, term: "Alpha", definition: "First" },+ { id: 2, term: "Beta", definition: "Second" },+ ],+ can_write: true,+ },+ }).as("getGlossary");++ visitGlossary();++ cy.wait("@getGlossary");+ cy.get("table").within(() => {+ cy.findByText("Alpha").should("be.visible");+ cy.findByText("Beta").should("be.visible");+ });+ });++ it("creates, updates, and deletes definitions with trimmed API values", () => {+ visitGlossary();+ executeCreateGlossaryTermFlow();++ executeUpdateGlossaryTermFlow();++ executeDeleteGlossaryTermFlow();+ });+});++describe("data studio > glossary", () => {+ beforeEach(() => {+ H.restore();+ H.resetSnowplow();+ cy.signInAsAdmin();+ H.activateToken("pro-self-hosted");+ });++ function visitDataStudioGlossary() {+ H.DataModel.visitDataStudio();+ H.DataStudio.nav().findByLabelText("Glossary").click();+ cy.findByRole("heading", { name: "Glossary" }).should("be.visible");+ }++ it("should create, update, and delete definitions and track each operation", () => {+ visitDataStudioGlossary();+ executeCreateGlossaryTermFlow();+ H.expectUnstructuredSnowplowEvent({+ event: "data_studio_glossary_term_created",+ });++ executeUpdateGlossaryTermFlow();+ H.expectUnstructuredSnowplowEvent({+ event: "data_studio_glossary_term_updated",+ });++ executeDeleteGlossaryTermFlow();+ H.expectUnstructuredSnowplowEvent({+ event: "data_studio_glossary_term_deleted",+ });+ });+});diff --git a/e2e/test/scenarios/onboarding/reference/reproductions/5276-remove-field-type.cy.spec.js b/e2e/test/scenarios/onboarding/reference/reproductions/5276-remove-field-type.cy.spec.jsindex c53efeabc5a..900eef660bb 100644--- a/e2e/test/scenarios/onboarding/reference/reproductions/5276-remove-field-type.cy.spec.js+++ b/e2e/test/scenarios/onboarding/reference/reproductions/5276-remove-field-type.cy.spec.js@@ -26,7 +26,10 @@ describe("issue 5276", () => {cy.findByDisplayValue("Score").click();H.popover().findByText("No semantic type").click();cy.button("Save").click();- cy.wait("@updateField");+ cy.wait("@updateField")+ .its("response.body.semantic_type")+ .should("eq", null);+ cy.button(/Edit/).trigger("click");cy.findByDisplayValue("Score").should("not.exist");});});diff --git a/e2e/test/scenarios/onboarding/setup/setup.cy.spec.ts b/e2e/test/scenarios/onboarding/setup/setup.cy.spec.tsindex 9b8ec4e2b19..6b46426d05d 100644--- a/e2e/test/scenarios/onboarding/setup/setup.cy.spec.ts+++ b/e2e/test/scenarios/onboarding/setup/setup.cy.spec.ts@@ -265,37 +265,6 @@ describe("scenarios > setup", () => {cy.findByTestId("step-number").should("have.text", "4");});- it("should allow a quick setup for the 'embedding' use case", () => {- cy.visit(- "/setup?first_name=John&last_name=Doe&[email protected]&site_name=Doe%20Unlimited&use_case=embedding",- );-- cy.findByTestId("step-number").should("have.text", "1");-- cy.findByTestId("setup-forms").within(() => {- const password = "12341234";- cy.findByDisplayValue("John").should("exist");- cy.findByLabelText("Create a password").type(password);- cy.findByLabelText("Confirm your password").type(password);- cy.button("Next").click();- });-- cy.findByTestId("setup-forms").within(() => {- cy.findByLabelText("Hi, John. Nice to meet you!").should("be.visible");-- skipLicenseStepOnEE();-- cy.findByText("Finish").click();- cy.findByText("You're all set up!").should("be.visible");- cy.findByText("Take me to Metabase").click();- });-- cy.location("pathname").should("eq", "/");- H.main()- .findByText("Get started with Embedding Metabase in your app")- .should("be.visible");- });-// There are only one step in the setup flow, so there is no need to show step numbers.it("should not show step numbers in cloud embedding use case", () => {H.mockSessionProperty("is-hosted?", true);@@ -309,43 +278,6 @@ describe("scenarios > setup", () => {cy.findByTestId("step-number").should("not.exist");});- it("should allow localization in the 'embedding' setup flow", () => {- cy.visit(- "/setup?first_name=John&last_name=Doe&[email protected]&site_name=Doe%20Unlimited&use_case=embedding",- );-- cy.log("Change language to English (ZZ)");- selectLanguage("English (ZZ)");-- cy.log("Changing a language should be applied immediately");- cy.findByTestId("setup-forms").within(() => {- const password = "12341234";- cy.findByDisplayValue("John").should("exist");- cy.findByLabelText("[zz] Create a password").type(password);- cy.findByLabelText("[zz] Confirm your password").type(password);- cy.button("[zz] Next").click();- });-- cy.findByTestId("setup-forms").within(() => {- cy.findByLabelText("[zz] Hi, John. Nice to meet you!").should(- "be.visible",- );-- if (IS_ENTERPRISE) {- cy.button("[zz] I'll activate later").click();- }-- cy.findByText("[zz] Finish").click();- cy.findByText("[zz] Take me to Metabase").click();- });-- cy.log("Locale is preserved upon successful setup");- cy.location("pathname").should("eq", "/");- H.main()- .findByText("[zz] Get started with Embedding Metabase in your app")- .should("be.visible");- });-it("should update the site locale setting when changing language in setup", () => {cy.intercept("PUT", "/api/setting/site-locale").as("updateSiteLocale");@@ -353,6 +285,8 @@ describe("scenarios > setup", () => {"/setup?first_name=John&last_name=Doe&[email protected]&site_name=Doe%20Unlimited&use_case=embedding",);+ cy.findByTestId("step-number").should("have.text", "1");+cy.log("Switching language before user creation should not update setting");selectLanguage("Dutch");// A real translation, so a catalogue that never loads fails the test. The@@ -386,9 +320,13 @@ describe("scenarios > setup", () => {cy.findByTestId("setup-forms").within(() => {if (IS_ENTERPRISE) {+ cy.findByText("[zz] Activate your commercial license").should(+ "be.visible",+ );cy.findByText("[zz] I'll activate later").click();}cy.findByText("[zz] Finish").click();+ cy.findByText("[zz] You're all set up!").should("be.visible");cy.findByText("[zz] Take me to Metabase").click();});@@ -953,6 +891,8 @@ describe("scenarios > setup", () => {H.blockSnowplow();cy.visit("/setup");skipWelcomePage();+ cy.findByLabelText("First name").should("be.visible");+ cy.findByLabelText("Email").should("be.visible");H.assertNoUnstructuredSnowplowEvent({event: "step_seen",});diff --git a/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.js b/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.jsindex 696410f0f3b..d9f12af3010 100644--- a/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.js+++ b/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.js@@ -14,55 +14,40 @@ describe("user > settings", () => {cy.signInAsNormalUser();});- it("should be able to remove first name and last name (metabase#22754)", () => {+ it("should show, update, and clear user details without fetching memberships (metabase#22754)", () => {+ cy.intercept("GET", "/api/permissions/membership").as("membership");+ cy.intercept("PUT", "/api/user/*").as("updateUser");cy.visit("/account/profile");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText(fullName);+ cy.findByTestId("account-header").within(() => {+ cy.findByText(fullName).should("be.visible");+ cy.findByText(email).should("be.visible");+ cy.findByRole("tab", { name: "Authentication" }).should("be.visible");+ });+ cy.findByDisplayValue(first_name).should("be.visible");+ cy.findByDisplayValue(last_name).should("be.visible");+ cy.findByDisplayValue(email).should("be.visible");+ cy.button("Update").should("be.disabled");+ cy.findByLabelText("First name").clear().type("John");+ cy.clock(Date.now(), ["setTimeout", "clearTimeout"]);+ cy.button("Update").click();+ cy.wait("@updateUser").its("response.statusCode").should("eq", 200);+ cy.button("Success").should("be.visible");+ cy.tick(5000);+ cy.button("Update").should("be.visible");+ cy.clock().then((clock) => clock.restore());+ cy.findByTestId("account-header").should("contain", `John ${last_name}`);+ cy.findByDisplayValue("John").should("be.visible");+ cy.get("@membership.all").should("have.length", 0);+cy.findByLabelText("First name").clear();cy.findByLabelText("Last name").clear();cy.button("Update").click();-+ cy.wait("@updateUser").its("response.statusCode").should("eq", 200);cy.reload();-cy.findByLabelText("First name").should("be.empty");cy.findByLabelText("Last name").should("be.empty");});- it("should show user details with disabled submit button", () => {- cy.visit("/account/profile");- cy.findByTestId("account-header").within(() => {- cy.findByText(fullName);- cy.findByText(email);- });- cy.findByDisplayValue(first_name);- cy.findByDisplayValue(last_name);- cy.findByDisplayValue(email);- cy.button("Update").should("be.disabled");- });-- it("should update the user without fetching memberships", () => {- cy.intercept("GET", "/api/permissions/membership").as("membership");- cy.visit("/account/profile");- cy.findByDisplayValue(first_name).click().clear().type("John");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Update").click();- cy.findByDisplayValue("John");-- // It is hard and unreliable to assert that something didn't happen in Cypress- // This solution was the only one that worked out of all others proposed in this SO topic: https://stackoverflow.com/a/59302542/8815185- cy.get("@membership.all").should("have.length", 0);- });-- it("should have an authentication tab", () => {- cy.intercept("GET", "/api/user/current").as("getUser");-- cy.visit("/account/profile");- cy.wait("@getUser");- cy.findByTestId("account-header")- .findByRole("tab", { name: "Authentication" })- .should("be.visible");- });-it("should redirect to the login page when the user has signed out but tries to visit `/account/profile` (metabase#15471)", () => {cy.signOut();cy.visit("/account/profile");@@ -71,25 +56,7 @@ describe("user > settings", () => {cy.findByText("Sign in to Metabase");});- it("should redirect to the login page when the user has changed the password and logged out (metabase#18151)", () => {- cy.visit("/account/password");-- cy.findByLabelText("Current password").type(password);- cy.findByLabelText("Create a password").type(password);- cy.findByLabelText("Confirm your password").type(password);- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Save").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Success");-- H.getProfileLink().click();- H.popover().findByText("Sign out").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Sign in to Metabase");- });-- it("should validate form values (metabase#23259)", () => {- cy.signInAsNormalUser();+ it("should validate passwords and redirect after saving and signing out (metabase#23259, metabase#18151)", () => {cy.visit("/account/password");// Validate common passwords@@ -113,6 +80,17 @@ describe("user > settings", () => {cy.button("Save").click();// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.contains("Invalid password");++ cy.findByLabelText("Current password").clear().type(password);+ cy.findByLabelText("Create a password").clear().type(password);+ cy.findByLabelText("Confirm your password").clear().type(password);+ cy.button("Save").click();+ H.main().findByText("Success").should("be.visible");+ H.getProfileLink().click();+ H.popover().findByText("Sign out").click();+ cy.findByRole("heading", { name: "Sign in to Metabase" }).should(+ "be.visible",+ );});it("should be able to change a language (metabase#22192)", () => {@@ -135,24 +113,6 @@ describe("user > settings", () => {H.getProfileLink().should("exist");});- it("should be able to open the app with every locale from the available locales (metabase#22192)", () => {- cy.request("GET", "/api/user/current").then(({ body: user }) => {- cy.intercept("GET", "/api/user/current").as("getUser");-- cy.request("GET", "/api/session/properties").then(- ({ body: settings }) => {- cy.wrap(settings["available-locales"]).each(([locale]) => {- cy.log(`Using ${locale} locale`);- cy.request("PUT", `/api/user/${user.id}`, { locale });- cy.visit("/");- cy.wait("@getUser");- H.getProfileLink().should("exist");- });- },- );- });- });-it("should show correct translations when a user logs in with a locale that is different from the site locale", () => {cy.intercept("GET", "/api/user/current").as("getUser");cy.request("PUT", `/api/user/${NORMAL_USER_ID}`, { locale: "fr" });@@ -173,76 +133,26 @@ describe("user > settings", () => {cy.findByTestId("step-summarize-0-0").findByText("Résumer").should("exist");});- describe("when user is authenticated via ldap", () => {- beforeEach(() => {- stubCurrentUser({ sso_source: "ldap" });-- cy.visit("/account/profile");- cy.wait("@getUser");- });-- it("should hide change password tab", () => {- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Password").should("not.exist");- });- });-- describe("when user is authenticated via google", () => {- beforeEach(() => {- stubCurrentUser({ sso_source: "google" });-- cy.visit("/account/profile");- cy.wait("@getUser");- });-- it("should hide change password tab", () => {- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Password").should("not.exist");- });-- it("should hide first name, last name, and email input (metabase#23298)", () => {- cy.findByLabelText("First name").should("not.exist");- cy.findByLabelText("Last name").should("not.exist");- cy.findByLabelText("Email").should("not.exist");- });- });-- describe("when user is authenticated via JWT", () => {- beforeEach(() => {- stubCurrentUser({ sso_source: "jwt" });-+ ["ldap", "google", "jwt", "saml"].forEach((ssoSource) => {+ it(`should prevent ${ssoSource} users from editing SSO credentials (metabase#23298)`, () => {+ stubCurrentUser({ sso_source: ssoSource });cy.visit("/account/profile");cy.wait("@getUser");- });-- it("should hide change password tab", () => {- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Password").should("not.exist");- });-- it("should hide first name, last name, and email input (metabase#23298)", () => {+ cy.findByTestId("account-header").should("contain", email);+ cy.findByTestId("user-locale-select").should("be.visible");+ cy.findByTestId("account-header")+ .findByRole("tab", { name: "Authentication" })+ .should("not.exist");cy.findByLabelText("First name").should("not.exist");cy.findByLabelText("Last name").should("not.exist");cy.findByLabelText("Email").should("not.exist");- });- });- describe("when user is authenticated via SAML", () => {- beforeEach(() => {- stubCurrentUser({ sso_source: "saml" });- cy.visit("/account/profile");+ cy.visit("/account/password");cy.wait("@getUser");- });-- it("should hide change password tab", () => {- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Password").should("not.exist");- });-- it("should hide first name, last name, and email input (metabase#23298)", () => {- cy.findByLabelText("First name").should("not.exist");- cy.findByLabelText("Last name").should("not.exist");- cy.findByLabelText("Email").should("not.exist");+ cy.findByTestId("account-header").should("contain", email);+ cy.findByLabelText("Current password").should("not.exist");+ cy.findByLabelText("Create a password").should("not.exist");+ cy.findByLabelText("Confirm your password").should("not.exist");});});