From 182dbe7fc2a6bf2a7f0c2ec0bb03e419db231793 Mon Sep 17 00:00:00 2001 From: Ankita Kinger Date: Tue, 10 Sep 2024 04:52:23 +0530 Subject: [PATCH] chore: Revert "fix: fixed back button to redirect to applications page" (#36191) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverts appsmithorg/appsmith#35900 ## Automation /ok-to-test tags="@tag.Sanity" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: b0516d09e4268def58306571166fe6e6318103b0 > Cypress dashboard. > Tags: `@tag.Sanity` > Spec: >
Mon, 09 Sep 2024 18:26:51 UTC ## Summary by CodeRabbit - **New Features** - Simplified navigation with the `BackButton` component, now relying on default behavior instead of a specified route in the `UserProfile` and `Settings` components. - **Bug Fixes** - Refined testing strategy by removing outdated navigation-related tests and imports for the `UserProfile` and `Settings` components, streamlining the test suite. - **Documentation** - Updated comments and documentation to reflect changes in navigation behavior and testing focus. --- .../src/pages/UserProfile/index.test.tsx | 27 +---------------- app/client/src/pages/UserProfile/index.tsx | 2 +- .../workspace/__tests__/settings.test.tsx | 30 ------------------- app/client/src/pages/workspace/settings.tsx | 2 +- 4 files changed, 3 insertions(+), 58 deletions(-) diff --git a/app/client/src/pages/UserProfile/index.test.tsx b/app/client/src/pages/UserProfile/index.test.tsx index aa57ee2d919a..f9e6ffe3653d 100644 --- a/app/client/src/pages/UserProfile/index.test.tsx +++ b/app/client/src/pages/UserProfile/index.test.tsx @@ -1,6 +1,6 @@ import "@testing-library/jest-dom/extend-expect"; import React from "react"; -import { render, screen, fireEvent } from "@testing-library/react"; +import { render } from "@testing-library/react"; import { Provider } from "react-redux"; import configureStore from "redux-mock-store"; import { lightTheme } from "selectors/themeSelectors"; @@ -87,15 +87,6 @@ jest.mock("actions/gitSyncActions", () => ({ fetchGlobalGitConfigInit: jest.fn(), })); -const mockHistoryPush = jest.fn(); - -jest.mock("react-router-dom", () => ({ - ...jest.requireActual("react-router-dom"), - useHistory: () => ({ - push: mockHistoryPush, - }), -})); - const mockStore = configureStore([]); describe("Git config ", () => { // TODO: Fix this the next time the file is edited @@ -137,22 +128,6 @@ describe("Git config ", () => { expect(getAllByText("Sign in to your account")).toBeInTheDocument; }); - it("should call history push when user goes back to applications", () => { - store = mockStore(defaultStoreState); - render( - - - - - - - , - ); - const backButton = screen.getByText("Back"); - fireEvent.click(backButton); - expect(mockHistoryPush).toHaveBeenCalledWith("/applications"); - }); - afterAll(() => { jest.clearAllMocks(); store.clearActions(); diff --git a/app/client/src/pages/UserProfile/index.tsx b/app/client/src/pages/UserProfile/index.tsx index bf7de701ef78..2cfb2fee9fb3 100644 --- a/app/client/src/pages/UserProfile/index.tsx +++ b/app/client/src/pages/UserProfile/index.tsx @@ -56,7 +56,7 @@ function UserProfile() { return ( - + {tabs.map((tab) => { diff --git a/app/client/src/pages/workspace/__tests__/settings.test.tsx b/app/client/src/pages/workspace/__tests__/settings.test.tsx index 3e488f3fb4c4..fdcbea9eb15e 100644 --- a/app/client/src/pages/workspace/__tests__/settings.test.tsx +++ b/app/client/src/pages/workspace/__tests__/settings.test.tsx @@ -1,17 +1,9 @@ import React from "react"; import "@testing-library/jest-dom"; import Router from "react-router-dom"; -import { BrowserRouter } from "react-router-dom"; import { render, screen } from "test/testUtils"; -import { - render as testRender, - screen as testScreen, -} from "@testing-library/react"; -import { fireEvent } from "@testing-library/react"; import Settings from "../settings"; import * as reactRedux from "react-redux"; -import configureStore from "redux-mock-store"; -import { Provider } from "react-redux"; // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -159,16 +151,9 @@ const mockWorkspaceData = { new: false, }; -const mockHistoryPush = jest.fn(); - -const mockStore = configureStore([]); - jest.mock("react-router-dom", () => ({ ...jest.requireActual("react-router-dom"), useParams: jest.fn(), - useHistory: () => ({ - push: mockHistoryPush, - }), })); function renderComponent() { @@ -205,19 +190,4 @@ describe("", () => { expect(tabList.length).toBeGreaterThanOrEqual(2); expect(tabList.length).toBeLessThanOrEqual(3); }); - - it("should redirect to workspace page if user wants to go back", () => { - testRender( - - - - - , - ); - const backBtn = testScreen.getByText("Back"); - fireEvent.click(backBtn); - expect(mockHistoryPush).toHaveBeenCalledWith( - `/applications?workspaceId=${mockWorkspaceData.id}`, - ); - }); }); diff --git a/app/client/src/pages/workspace/settings.tsx b/app/client/src/pages/workspace/settings.tsx index 1c5ab878d554..0d4567c9325d 100644 --- a/app/client/src/pages/workspace/settings.tsx +++ b/app/client/src/pages/workspace/settings.tsx @@ -127,7 +127,7 @@ export default function Settings() { <> - +