Skip to content

Commit

Permalink
chore: Revert "fix: fixed back button to redirect to applications pag…
Browse files Browse the repository at this point in the history
…e" (#36191)

Reverts #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: b0516d0
> <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 -->
  • Loading branch information
ankitakinger authored Sep 9, 2024
1 parent 9a26066 commit 182dbe7
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 58 deletions.
27 changes: 1 addition & 26 deletions app/client/src/pages/UserProfile/index.test.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/pages/UserProfile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function UserProfile() {
return (
<PageWrapper displayName={"Profile"}>
<ProfileWrapper>
<BackButton goTo="/applications" />
<BackButton />
<Tabs defaultValue={selectedTab} onValueChange={setSelectedTab}>
<TabsList>
{tabs.map((tab) => {
Expand Down
30 changes: 0 additions & 30 deletions app/client/src/pages/workspace/__tests__/settings.test.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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}`,
);
});
});
2 changes: 1 addition & 1 deletion app/client/src/pages/workspace/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 182dbe7

Please sign in to comment.