-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/oidc-behind-proxy
- Loading branch information
Showing
246 changed files
with
9,241 additions
and
2,195 deletions.
There are no files selected for viewing
Binary file removed
BIN
-8.42 MB
...v7_macos_aarch64_0.111.2/30d309907f6262cb1327613813ba35dde7f64d654b4afd8728719be6e057ff48
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/twenty-front/src/hooks/__tests__/useNavigateApp.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { renderHook } from '@testing-library/react'; | ||
import { MemoryRouter, useNavigate } from 'react-router-dom'; | ||
|
||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; | ||
import { AppPath } from '@/types/AppPath'; | ||
import { useNavigateApp } from '~/hooks/useNavigateApp'; | ||
|
||
jest.mock('react-router-dom', () => ({ | ||
...jest.requireActual('react-router-dom'), | ||
useNavigate: jest.fn(), | ||
})); | ||
|
||
const Wrapper = ({ children }: { children: React.ReactNode }) => ( | ||
<MemoryRouter>{children}</MemoryRouter> | ||
); | ||
|
||
describe('useNavigateApp', () => { | ||
const mockNavigate = jest.fn(); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
(useNavigate as jest.Mock).mockReturnValue(mockNavigate); | ||
}); | ||
|
||
it('should navigate to the correct path without params', () => { | ||
const { result } = renderHook(() => useNavigateApp(), { | ||
wrapper: Wrapper, | ||
}); | ||
|
||
result.current(AppPath.Index); | ||
|
||
expect(mockNavigate).toHaveBeenCalledWith('/', undefined); | ||
}); | ||
|
||
it('should navigate to the correct path with params', () => { | ||
const { result } = renderHook(() => useNavigateApp(), { | ||
wrapper: Wrapper, | ||
}); | ||
|
||
result.current(AppPath.RecordShowPage, { | ||
objectNameSingular: CoreObjectNameSingular.Company, | ||
objectRecordId: '123', | ||
}); | ||
|
||
expect(mockNavigate).toHaveBeenCalledWith('/object/company/123', undefined); | ||
}); | ||
|
||
it('should navigate with query params', () => { | ||
const { result } = renderHook(() => useNavigateApp(), { | ||
wrapper: Wrapper, | ||
}); | ||
|
||
const queryParams = { viewId: '123', filter: 'test' }; | ||
result.current(AppPath.Index, undefined, queryParams); | ||
|
||
expect(mockNavigate).toHaveBeenCalledWith( | ||
'/?viewId=123&filter=test', | ||
undefined, | ||
); | ||
}); | ||
|
||
it('should navigate with options', () => { | ||
const { result } = renderHook(() => useNavigateApp(), { | ||
wrapper: Wrapper, | ||
}); | ||
|
||
const options = { replace: true, state: { test: true } }; | ||
result.current(AppPath.Index, undefined, undefined, options); | ||
|
||
expect(mockNavigate).toHaveBeenCalledWith('/', options); | ||
}); | ||
}); |
Oops, something went wrong.