From 55aa8c702e47c581539f4cbf33df4e2bd50768a7 Mon Sep 17 00:00:00 2001 From: Zach Wasserman Date: Sun, 3 Oct 2021 11:15:58 -0700 Subject: [PATCH] Use new home dashboard (#2212) Adapted from @RachelElysia's original #1640. --- changes/homepage | 1 + cypress.json | 1 + cypress/integration/all/app/hosts.spec.ts | 4 +- .../integration/all/sessions/sessions.spec.ts | 4 +- cypress/integration/all/sessions/sso.spec.ts | 4 +- cypress/integration/free/admin.spec.ts | 2 +- cypress/integration/free/maintainer.spec.ts | 2 +- cypress/integration/free/observer.spec.ts | 2 +- cypress/integration/premium/admin.spec.ts | 2 +- .../integration/premium/maintainer.spec.ts | 2 +- cypress/integration/premium/observer.spec.ts | 171 +++++++++--------- .../premium/team_maintainer_observer.spec.ts | 4 +- .../AuthenticatedAdminRoutes.tests.js | 3 +- .../side_panels/SiteTopNav/navItems.js | 4 +- frontend/pages/LoginPage/LoginPage.tests.jsx | 3 +- .../RegistrationPage.tests.jsx | 5 +- frontend/router/index.tsx | 6 +- frontend/router/paths.ts | 4 +- 18 files changed, 112 insertions(+), 112 deletions(-) create mode 100644 changes/homepage diff --git a/changes/homepage b/changes/homepage new file mode 100644 index 000000000..3616a1dac --- /dev/null +++ b/changes/homepage @@ -0,0 +1 @@ +* Update default homepage to new dashboard. diff --git a/cypress.json b/cypress.json index b15968f2d..17a50beb3 100644 --- a/cypress.json +++ b/cypress.json @@ -8,3 +8,4 @@ "openMode": 0 } } + diff --git a/cypress/integration/all/app/hosts.spec.ts b/cypress/integration/all/app/hosts.spec.ts index 613198907..a0723e987 100644 --- a/cypress/integration/all/app/hosts.spec.ts +++ b/cypress/integration/all/app/hosts.spec.ts @@ -25,7 +25,7 @@ describe( }, }, () => { - cy.visit("/"); + cy.visit("/hosts/manage"); cy.contains("button", /add new host/i).click(); @@ -50,7 +50,7 @@ describe( // testing, but may vary by environment). cy.waitUntil( () => { - cy.visit("/"); + cy.visit("/hosts/manage"); return Cypress.$('button[title="Online"]').length > 0; }, { timeout: 30000, interval: 1000 } diff --git a/cypress/integration/all/sessions/sessions.spec.ts b/cypress/integration/all/sessions/sessions.spec.ts index d00a28145..ca09ac211 100644 --- a/cypress/integration/all/sessions/sessions.spec.ts +++ b/cypress/integration/all/sessions/sessions.spec.ts @@ -15,8 +15,8 @@ describe("Sessions", () => { cy.get("button").click(); // Verify dashboard - cy.url().should("include", "/hosts/manage"); - cy.contains("All Hosts"); + cy.url().should("include", "/dashboard"); + cy.contains("Host"); // Log out cy.get(".avatar").first().click(); diff --git a/cypress/integration/all/sessions/sso.spec.ts b/cypress/integration/all/sessions/sso.spec.ts index f8d25855d..5e36a57fd 100644 --- a/cypress/integration/all/sessions/sso.spec.ts +++ b/cypress/integration/all/sessions/sso.spec.ts @@ -17,8 +17,8 @@ describe("SSO Sessions", () => { cy.contains("button", "Login").click(); // Verify dashboard - cy.url().should("include", "/hosts/manage"); - cy.contains("All Hosts"); + cy.url().should("include", "/dashboard"); + cy.contains("Hosts"); // Log out cy.get(".avatar").first().click(); diff --git a/cypress/integration/free/admin.spec.ts b/cypress/integration/free/admin.spec.ts index d76ab7746..d232e7fe4 100644 --- a/cypress/integration/free/admin.spec.ts +++ b/cypress/integration/free/admin.spec.ts @@ -19,7 +19,7 @@ describe( it("Can perform the appropriate free-tier admin actions", () => { cy.login("anna@organization.com", "user123#"); - cy.visit("/"); + cy.visit("/hosts/manage"); // Ensure page is loaded cy.contains("All hosts"); diff --git a/cypress/integration/free/maintainer.spec.ts b/cypress/integration/free/maintainer.spec.ts index 4c24e4506..244ae197b 100644 --- a/cypress/integration/free/maintainer.spec.ts +++ b/cypress/integration/free/maintainer.spec.ts @@ -19,7 +19,7 @@ describe( it("Can perform the appropriate core global maintainer actions", () => { cy.login("mary@organization.com", "user123#"); - cy.visit("/"); + cy.visit("/hosts/manage"); // Ensure page is loaded // cy.wait(3000); // eslint-disable-line cypress/no-unnecessary-waiting diff --git a/cypress/integration/free/observer.spec.ts b/cypress/integration/free/observer.spec.ts index 253ceb2cf..22b1ab19b 100644 --- a/cypress/integration/free/observer.spec.ts +++ b/cypress/integration/free/observer.spec.ts @@ -14,7 +14,7 @@ describe("Free tier - Observer user", () => { it("Can perform the appropriate free global observer actions", () => { cy.login("oliver@organization.com", "user123#"); - cy.visit("/"); + cy.visit("/hosts/manage"); // Ensure page is loaded cy.contains("All hosts"); diff --git a/cypress/integration/premium/admin.spec.ts b/cypress/integration/premium/admin.spec.ts index f61c4262e..7e8c58b2a 100644 --- a/cypress/integration/premium/admin.spec.ts +++ b/cypress/integration/premium/admin.spec.ts @@ -26,7 +26,7 @@ describe( }, () => { cy.login("anna@organization.com", "user123#"); - cy.visit("/"); + cy.visit("/hosts/manage"); // Ensure the hosts page is loaded cy.contains("All hosts"); diff --git a/cypress/integration/premium/maintainer.spec.ts b/cypress/integration/premium/maintainer.spec.ts index a94c344b0..884c1ec81 100644 --- a/cypress/integration/premium/maintainer.spec.ts +++ b/cypress/integration/premium/maintainer.spec.ts @@ -19,7 +19,7 @@ describe( it("Can perform the appropriate basic global maintainer actions", () => { cy.login("mary@organization.com", "user123#"); - cy.visit("/"); + cy.visit("/hosts/manage"); // Ensure page is loaded cy.contains("All hosts"); diff --git a/cypress/integration/premium/observer.spec.ts b/cypress/integration/premium/observer.spec.ts index 078dfdfb1..19ca76767 100644 --- a/cypress/integration/premium/observer.spec.ts +++ b/cypress/integration/premium/observer.spec.ts @@ -1,97 +1,92 @@ -describe( - "Premium tier - Observer user", - { - defaultCommandTimeout: 20000, - }, - () => { - beforeEach(() => { - cy.setup(); - cy.login(); - cy.seedPremium(); - cy.seedQueries(); - cy.addDockerHost("apples"); - cy.logout(); +describe("Premium tier - Observer user", () => { + beforeEach(() => { + cy.setup(); + cy.login(); + cy.seedPremium(); + cy.seedQueries(); + cy.addDockerHost("apples"); + cy.logout(); + }); + + afterEach(() => { + cy.stopDockerHost(); + }); + + it("Can perform the appropriate basic global observer actions", () => { + cy.login("oliver@organization.com", "user123#"); + // Host manage page: Can see team column + cy.visit("/hosts/manage"); + + // Ensure page is loaded + cy.wait(5000); // eslint-disable-line cypress/no-unnecessary-waiting + cy.contains("All hosts"); + + cy.get("thead").within(() => { + cy.findByText(/team/i).should("exist"); }); - afterEach(() => { - cy.stopDockerHost(); + // Host details page: Can see team on host + cy.get("tbody").within(() => { + // Test host text varies + cy.findByRole("button").click(); }); - - it("Can perform the appropriate basic global observer actions", () => { - cy.login("oliver@organization.com", "user123#"); - // Host manage page: Can see team column - cy.visit("/hosts/manage"); - - // Ensure page is loaded - cy.wait(5000); // eslint-disable-line cypress/no-unnecessary-waiting - cy.contains("All hosts"); - - cy.get("thead").within(() => { - cy.findByText(/team/i).should("exist"); - }); - - // Host details page: Can see team on host - cy.get("tbody").within(() => { - // Test host text varies - cy.findByRole("button").click(); - }); - cy.get(".title").within(() => { - cy.findByText("Team").should("exist"); - }); - cy.contains("button", /transfer/i).should("not.exist"); - cy.contains("button", /delete/i).should("not.exist"); - cy.contains("button", /query/i).click(); - cy.contains("button", /create custom query/i).should("not.exist"); - - // Not see the “Show enroll secret” button - cy.contains("button", /show enroll secret/i).should("not.exist"); - - // TODO - Fix tests according to improved query experience - MP - // Query pages: Can see team in select targets dropdown - // cy.visit("/queries/manage"); - - // cy.findByText(/detect presence/i).click(); - - // cy.findByRole("button", { name: /run/i }).click(); - - // cy.get(".target-select").within(() => { - // cy.findByText(/Label name, host name, IP address, etc./i).click(); - // cy.findByText(/teams/i).should("exist"); - // }); + cy.get(".title").within(() => { + cy.findByText("Team").should("exist"); }); + cy.contains("button", /transfer/i).should("not.exist"); + cy.contains("button", /delete/i).should("not.exist"); + cy.contains("button", /query/i).click(); + cy.contains("button", /create custom query/i).should("not.exist"); - // Pseudo code for team observer only - // TODO: Rebuild this test according to new manual QA - it("Can perform the appropriate basic team observer only actions", () => { - cy.login("toni@organization.com", "user123#"); - cy.visit("/hosts/manage"); - cy.wait(3000); // eslint-disable-line cypress/no-unnecessary-waiting + // Not see the “Show enroll secret” button + cy.contains("button", /show enroll secret/i).should("not.exist"); - cy.findByText("Hosts").should("exist"); + // TODO - Fix tests according to improved query experience - MP + // Query pages: Can see team in select targets dropdown + // cy.visit("/queries/manage"); - // Nav restrictions - cy.findByText(/settings/i).should("not.exist"); - cy.findByText(/schedule/i).should("not.exist"); - cy.visit("/settings/organization"); - cy.findByText(/you do not have permissions/i).should("exist"); - cy.visit("/packs/manage"); - cy.findByText(/you do not have permissions/i).should("exist"); - cy.visit("/schedule/manage"); - cy.findByText(/you do not have permissions/i).should("exist"); + // cy.findByText(/detect presence/i).click(); - cy.contains(".table-container .data-table__table th", "Team").should( - "be.visible" - ); + // cy.findByRole("button", { name: /run/i }).click(); - // On the Profile page, they should… - // See Global in the Team section and Observer in the Role section - cy.visit("/profile"); - cy.findByText(/team/i) - .next() - .contains(/apples/i); - cy.findByText("Role") - .next() - .contains(/observer/i); - }); - } -); + // cy.get(".target-select").within(() => { + // cy.findByText(/Label name, host name, IP address, etc./i).click(); + // cy.findByText(/teams/i).should("exist"); + // }); + }); + + // Pseudo code for team observer only + // TODO: Rebuild this test according to new manual QA + it("Can perform the appropriate basic team observer only actions", () => { + cy.login("toni@organization.com", "user123#"); + cy.visit("/hosts/manage"); + cy.wait(3000); // eslint-disable-line cypress/no-unnecessary-waiting + + cy.findByText("Hosts").should("exist"); + + // Nav restrictions + cy.findByText(/settings/i).should("not.exist"); + cy.findByText(/schedule/i).should("not.exist"); + cy.visit("/settings/organization"); + cy.findByText(/you do not have permissions/i).should("exist"); + cy.visit("/packs/manage"); + cy.findByText(/you do not have permissions/i).should("exist"); + cy.visit("/schedule/manage"); + cy.findByText(/you do not have permissions/i).should("exist"); + + cy.visit("/hosts/manage"); + cy.contains(".table-container .data-table__table th", "Team").should( + "be.visible" + ); + + // On the Profile page, they should… + // See Global in the Team section and Observer in the Role section + cy.visit("/profile"); + cy.findByText(/team/i) + .next() + .contains(/apples/i); + cy.findByText("Role") + .next() + .contains(/observer/i); + }); +}); diff --git a/cypress/integration/premium/team_maintainer_observer.spec.ts b/cypress/integration/premium/team_maintainer_observer.spec.ts index 87298ae71..fc2d5e027 100644 --- a/cypress/integration/premium/team_maintainer_observer.spec.ts +++ b/cypress/integration/premium/team_maintainer_observer.spec.ts @@ -18,7 +18,7 @@ describe( it("Can perform the appropriate team observer actions", () => { cy.login("marco@organization.com", "user123#"); - cy.visit("/"); + cy.visit("/hosts/manage"); // Ensure page is loaded cy.contains("Hosts"); @@ -111,7 +111,7 @@ describe( it("Can perform the appropriate maintainer actions", () => { cy.login("marco@organization.com", "user123#"); - cy.visit("/"); + cy.visit("/hosts/manage"); // Ensure page is loaded and appropriate nav links are displayed cy.contains("Hosts"); diff --git a/frontend/components/AuthenticatedAdminRoutes/AuthenticatedAdminRoutes.tests.js b/frontend/components/AuthenticatedAdminRoutes/AuthenticatedAdminRoutes.tests.js index dd77a42e9..512492101 100644 --- a/frontend/components/AuthenticatedAdminRoutes/AuthenticatedAdminRoutes.tests.js +++ b/frontend/components/AuthenticatedAdminRoutes/AuthenticatedAdminRoutes.tests.js @@ -1,5 +1,6 @@ import { mount } from "enzyme"; +import paths from "router/paths"; import ConnectedAdminRoutes from "./AuthenticatedAdminRoutes"; import { connectedComponent, reduxMockStore } from "../../test/helpers"; @@ -8,7 +9,7 @@ describe("AuthenticatedAdminRoutes - layout", () => { type: "@@router/CALL_HISTORY_METHOD", payload: { method: "push", - args: ["/"], + args: [paths.HOME], }, }; diff --git a/frontend/components/side_panels/SiteTopNav/navItems.js b/frontend/components/side_panels/SiteTopNav/navItems.js index 64100e633..9953ced76 100644 --- a/frontend/components/side_panels/SiteTopNav/navItems.js +++ b/frontend/components/side_panels/SiteTopNav/navItems.js @@ -21,8 +21,8 @@ export default (currentUser) => { name: "Home", iconName: "logo", location: { - regex: new RegExp(`^${URL_PREFIX}/home/dashboard`), - pathname: PATHS.HOMEPAGE, + regex: new RegExp(`^${URL_PREFIX}/dashboard`), + pathname: PATHS.HOME, }, }, { diff --git a/frontend/pages/LoginPage/LoginPage.tests.jsx b/frontend/pages/LoginPage/LoginPage.tests.jsx index 10f7f74ac..20dc6a8e9 100644 --- a/frontend/pages/LoginPage/LoginPage.tests.jsx +++ b/frontend/pages/LoginPage/LoginPage.tests.jsx @@ -1,5 +1,6 @@ import { mount } from "enzyme"; +import paths from "router/paths"; import { connectedComponent, reduxMockStore } from "../../test/helpers"; import local from "../../utilities/local"; import LoginPage from "./LoginPage"; @@ -50,7 +51,7 @@ describe("LoginPage - component", () => { type: "@@router/CALL_HISTORY_METHOD", payload: { method: "push", - args: ["/"], + args: [paths.HOME], }, }; diff --git a/frontend/pages/RegistrationPage/RegistrationPage.tests.jsx b/frontend/pages/RegistrationPage/RegistrationPage.tests.jsx index 77743df28..b08c9084d 100644 --- a/frontend/pages/RegistrationPage/RegistrationPage.tests.jsx +++ b/frontend/pages/RegistrationPage/RegistrationPage.tests.jsx @@ -1,6 +1,7 @@ import React from "react"; import { mount, shallow } from "enzyme"; +import paths from "router/paths"; import { connectedComponent, reduxMockStore } from "test/helpers"; import ConnectedRegistrationPage, { RegistrationPage, @@ -17,7 +18,7 @@ const user = { }; describe("RegistrationPage - component", () => { - it("redirects to the login page when a user is logged in", () => { + it("redirects to the home page when a user is logged in", () => { const storeWithUser = { ...baseStore, auth: { @@ -35,7 +36,7 @@ describe("RegistrationPage - component", () => { type: "@@router/CALL_HISTORY_METHOD", payload: { method: "push", - args: ["/"], + args: [paths.HOME], }, }; diff --git a/frontend/router/index.tsx b/frontend/router/index.tsx index 3a0fb9f52..9b55d37d2 100644 --- a/frontend/router/index.tsx +++ b/frontend/router/index.tsx @@ -70,7 +70,7 @@ const AppWrapper = ({ children }: IAppWrapperProps) => ( const routes = ( - + @@ -85,8 +85,8 @@ const routes = ( - - + + diff --git a/frontend/router/paths.ts b/frontend/router/paths.ts index 3f7c04d78..21aff071f 100644 --- a/frontend/router/paths.ts +++ b/frontend/router/paths.ts @@ -4,6 +4,8 @@ import { IQuery } from "../interfaces/query"; import URL_PREFIX from "./url_prefix"; export default { + ROOT: `${URL_PREFIX}/`, + HOME: `${URL_PREFIX}/dashboard`, ADMIN_USERS: `${URL_PREFIX}/settings/users`, ADMIN_SETTINGS: `${URL_PREFIX}/settings/organization`, ADMIN_TEAMS: `${URL_PREFIX}/settings/teams`, @@ -18,12 +20,10 @@ export default { return `${URL_PREFIX}/queries/${query.id}`; }, FORGOT_PASSWORD: `${URL_PREFIX}/login/forgot`, - HOME: `${URL_PREFIX}/`, API_ONLY_USER: `${URL_PREFIX}/apionlyuser`, FLEET_403: `${URL_PREFIX}/403`, FLEET_500: `${URL_PREFIX}/500`, LOGIN: `${URL_PREFIX}/login`, - HOMEPAGE: `${URL_PREFIX}/home/dashboard`, LOGOUT: `${URL_PREFIX}/logout`, MANAGE_HOSTS: `${URL_PREFIX}/hosts/manage`, HOST_DETAILS: (host: IHost): string => {