d5f88e566c
The goal of this PR is to test if Twenty can support a large number of members, a question which was raised by a large company that is considering moving away from Salesforce. I was expecting the currentWorkspaceMembersState to cause a lot more issue. It would be very hard to get rid of it in the context of actors, I think that would require a big refactoring. I thought we'd have to do it but it turns out the perf are pretty good. One thing we need to improve is the pagination on the roles page, we'll wait for @Bonapara to update that
54 lines
2.5 KiB
TypeScript
54 lines
2.5 KiB
TypeScript
import { MockedProvider, type MockedResponse } from '@apollo/client/testing';
|
|
import { type ReactNode } from 'react';
|
|
import { RecoilRoot, type MutableSnapshot } from 'recoil';
|
|
|
|
import { ContextStoreComponentInstanceContext } from '@/context-store/states/contexts/ContextStoreComponentInstanceContext';
|
|
|
|
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
|
import { RecordComponentInstanceContextsWrapper } from '@/object-record/components/RecordComponentInstanceContextsWrapper';
|
|
import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext';
|
|
import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewComponentInstanceContext';
|
|
import { type InMemoryCache } from '@apollo/client';
|
|
import { JestContextStoreSetter } from '~/testing/jest/JestContextStoreSetter';
|
|
import { JestObjectMetadataItemSetter } from '~/testing/jest/JestObjectMetadataItemSetter';
|
|
|
|
export const getJestMetadataAndApolloMocksWrapper = ({
|
|
apolloMocks,
|
|
cache,
|
|
onInitializeRecoilSnapshot,
|
|
objectMetadataItems,
|
|
}: {
|
|
cache?: InMemoryCache;
|
|
apolloMocks?:
|
|
| readonly MockedResponse<Record<string, any>, Record<string, any>>[]
|
|
| undefined;
|
|
onInitializeRecoilSnapshot?: (snapshot: MutableSnapshot) => void;
|
|
objectMetadataItems?: ObjectMetadataItem[];
|
|
}) => {
|
|
return ({ children }: { children: ReactNode }) => (
|
|
<RecoilRoot initializeState={onInitializeRecoilSnapshot}>
|
|
<SnackBarComponentInstanceContext.Provider
|
|
value={{ instanceId: 'snack-bar-manager' }}
|
|
>
|
|
<MockedProvider mocks={apolloMocks} addTypename={false} cache={cache}>
|
|
<RecordComponentInstanceContextsWrapper componentInstanceId="instanceId">
|
|
<ViewComponentInstanceContext.Provider
|
|
value={{ instanceId: 'instanceId' }}
|
|
>
|
|
<JestObjectMetadataItemSetter
|
|
objectMetadataItems={objectMetadataItems}
|
|
>
|
|
<ContextStoreComponentInstanceContext.Provider
|
|
value={{ instanceId: 'instanceId' }}
|
|
>
|
|
<JestContextStoreSetter>{children}</JestContextStoreSetter>
|
|
</ContextStoreComponentInstanceContext.Provider>
|
|
</JestObjectMetadataItemSetter>
|
|
</ViewComponentInstanceContext.Provider>
|
|
</RecordComponentInstanceContextsWrapper>
|
|
</MockedProvider>
|
|
</SnackBarComponentInstanceContext.Provider>
|
|
</RecoilRoot>
|
|
);
|
|
};
|