[TEST] Covering useDeleteOne relations optimistic cache behavior (#10238)
## Introduction Added coverage on the `useDeleteOneRecord` hooks, especially its optimistic behavior feature. Introduced a new testing tool `InMemoryTestingCacheInstance` that has builtin very basic expectors in order to avoid future duplication when covering others record hooks `update, create, destroy` etc etc ## Notes Added few comments in this PR regarding some builtin functions I've created around companies and people mocked object model and that I think could be cool to spread and centralize within a dedicated "class template" Also put in light that unless I'm mistaken some tests are running on `RecordNode` and not `RecordObject` Took few directions on my own that as I always I would suggestion nor remarks on them ! Let me know ## Misc - Should we refactor `useDeleteOneRecord` tests to follow `eachTesting` pattern ? => I feel like this is inappropriate as this hooks is already high level, the only plus value would be less tests code despite readability IMO
This commit is contained in:
@ -6,7 +6,7 @@ import { contextStoreCurrentObjectMetadataItemComponentState } from '@/context-s
|
||||
import { ContextStoreComponentInstanceContext } from '@/context-store/states/contexts/ContextStoreComponentInstanceContext';
|
||||
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
|
||||
import { isUndefined } from '@sniptt/guards';
|
||||
import { getCompanyObjectMetadataItem } from '~/testing/mock-data/companies';
|
||||
import { getMockCompanyObjectMetadataItem } from '~/testing/mock-data/companies';
|
||||
|
||||
export const ContextStoreDecorator: Decorator = (Story, context) => {
|
||||
const { contextStore } = context.parameters;
|
||||
@ -24,7 +24,7 @@ export const ContextStoreDecorator: Decorator = (Story, context) => {
|
||||
|
||||
const [isLoaded, setIsLoaded] = useState(false);
|
||||
|
||||
const objectMetadataItem = getCompanyObjectMetadataItem();
|
||||
const objectMetadataItem = getMockCompanyObjectMetadataItem();
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentObjectMetadataItem(objectMetadataItem);
|
||||
|
||||
@ -14,7 +14,7 @@ import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { getCompaniesMock } from '~/testing/mock-data/companies';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems';
|
||||
import { getPeopleMock } from '~/testing/mock-data/people';
|
||||
import { getPeopleRecordConnectionMock } from '~/testing/mock-data/people';
|
||||
import { mockedTasks } from '~/testing/mock-data/tasks';
|
||||
|
||||
const RecordMockSetterEffect = ({
|
||||
@ -71,7 +71,7 @@ export const getFieldDecorator =
|
||||
]
|
||||
: companiesMock;
|
||||
|
||||
const peopleMock = getPeopleMock();
|
||||
const peopleMock = getPeopleRecordConnectionMock();
|
||||
|
||||
const people =
|
||||
objectNameSingular === 'person' && isDefined(fieldValue)
|
||||
|
||||
Reference in New Issue
Block a user