Skip to content

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

Consolidate navigation e2e tests (#83541)

Chris Vandoodewaard935be20efc6a
diff --git a/e2e/test/scenarios/data-studio/table-collection-permissions.cy.spec.ts b/e2e/test/scenarios/data-studio/table-collection-permissions.cy.spec.ts
index 2f4944fe134..52dcdbd2f6a 100644
--- a/e2e/test/scenarios/data-studio/table-collection-permissions.cy.spec.ts
+++ b/e2e/test/scenarios/data-studio/table-collection-permissions.cy.spec.ts
@@ -296,6 +296,7 @@ describe("scenarios > data studio > table collection permissions", () => {
cy.findByText("Reviews").should("be.visible");
cy.findByText("Orders").click();
});
+ H.queryBuilderHeader().findByText("Orders").should("be.visible");
H.tableInteractive().should("be.visible");
H.tableHeaderColumn("Product ID").should("be.visible");
});
diff --git a/e2e/test/scenarios/onboarding/home/homepage.cy.spec.js b/e2e/test/scenarios/onboarding/home/homepage.cy.spec.js
index 2d44cfe3d2f..9351dedc040 100644
--- a/e2e/test/scenarios/onboarding/home/homepage.cy.spec.js
+++ b/e2e/test/scenarios/onboarding/home/homepage.cy.spec.js
@@ -607,7 +607,7 @@ describe("scenarios > home > custom homepage", () => {
);
});
- it("should not redirect when already on the dashboard homepage (metabase#43800)", () => {
+ it("should preserve navbar state and avoid redirecting from the dashboard homepage (metabase#43800)", () => {
cy.intercept(
"GET",
`/api/dashboard/${ORDERS_DASHBOARD_ID}/query_metadata*`,
@@ -634,6 +634,13 @@ describe("scenarios > home > custom homepage", () => {
"equal",
`/dashboard/${ORDERS_DASHBOARD_ID}`,
);
+
+ cy.visit("/collection/root");
+ H.navigationSidebar().should("be.visible");
+ cy.findByTestId("main-logo-link").click();
+ cy.location("pathname").should("eq", `/dashboard/${ORDERS_DASHBOARD_ID}`);
+ H.dashboardGrid().should("be.visible");
+ H.navigationSidebar().should("be.visible");
});
it("should not load the homepage dashboard when visiting another dashboard directly (metabase#43800)", () => {
diff --git a/e2e/test/scenarios/navigation/navbar.cy.spec.js b/e2e/test/scenarios/onboarding/navbar/navbar.cy.spec.js
similarity index 50%
rename from e2e/test/scenarios/navigation/navbar.cy.spec.js
rename to e2e/test/scenarios/onboarding/navbar/navbar.cy.spec.js
index a1dd18c6718..7eb385eab55 100644
--- a/e2e/test/scenarios/navigation/navbar.cy.spec.js
+++ b/e2e/test/scenarios/onboarding/navbar/navbar.cy.spec.js
@@ -2,6 +2,7 @@ const { H } = cy;
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import {
ORDERS_DASHBOARD_ID,
+ ORDERS_QUESTION_ID,
THIRD_COLLECTION_ID,
} from "e2e/support/cypress_sample_instance_data";
@@ -14,12 +15,7 @@ describe("scenarios > navigation > navbar", () => {
cy.signInAsNormalUser();
});
- it("should be open after logging in", () => {
- cy.visit("/");
- H.navigationSidebar().should("be.visible");
- });
-
- it("should highlight relevant entities when navigating", () => {
+ it("should highlight entities, preserve state on logo and breadcrumb clicks, and show errors", () => {
const questionName = "Bookmarked question";
H.createQuestion(
{
@@ -49,123 +45,73 @@ describe("scenarios > navigation > navbar", () => {
H.openNavigationSidebar();
H.assertNavigationSidebarItemSelected(/Third collection/, "false");
H.assertNavigationSidebarBookmarkSelected(questionName, "false");
- });
-
- it("should display error ui when data fetching fails", () => {
- cy.intercept("GET", "/api/database", (req) => req.reply(500));
- cy.visit("/");
- H.navigationSidebar().findByText(/An error occurred/);
- });
- it("state should preserve when clicking the mb logo", () => {
cy.visit("/collection/root");
H.navigationSidebar().should("be.visible");
cy.findByTestId("main-logo-link").click();
+ cy.location("pathname").should("eq", "/");
+ cy.findByTestId("home-page").should("be.visible");
H.navigationSidebar().should("be.visible");
H.visitDashboard(ORDERS_DASHBOARD_ID);
H.navigationSidebar().should("not.be.visible");
cy.findByTestId("main-logo-link").click();
+ cy.location("pathname").should("eq", "/");
+ cy.findByTestId("home-page").should("be.visible");
H.navigationSidebar().should("not.be.visible");
- });
- it("should close when visiting a dashboard", () => {
- H.visitDashboard(ORDERS_DASHBOARD_ID);
- H.navigationSidebar().should("not.be.visible");
- });
-
- it("should preserve state when visiting a collection", () => {
H.visitDashboard(ORDERS_DASHBOARD_ID);
H.navigationSidebar().should("not.be.visible");
H.appBar().contains("Our analytics").parentsUntil("a").first().click();
+ cy.location("pathname").should("eq", "/collection/root");
+ cy.findByTestId("collection-name-heading").should(
+ "have.text",
+ "Our analytics",
+ );
H.navigationSidebar().should("not.be.visible");
- });
-
- it("should close when creating a new question", () => {
- cy.visit("/");
- H.navigationSidebar().should("be.visible");
- H.appBar().findByText("New").click();
- H.popover()
- .findByText(/Question/)
- .click();
- H.navigationSidebar().should("not.be.visible");
- });
- it("should close when opening a sql editor", () => {
+ cy.intercept("GET", "/api/database", (req) => req.reply(500));
cy.visit("/");
- H.navigationSidebar().should("be.visible");
- H.appBar().findByText("New").click();
- H.popover()
- .findByText(/SQL query/)
- .click();
- H.navigationSidebar().should("not.be.visible");
+ H.navigationSidebar().findByText(/An error occurred/);
});
});
- describe("Custom Homepage", () => {
+ describe("EE", () => {
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
- H.updateSetting("custom-homepage", true);
- H.updateSetting("custom-homepage-dashboard", ORDERS_DASHBOARD_ID);
+ H.activateToken("pro-self-hosted");
});
- it("should be open when visiting home with a custom home page configured", () => {
+ it("should preserve sidebar state when redirecting to the landing page", () => {
+ H.updateSetting("landing-page", `/question/${ORDERS_QUESTION_ID}`);
cy.visit("/");
- cy.url().should("contain", "/dashboard/");
+ cy.location("pathname").should(
+ "match",
+ new RegExp(`^/question/${ORDERS_QUESTION_ID}\\b`),
+ );
+ H.queryBuilderHeader().findByText("Orders").should("be.visible");
H.navigationSidebar().should("be.visible");
- cy.findByTestId("main-logo-link").click();
+ cy.visit("/collection/root");
H.navigationSidebar().should("be.visible");
- });
-
- it("should preserve state when clicking the mb logo and custom home page is configured", () => {
- H.visitDashboard(ORDERS_DASHBOARD_ID);
- H.navigationSidebar().should("not.be.visible");
cy.findByTestId("main-logo-link").click();
- H.navigationSidebar().should("not.be.visible");
- });
- });
-
- describe("EE", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.activateToken("pro-self-hosted");
- });
-
- it("should be open when logging in with a landing page configured", () => {
- H.updateSetting("landing-page", "/question/76");
- cy.visit("/");
- cy.url().should("contain", "question");
+ cy.location("pathname").should(
+ "match",
+ new RegExp(`^/question/${ORDERS_QUESTION_ID}\\b`),
+ );
+ H.queryBuilderHeader().findByText("Orders").should("be.visible");
H.navigationSidebar().should("be.visible");
- });
- it("should preserve state when clicking the mb logo and landing page is configured", () => {
- H.updateSetting("landing-page", "/question/76");
H.visitDashboard(ORDERS_DASHBOARD_ID);
- cy.findByTestId("main-logo-link").click();
H.navigationSidebar().should("not.be.visible");
- });
- });
-
- describe("library", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.activateToken("pro-self-hosted");
- });
-
- it("should show the library when a table is published", () => {
- H.createLibrary();
- H.publishTables({ table_ids: [ORDERS_ID] });
- cy.visit("/");
- H.navigationSidebar()
- .findByRole("section", { name: "Library" })
- .findByText("Data")
- .click();
- H.collectionTable().findByText("Orders").click();
+ cy.findByTestId("main-logo-link").click();
+ cy.location("pathname").should(
+ "match",
+ new RegExp(`^/question/${ORDERS_QUESTION_ID}\\b`),
+ );
H.queryBuilderHeader().findByText("Orders").should("be.visible");
+ H.navigationSidebar().should("not.be.visible");
});
});
});
diff --git a/e2e/test/scenarios/onboarding/navbar/new-menu.cy.spec.js b/e2e/test/scenarios/onboarding/navbar/new-menu.cy.spec.js
index 7443c5ad6ac..4c81e3faee0 100644
--- a/e2e/test/scenarios/onboarding/navbar/new-menu.cy.spec.js
+++ b/e2e/test/scenarios/onboarding/navbar/new-menu.cy.spec.js
@@ -6,19 +6,22 @@ describe("metabase > scenarios > navbar > new menu", () => {
cy.signInAsAdmin();
cy.visit("/");
+ H.navigationSidebar().should("be.visible");
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
cy.findByText("New").click();
});
- it("should open the question notebook and SQL query editors", () => {
+ it("should open the question notebook and SQL query editors and close the navbar", () => {
H.popover().within(() => {
cy.findByText("Question").click();
});
cy.location("pathname").should("eq", "/question/notebook");
H.miniPicker().should("be.visible");
+ H.navigationSidebar().should("not.be.visible");
cy.visit("/");
+ H.navigationSidebar().should("be.visible");
H.newButton().click();
H.popover().within(() => {
cy.findByText("SQL query").click();
@@ -26,6 +29,7 @@ describe("metabase > scenarios > navbar > new menu", () => {
cy.location("pathname").should("eq", "/question");
H.NativeEditor.get().should("be.visible");
+ H.navigationSidebar().should("not.be.visible");
});
});