forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes twentyhq#5486 --------- Co-authored-by: gitstart-twenty <[email protected]> Co-authored-by: v1b3m <[email protected]> Co-authored-by: Charles Bochet <[email protected]>
- Loading branch information
1 parent
e47101e
commit 36b467d
Showing
16 changed files
with
709 additions
and
101 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
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
44 changes: 41 additions & 3 deletions
44
.../twenty-front/src/modules/activities/calendar/components/__stories__/Calendar.stories.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
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
12 changes: 12 additions & 0 deletions
12
packages/twenty-front/src/modules/navigation/utils/indexAppPath.ts
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,12 @@ | ||
import { AppPath } from '@/types/AppPath'; | ||
|
||
const getIndexAppPath = () => { | ||
return AppPath.Index; | ||
}; | ||
|
||
// This file is using the default export pattern to be compatible | ||
// with the way it is imported in the tests. | ||
// Otherwise we cannot mock it: https://github.com/jestjs/jest/issues/12145 as we are using ES native modules | ||
// TBH: I am not a big fan of this pattern, alternatively we could set a global variable or a recoilState | ||
// to store the value | ||
export default { getIndexAppPath }; |
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
62 changes: 57 additions & 5 deletions
62
packages/twenty-front/src/testing/decorators/ComponentWithRouterDecorator.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 |
---|---|---|
@@ -1,12 +1,64 @@ | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { | ||
createMemoryRouter, | ||
createRoutesFromElements, | ||
Outlet, | ||
Route, | ||
RouterProvider, | ||
} from 'react-router-dom'; | ||
import { Decorator } from '@storybook/react'; | ||
|
||
import { | ||
computeLocation, | ||
isRouteParams, | ||
} from '~/testing/decorators/PageDecorator'; | ||
|
||
import { ComponentStorybookLayout } from '../ComponentStorybookLayout'; | ||
|
||
export const ComponentWithRouterDecorator: Decorator = (Story) => ( | ||
interface StrictArgs { | ||
[name: string]: unknown; | ||
} | ||
|
||
const Providers = () => ( | ||
<ComponentStorybookLayout> | ||
<MemoryRouter> | ||
<Story /> | ||
</MemoryRouter> | ||
<Outlet /> | ||
</ComponentStorybookLayout> | ||
); | ||
|
||
const createRouter = ({ | ||
Story, | ||
args, | ||
initialEntries, | ||
initialIndex, | ||
}: { | ||
Story: () => JSX.Element; | ||
args: StrictArgs; | ||
initialEntries?: { | ||
pathname: string; | ||
}[]; | ||
initialIndex?: number; | ||
}) => | ||
createMemoryRouter( | ||
createRoutesFromElements( | ||
<Route element={<Providers />}> | ||
<Route path={(args.routePath as string) ?? '*'} element={<Story />} /> | ||
</Route>, | ||
), | ||
{ initialEntries, initialIndex }, | ||
); | ||
|
||
export const ComponentWithRouterDecorator: Decorator = (Story, { args }) => { | ||
return ( | ||
<RouterProvider | ||
router={createRouter({ | ||
Story, | ||
args, | ||
initialEntries: | ||
args.routePath && | ||
typeof args.routePath === 'string' && | ||
(args.routeParams === undefined || isRouteParams(args.routeParams)) | ||
? [computeLocation(args.routePath, args.routeParams)] | ||
: [{ pathname: '/' }], | ||
})} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.