-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not route back to overview tab when changing the resource att…
…ributes (#5058) * fix: do not route back to overview tab when changing the resource attributes * fix: retain the resource attributes in query params on tab change * feat: added jest test case for the same --------- Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
- Loading branch information
1 parent
ab444af
commit 83d0dde
Showing
5 changed files
with
58 additions
and
23 deletions.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
frontend/src/hooks/useResourceAttribute/__tests__/useResourceAttribute.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,28 @@ | ||
import { act, renderHook, waitFor } from '@testing-library/react'; | ||
import { createMemoryHistory } from 'history'; | ||
import { Router } from 'react-router-dom'; | ||
|
||
import ResourceProvider from '../ResourceProvider'; | ||
import useResourceAttribute from '../useResourceAttribute'; | ||
|
||
describe('useResourceAttribute component hook', () => { | ||
it('should not change other query params except for resourceAttribute', async () => { | ||
const history = createMemoryHistory({ | ||
initialEntries: ['/inital-url?tab=overview'], | ||
}); | ||
const wrapper = ({ children }: { children: any }): JSX.Element => ( | ||
<Router history={history}> | ||
<ResourceProvider>{children}</ResourceProvider> | ||
</Router> | ||
); | ||
const { result } = renderHook(() => useResourceAttribute(), { wrapper }); | ||
|
||
act(() => { | ||
result.current.handleEnvironmentChange(['production']); | ||
}); | ||
|
||
await waitFor(() => | ||
expect(history.location.search).toContain('tab=overview'), | ||
); | ||
}); | ||
}); |
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