Fix Frontend pages tests (#2719)
* Fix Frontend pages tests Co-authored-by: gitstart-twenty <twenty@gitstart.com> Co-authored-by: Mael FOSSO <fosso.mael.elvis@gmail.com> * Add SnackBarDecorator Co-authored-by: gitstart-twenty <twenty@gitstart.com> Co-authored-by: Mael FOSSO <fosso.mael.elvis@gmail.com> * Fix more tests Co-authored-by: gitstart-twenty <twenty@gitstart.com> Co-authored-by: Mael FOSSO <fosso.mael.elvis@gmail.com> * Fix more tests Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: gitstart-twenty <twenty@gitstart.com> Co-authored-by: Mael FOSSO <fosso.mael.elvis@gmail.com> --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: Mael FOSSO <fosso.mael.elvis@gmail.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com>
This commit is contained in:
@ -5,6 +5,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { ClientConfigProvider } from '@/client-config/components/ClientConfigProvider';
|
import { ClientConfigProvider } from '@/client-config/components/ClientConfigProvider';
|
||||||
import { UserProvider } from '@/users/components/UserProvider';
|
import { UserProvider } from '@/users/components/UserProvider';
|
||||||
import { App } from '~/App';
|
import { App } from '~/App';
|
||||||
|
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
||||||
import { FullHeightStorybookLayout } from '~/testing/FullHeightStorybookLayout';
|
import { FullHeightStorybookLayout } from '~/testing/FullHeightStorybookLayout';
|
||||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ const meta: Meta<typeof App> = {
|
|||||||
title: 'App/App',
|
title: 'App/App',
|
||||||
component: App,
|
component: App,
|
||||||
decorators: [
|
decorators: [
|
||||||
|
SnackBarDecorator,
|
||||||
(Story) => (
|
(Story) => (
|
||||||
<ClientConfigProvider>
|
<ClientConfigProvider>
|
||||||
<UserProvider>
|
<UserProvider>
|
||||||
|
|||||||
@ -2,11 +2,12 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
|
|
||||||
import { ApiKeyInput } from '@/settings/developers/components/ApiKeyInput';
|
import { ApiKeyInput } from '@/settings/developers/components/ApiKeyInput';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
||||||
|
|
||||||
const meta: Meta<typeof ApiKeyInput> = {
|
const meta: Meta<typeof ApiKeyInput> = {
|
||||||
title: 'Pages/Settings/Developers/ApiKeys/ApiKeyInput',
|
title: 'Pages/Settings/Developers/ApiKeys/ApiKeyInput',
|
||||||
component: ApiKeyInput,
|
component: ApiKeyInput,
|
||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator, SnackBarDecorator],
|
||||||
args: {
|
args: {
|
||||||
apiKey:
|
apiKey:
|
||||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0d2VudHktN2VkOWQyMTItMWMyNS00ZDAyLWJmMjUtNmFlY2NmN2VhNDE5IiwiaWF0IjoxNjk4MTQyODgyLCJleHAiOjE2OTk0MDE1OTksImp0aSI6ImMyMmFiNjQxLTVhOGYtNGQwMC1iMDkzLTk3MzUwYTM2YzZkOSJ9.JIe2TX5IXrdNl3n-kRFp3jyfNUE7unzXZLAzm2Gxl98',
|
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0d2VudHktN2VkOWQyMTItMWMyNS00ZDAyLWJmMjUtNmFlY2NmN2VhNDE5IiwiaWF0IjoxNjk4MTQyODgyLCJleHAiOjE2OTk0MDE1OTksImp0aSI6ImMyMmFiNjQxLTVhOGYtNGQwMC1iMDkzLTk3MzUwYTM2YzZkOSJ9.JIe2TX5IXrdNl3n-kRFp3jyfNUE7unzXZLAzm2Gxl98',
|
||||||
|
|||||||
@ -34,10 +34,10 @@ export const NameFields = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const [firstName, setFirstName] = useState(
|
const [firstName, setFirstName] = useState(
|
||||||
currentWorkspaceMember?.name.firstName ?? '',
|
currentWorkspaceMember?.name?.firstName ?? '',
|
||||||
);
|
);
|
||||||
const [lastName, setLastName] = useState(
|
const [lastName, setLastName] = useState(
|
||||||
currentWorkspaceMember?.name.lastName ?? '',
|
currentWorkspaceMember?.name?.lastName ?? '',
|
||||||
);
|
);
|
||||||
|
|
||||||
const { updateOneObject, objectNotFoundInMetadata } =
|
const { updateOneObject, objectNotFoundInMetadata } =
|
||||||
@ -91,8 +91,8 @@ export const NameFields = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
currentWorkspaceMember.name.firstName !== firstName ||
|
currentWorkspaceMember.name?.firstName !== firstName ||
|
||||||
currentWorkspaceMember.name.lastName !== lastName
|
currentWorkspaceMember.name?.lastName !== lastName
|
||||||
) {
|
) {
|
||||||
debouncedUpdate();
|
debouncedUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,8 +76,8 @@ export const CreateProfile = () => {
|
|||||||
} = useForm<Form>({
|
} = useForm<Form>({
|
||||||
mode: 'onChange',
|
mode: 'onChange',
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
firstName: currentWorkspaceMember?.name.firstName ?? '',
|
firstName: currentWorkspaceMember?.name?.firstName ?? '',
|
||||||
lastName: currentWorkspaceMember?.name.lastName ?? '',
|
lastName: currentWorkspaceMember?.name?.lastName ?? '',
|
||||||
},
|
},
|
||||||
resolver: zodResolver(validationSchema),
|
resolver: zodResolver(validationSchema),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,13 +3,19 @@ import { within } from '@storybook/testing-library';
|
|||||||
|
|
||||||
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
|
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
|
||||||
import { PageDecoratorArgs } from '~/testing/decorators/PageDecorator';
|
import { PageDecoratorArgs } from '~/testing/decorators/PageDecorator';
|
||||||
|
import { RelationPickerDecorator } from '~/testing/decorators/RelationPickerDecorator';
|
||||||
|
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
||||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||||
|
|
||||||
import { NotFound } from '../NotFound';
|
import { NotFound } from '../NotFound';
|
||||||
const meta: Meta<PageDecoratorArgs> = {
|
const meta: Meta<PageDecoratorArgs> = {
|
||||||
title: 'Pages/NotFound/Default',
|
title: 'Pages/NotFound/Default',
|
||||||
component: NotFound,
|
component: NotFound,
|
||||||
decorators: [ComponentWithRouterDecorator],
|
decorators: [
|
||||||
|
ComponentWithRouterDecorator,
|
||||||
|
SnackBarDecorator,
|
||||||
|
RelationPickerDecorator,
|
||||||
|
],
|
||||||
args: {
|
args: {
|
||||||
routePath: 'toto-not-found',
|
routePath: 'toto-not-found',
|
||||||
},
|
},
|
||||||
|
|||||||
@ -22,9 +22,9 @@ export const TasksEffect = () => {
|
|||||||
value: currentWorkspaceMember.id,
|
value: currentWorkspaceMember.id,
|
||||||
operand: ViewFilterOperand.Is,
|
operand: ViewFilterOperand.Is,
|
||||||
displayValue:
|
displayValue:
|
||||||
currentWorkspaceMember.name.firstName +
|
currentWorkspaceMember.name?.firstName +
|
||||||
' ' +
|
' ' +
|
||||||
currentWorkspaceMember.name.lastName,
|
currentWorkspaceMember.name?.lastName,
|
||||||
displayAvatarUrl: currentWorkspaceMember.avatarUrl ?? undefined,
|
displayAvatarUrl: currentWorkspaceMember.avatarUrl ?? undefined,
|
||||||
definition: tasksFilterDefinitions[0],
|
definition: tasksFilterDefinitions[0],
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
import { HelmetProvider } from 'react-helmet-async';
|
import { HelmetProvider } from 'react-helmet-async';
|
||||||
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
||||||
import { Decorator } from '@storybook/react';
|
import { Decorator } from '@storybook/react';
|
||||||
|
import { RecoilRoot } from 'recoil';
|
||||||
|
|
||||||
|
import { SnackBarProviderScope } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarProviderScope';
|
||||||
|
import { RelationPickerScope } from '@/ui/input/components/internal/relation-picker/scopes/RelationPickerScope';
|
||||||
import { ClientConfigProvider } from '~/modules/client-config/components/ClientConfigProvider';
|
import { ClientConfigProvider } from '~/modules/client-config/components/ClientConfigProvider';
|
||||||
import { DefaultLayout } from '~/modules/ui/layout/page/DefaultLayout';
|
import { DefaultLayout } from '~/modules/ui/layout/page/DefaultLayout';
|
||||||
import { UserProvider } from '~/modules/users/components/UserProvider';
|
import { UserProvider } from '~/modules/users/components/UserProvider';
|
||||||
@ -30,21 +33,27 @@ export const PageDecorator: Decorator<{
|
|||||||
routePath: string;
|
routePath: string;
|
||||||
routeParams: RouteParams;
|
routeParams: RouteParams;
|
||||||
}> = (Story, { args }) => (
|
}> = (Story, { args }) => (
|
||||||
<UserProvider>
|
<RecoilRoot>
|
||||||
<ClientConfigProvider>
|
<UserProvider>
|
||||||
<MemoryRouter
|
<ClientConfigProvider>
|
||||||
initialEntries={[computeLocation(args.routePath, args.routeParams)]}
|
<MemoryRouter
|
||||||
>
|
initialEntries={[computeLocation(args.routePath, args.routeParams)]}
|
||||||
<FullHeightStorybookLayout>
|
>
|
||||||
<HelmetProvider>
|
<FullHeightStorybookLayout>
|
||||||
<DefaultLayout>
|
<HelmetProvider>
|
||||||
<Routes>
|
<SnackBarProviderScope snackBarManagerScopeId="snack-bar-manager">
|
||||||
<Route path={args.routePath} element={<Story />} />
|
<RelationPickerScope relationPickerScopeId="relation-picker">
|
||||||
</Routes>
|
<DefaultLayout>
|
||||||
</DefaultLayout>
|
<Routes>
|
||||||
</HelmetProvider>
|
<Route path={args.routePath} element={<Story />} />
|
||||||
</FullHeightStorybookLayout>
|
</Routes>
|
||||||
</MemoryRouter>
|
</DefaultLayout>
|
||||||
</ClientConfigProvider>
|
</RelationPickerScope>
|
||||||
</UserProvider>
|
</SnackBarProviderScope>
|
||||||
|
</HelmetProvider>
|
||||||
|
</FullHeightStorybookLayout>
|
||||||
|
</MemoryRouter>
|
||||||
|
</ClientConfigProvider>
|
||||||
|
</UserProvider>
|
||||||
|
</RecoilRoot>
|
||||||
);
|
);
|
||||||
|
|||||||
9
front/src/testing/decorators/RelationPickerDecorator.tsx
Normal file
9
front/src/testing/decorators/RelationPickerDecorator.tsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Decorator } from '@storybook/react';
|
||||||
|
|
||||||
|
import { RelationPickerScope } from '@/ui/input/components/internal/relation-picker/scopes/RelationPickerScope';
|
||||||
|
|
||||||
|
export const RelationPickerDecorator: Decorator = (Story) => (
|
||||||
|
<RelationPickerScope relationPickerScopeId="relation-picker">
|
||||||
|
<Story />
|
||||||
|
</RelationPickerScope>
|
||||||
|
);
|
||||||
9
front/src/testing/decorators/SnackBarDecorator.tsx
Normal file
9
front/src/testing/decorators/SnackBarDecorator.tsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Decorator } from '@storybook/react';
|
||||||
|
|
||||||
|
import { SnackBarProviderScope } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarProviderScope';
|
||||||
|
|
||||||
|
export const SnackBarDecorator: Decorator = (Story) => (
|
||||||
|
<SnackBarProviderScope snackBarManagerScopeId="snack-bar-manager">
|
||||||
|
<Story />
|
||||||
|
</SnackBarProviderScope>
|
||||||
|
);
|
||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user