chore: Revert "fix: fixed back button to redirect to applications page" (#36191)
Reverts appsmithorg/appsmith#35900 ## Automation /ok-to-test tags="@tag.Sanity" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10778653732> > Commit: b0516d09e4268def58306571166fe6e6318103b0 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10778653732&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Mon, 09 Sep 2024 18:26:51 UTC <!-- end of auto-generated comment: Cypress test results --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
9a2606618f
commit
182dbe7fc2
|
|
@ -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(
|
||||
<Provider store={store}>
|
||||
<ThemeProvider theme={lightTheme}>
|
||||
<Router>
|
||||
<UserProfile />
|
||||
</Router>
|
||||
</ThemeProvider>
|
||||
</Provider>,
|
||||
);
|
||||
const backButton = screen.getByText("Back");
|
||||
fireEvent.click(backButton);
|
||||
expect(mockHistoryPush).toHaveBeenCalledWith("/applications");
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
jest.clearAllMocks();
|
||||
store.clearActions();
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ function UserProfile() {
|
|||
return (
|
||||
<PageWrapper displayName={"Profile"}>
|
||||
<ProfileWrapper>
|
||||
<BackButton goTo="/applications" />
|
||||
<BackButton />
|
||||
<Tabs defaultValue={selectedTab} onValueChange={setSelectedTab}>
|
||||
<TabsList>
|
||||
{tabs.map((tab) => {
|
||||
|
|
|
|||
|
|
@ -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("<Settings />", () => {
|
|||
expect(tabList.length).toBeGreaterThanOrEqual(2);
|
||||
expect(tabList.length).toBeLessThanOrEqual(3);
|
||||
});
|
||||
|
||||
it("should redirect to workspace page if user wants to go back", () => {
|
||||
testRender(
|
||||
<BrowserRouter>
|
||||
<Provider store={mockStore(mockWorkspaceData)}>
|
||||
<Settings />
|
||||
</Provider>
|
||||
</BrowserRouter>,
|
||||
);
|
||||
const backBtn = testScreen.getByText("Back");
|
||||
fireEvent.click(backBtn);
|
||||
expect(mockHistoryPush).toHaveBeenCalledWith(
|
||||
`/applications?workspaceId=${mockWorkspaceData.id}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ export default function Settings() {
|
|||
<>
|
||||
<SettingsWrapper data-testid="t--settings-wrapper" isMobile={isMobile}>
|
||||
<StyledStickyHeader isMobile={isMobile}>
|
||||
<BackButton goTo={`/applications?workspaceId=${workspaceId}`} />
|
||||
<BackButton />
|
||||
<SettingsPageHeader
|
||||
buttonText="Add users"
|
||||
onButtonClick={onButtonClick}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user