Frontend tests improvements (#13115)
Fix warnings and lower coverage by 0.1%
This commit is contained in:
@ -5,9 +5,7 @@ const tsConfig = require('./tsconfig.spec.json');
|
|||||||
process.env.TZ = 'GMT';
|
process.env.TZ = 'GMT';
|
||||||
process.env.LC_ALL = 'en_US.UTF-8';
|
process.env.LC_ALL = 'en_US.UTF-8';
|
||||||
const jestConfig: JestConfigWithTsJest = {
|
const jestConfig: JestConfigWithTsJest = {
|
||||||
// to enable logs, comment out the following line
|
|
||||||
silent: true,
|
silent: true,
|
||||||
verbose: false,
|
|
||||||
// For more information please have a look to official docs https://jestjs.io/docs/configuration/#prettierpath-string
|
// For more information please have a look to official docs https://jestjs.io/docs/configuration/#prettierpath-string
|
||||||
// Prettier v3 will should be supported in jest v30 https://github.com/jestjs/jest/releases/tag/v30.0.0-alpha.1
|
// Prettier v3 will should be supported in jest v30 https://github.com/jestjs/jest/releases/tag/v30.0.0-alpha.1
|
||||||
prettierPath: null,
|
prettierPath: null,
|
||||||
@ -54,7 +52,7 @@ const jestConfig: JestConfigWithTsJest = {
|
|||||||
extensionsToTreatAsEsm: ['.ts', '.tsx'],
|
extensionsToTreatAsEsm: ['.ts', '.tsx'],
|
||||||
coverageThreshold: {
|
coverageThreshold: {
|
||||||
global: {
|
global: {
|
||||||
statements: 57,
|
statements: 56.9,
|
||||||
lines: 55,
|
lines: 55,
|
||||||
functions: 46,
|
functions: 46,
|
||||||
},
|
},
|
||||||
@ -79,6 +77,7 @@ const jestConfig: JestConfigWithTsJest = {
|
|||||||
'display/icon/index.ts',
|
'display/icon/index.ts',
|
||||||
],
|
],
|
||||||
coverageDirectory: './coverage',
|
coverageDirectory: './coverage',
|
||||||
|
errorOnDeprecated: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default jestConfig;
|
export default jestConfig;
|
||||||
|
|||||||
@ -178,17 +178,31 @@ const mocks: MockedResponse[] = [
|
|||||||
data: {
|
data: {
|
||||||
updateTask: {
|
updateTask: {
|
||||||
__typename: 'Task',
|
__typename: 'Task',
|
||||||
createdAt: '2024-03-15T07:33:14.212Z',
|
assignee: null,
|
||||||
reminderAt: null,
|
|
||||||
authorId: '123',
|
|
||||||
title: 'Test',
|
|
||||||
status: 'DONE',
|
|
||||||
updatedAt: '2024-03-15T07:33:14.212Z',
|
|
||||||
body: 'Test',
|
|
||||||
dueAt: '2024-03-15T07:33:14.212Z',
|
|
||||||
type: 'TASK',
|
|
||||||
id: '123',
|
|
||||||
assigneeId: '123',
|
assigneeId: '123',
|
||||||
|
attachments: { edges: [] },
|
||||||
|
body: 'Test',
|
||||||
|
bodyV2: {
|
||||||
|
blocknote: 'Test',
|
||||||
|
markdown: 'Test',
|
||||||
|
},
|
||||||
|
createdAt: '2024-03-15T07:33:14.212Z',
|
||||||
|
createdBy: {
|
||||||
|
source: 'MANUAL',
|
||||||
|
workspaceMemberId: '123',
|
||||||
|
name: 'Test User',
|
||||||
|
context: 'test',
|
||||||
|
},
|
||||||
|
deletedAt: null,
|
||||||
|
dueAt: '2024-03-15T07:33:14.212Z',
|
||||||
|
favorites: { edges: [] },
|
||||||
|
id: '123',
|
||||||
|
position: 1,
|
||||||
|
status: 'DONE',
|
||||||
|
taskTargets: { edges: [] },
|
||||||
|
timelineActivities: { edges: [] },
|
||||||
|
title: 'Test',
|
||||||
|
updatedAt: '2024-03-15T07:33:14.212Z',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { act } from 'react-dom/test-utils';
|
import { act, renderHook } from '@testing-library/react';
|
||||||
import { renderHook } from '@testing-library/react';
|
|
||||||
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
||||||
|
|
||||||
import { useIsLogged } from '@/auth/hooks/useIsLogged';
|
import { useIsLogged } from '@/auth/hooks/useIsLogged';
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { act } from 'react-dom/test-utils';
|
|
||||||
import { enableFetchMocks } from 'jest-fetch-mock';
|
import { enableFetchMocks } from 'jest-fetch-mock';
|
||||||
|
import { act } from 'react';
|
||||||
|
|
||||||
import { renewToken } from '@/auth/services/AuthService';
|
import { renewToken } from '@/auth/services/AuthService';
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,30 @@ import { isDeveloperDefaultSignInPrefilledState } from '@/client-config/states/i
|
|||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
|
|
||||||
|
const TestWrapper = ({
|
||||||
|
children,
|
||||||
|
initialEntry = '/',
|
||||||
|
isDeveloperDefaultSignInPrefilled = false,
|
||||||
|
}: {
|
||||||
|
children: ReactNode;
|
||||||
|
initialEntry?: string;
|
||||||
|
isDeveloperDefaultSignInPrefilled?: boolean;
|
||||||
|
}) => (
|
||||||
|
<MemoryRouter initialEntries={[initialEntry]}>
|
||||||
|
<RecoilRoot
|
||||||
|
initializeState={(snapshot) => {
|
||||||
|
snapshot.set(
|
||||||
|
isDeveloperDefaultSignInPrefilledState,
|
||||||
|
isDeveloperDefaultSignInPrefilled,
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</RecoilRoot>
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
describe('useSignInUpForm', () => {
|
describe('useSignInUpForm', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -12,21 +35,17 @@ describe('useSignInUpForm', () => {
|
|||||||
|
|
||||||
it('should initialize the form with default values', async () => {
|
it('should initialize the form with default values', async () => {
|
||||||
const { result } = renderHook(() => useSignInUpForm(), {
|
const { result } = renderHook(() => useSignInUpForm(), {
|
||||||
wrapper: ({ children }: { children: ReactNode }) => (
|
wrapper: ({ children }) => <TestWrapper>{children}</TestWrapper>,
|
||||||
<MemoryRouter>
|
|
||||||
<RecoilRoot>{children}</RecoilRoot>
|
|
||||||
</MemoryRouter>
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
expect(result.current.form).toBeDefined();
|
expect(result.current.form).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not prefill sign-in developer defaults when state is false', () => {
|
it('should not prefill sign-in developer defaults when state is false', () => {
|
||||||
const { result } = renderHook(() => useSignInUpForm(), {
|
const { result } = renderHook(() => useSignInUpForm(), {
|
||||||
wrapper: ({ children }: { children: ReactNode }) => (
|
wrapper: ({ children }) => (
|
||||||
<MemoryRouter initialEntries={['?email=test@test.com']}>
|
<TestWrapper initialEntry="?email=test@test.com">
|
||||||
<RecoilRoot>{children}</RecoilRoot>
|
{children}
|
||||||
</MemoryRouter>
|
</TestWrapper>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -39,24 +58,16 @@ describe('useSignInUpForm', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should prefill developer defaults when the state is true', () => {
|
it('should prefill developer defaults when the state is true', () => {
|
||||||
const { result } = renderHook(
|
const { result } = renderHook(() => useSignInUpForm(), {
|
||||||
() => {
|
wrapper: ({ children }) => (
|
||||||
const setIsDeveloperDefaultSignInPrefilledState = useSetRecoilState(
|
<TestWrapper
|
||||||
isDeveloperDefaultSignInPrefilledState,
|
initialEntry="?email=test@test.com"
|
||||||
);
|
isDeveloperDefaultSignInPrefilled={true}
|
||||||
|
>
|
||||||
setIsDeveloperDefaultSignInPrefilledState(true);
|
{children}
|
||||||
|
</TestWrapper>
|
||||||
return useSignInUpForm();
|
),
|
||||||
},
|
});
|
||||||
{
|
|
||||||
wrapper: ({ children }: { children: ReactNode }) => (
|
|
||||||
<MemoryRouter initialEntries={['?email=test@test.com']}>
|
|
||||||
<RecoilRoot>{children}</RecoilRoot>
|
|
||||||
</MemoryRouter>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(result.current.form.getValues()).toEqual({
|
expect(result.current.form.getValues()).toEqual({
|
||||||
exist: false,
|
exist: false,
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook, waitFor } from '@testing-library/react';
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
||||||
|
|
||||||
import { currentUserState } from '@/auth/states/currentUserState';
|
import { currentUserState } from '@/auth/states/currentUserState';
|
||||||
@ -36,39 +37,48 @@ const renderHooks = ({
|
|||||||
arePrefetchViewsLoadedState,
|
arePrefetchViewsLoadedState,
|
||||||
);
|
);
|
||||||
|
|
||||||
setObjectMetadataItems(generatedMockObjectMetadataItems);
|
useEffect(() => {
|
||||||
setArePrefetchViewsLoaded(true);
|
setObjectMetadataItems(generatedMockObjectMetadataItems);
|
||||||
|
setArePrefetchViewsLoaded(true);
|
||||||
|
|
||||||
if (withExistingView) {
|
if (withExistingView) {
|
||||||
setPrefetchViews([
|
setPrefetchViews([
|
||||||
{
|
{
|
||||||
id: 'viewId',
|
id: 'viewId',
|
||||||
name: 'Test View',
|
name: 'Test View',
|
||||||
objectMetadataId: getMockCompanyObjectMetadataItem().id,
|
objectMetadataId: getMockCompanyObjectMetadataItem().id,
|
||||||
type: ViewType.Table,
|
type: ViewType.Table,
|
||||||
key: null,
|
key: null,
|
||||||
isCompact: false,
|
isCompact: false,
|
||||||
openRecordIn: ViewOpenRecordInType.SIDE_PANEL,
|
openRecordIn: ViewOpenRecordInType.SIDE_PANEL,
|
||||||
viewFields: [],
|
viewFields: [],
|
||||||
viewGroups: [],
|
viewGroups: [],
|
||||||
viewSorts: [],
|
viewSorts: [],
|
||||||
kanbanFieldMetadataId: '',
|
kanbanFieldMetadataId: '',
|
||||||
kanbanAggregateOperation: AggregateOperations.COUNT,
|
kanbanAggregateOperation: AggregateOperations.COUNT,
|
||||||
icon: '',
|
icon: '',
|
||||||
kanbanAggregateOperationFieldMetadataId: '',
|
kanbanAggregateOperationFieldMetadataId: '',
|
||||||
position: 0,
|
position: 0,
|
||||||
viewFilters: [],
|
viewFilters: [],
|
||||||
__typename: 'View',
|
__typename: 'View',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
setPrefetchViews([]);
|
setPrefetchViews([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (withCurrentUser) {
|
||||||
|
setCurrentUser(mockedUserData);
|
||||||
|
setCurrentUserWorkspace(mockedUserData.currentUserWorkspace);
|
||||||
|
}
|
||||||
|
}, [
|
||||||
|
setCurrentUser,
|
||||||
|
setCurrentUserWorkspace,
|
||||||
|
setObjectMetadataItems,
|
||||||
|
setPrefetchViews,
|
||||||
|
setArePrefetchViewsLoaded,
|
||||||
|
]);
|
||||||
|
|
||||||
if (withCurrentUser) {
|
|
||||||
setCurrentUser(mockedUserData);
|
|
||||||
setCurrentUserWorkspace(mockedUserData.currentUserWorkspace);
|
|
||||||
}
|
|
||||||
return useDefaultHomePagePath();
|
return useDefaultHomePagePath();
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -79,34 +89,46 @@ const renderHooks = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe('useDefaultHomePagePath', () => {
|
describe('useDefaultHomePagePath', () => {
|
||||||
it('should return proper path when no currentUser', () => {
|
it('should return proper path when no currentUser', async () => {
|
||||||
const { result } = renderHooks({
|
const { result } = renderHooks({
|
||||||
withCurrentUser: false,
|
withCurrentUser: false,
|
||||||
withExistingView: false,
|
withExistingView: false,
|
||||||
});
|
});
|
||||||
expect(result.current.defaultHomePagePath).toEqual(AppPath.SignInUp);
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(result.current.defaultHomePagePath).toEqual(AppPath.SignInUp);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('should return proper path when no currentUser and existing view', () => {
|
it('should return proper path when no currentUser and existing view', async () => {
|
||||||
const { result } = renderHooks({
|
const { result } = renderHooks({
|
||||||
withCurrentUser: false,
|
withCurrentUser: false,
|
||||||
withExistingView: true,
|
withExistingView: true,
|
||||||
});
|
});
|
||||||
expect(result.current.defaultHomePagePath).toEqual(AppPath.SignInUp);
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(result.current.defaultHomePagePath).toEqual(AppPath.SignInUp);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('should return proper path when currentUser is defined', () => {
|
it('should return proper path when currentUser is defined', async () => {
|
||||||
const { result } = renderHooks({
|
const { result } = renderHooks({
|
||||||
withCurrentUser: true,
|
withCurrentUser: true,
|
||||||
withExistingView: false,
|
withExistingView: false,
|
||||||
});
|
});
|
||||||
expect(result.current.defaultHomePagePath).toEqual('/objects/companies');
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(result.current.defaultHomePagePath).toEqual('/objects/companies');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('should return proper path when currentUser is defined and view exists', () => {
|
it('should return proper path when currentUser is defined and view exists', async () => {
|
||||||
const { result } = renderHooks({
|
const { result } = renderHooks({
|
||||||
withCurrentUser: true,
|
withCurrentUser: true,
|
||||||
withExistingView: true,
|
withExistingView: true,
|
||||||
});
|
});
|
||||||
expect(result.current.defaultHomePagePath).toEqual(
|
|
||||||
'/objects/companies?viewId=viewId',
|
await waitFor(() => {
|
||||||
);
|
expect(result.current.defaultHomePagePath).toEqual(
|
||||||
|
'/objects/companies?viewId=viewId',
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { MockedProvider } from '@apollo/client/testing';
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
import { act, renderHook } from '@testing-library/react';
|
import { act, renderHook } from '@testing-library/react';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
query,
|
query,
|
||||||
@ -27,7 +27,11 @@ const mocks = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const Wrapper = ({ children }: { children: ReactNode }) => (
|
const Wrapper = ({ children }: { children: ReactNode }) => (
|
||||||
<RecoilRoot>
|
<RecoilRoot
|
||||||
|
initializeState={({ set }) =>
|
||||||
|
set(objectMetadataItemsState, generatedMockObjectMetadataItems)
|
||||||
|
}
|
||||||
|
>
|
||||||
<MockedProvider mocks={mocks} addTypename={false}>
|
<MockedProvider mocks={mocks} addTypename={false}>
|
||||||
{children}
|
{children}
|
||||||
</MockedProvider>
|
</MockedProvider>
|
||||||
@ -36,17 +40,9 @@ const Wrapper = ({ children }: { children: ReactNode }) => (
|
|||||||
|
|
||||||
describe('useFilteredObjectMetadataItems', () => {
|
describe('useFilteredObjectMetadataItems', () => {
|
||||||
it('should findActiveObjectMetadataItemByNamePlural', async () => {
|
it('should findActiveObjectMetadataItemByNamePlural', async () => {
|
||||||
const { result } = renderHook(
|
const { result } = renderHook(useFilteredObjectMetadataItems, {
|
||||||
() => {
|
wrapper: Wrapper,
|
||||||
const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
|
});
|
||||||
setMetadataItems(generatedMockObjectMetadataItems);
|
|
||||||
|
|
||||||
return useFilteredObjectMetadataItems();
|
|
||||||
},
|
|
||||||
{
|
|
||||||
wrapper: Wrapper,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
act(() => {
|
act(() => {
|
||||||
const res =
|
const res =
|
||||||
@ -57,17 +53,9 @@ describe('useFilteredObjectMetadataItems', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should findObjectMetadataItemByNamePlural', async () => {
|
it('should findObjectMetadataItemByNamePlural', async () => {
|
||||||
const { result } = renderHook(
|
const { result } = renderHook(useFilteredObjectMetadataItems, {
|
||||||
() => {
|
wrapper: Wrapper,
|
||||||
const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
|
});
|
||||||
setMetadataItems(generatedMockObjectMetadataItems);
|
|
||||||
|
|
||||||
return useFilteredObjectMetadataItems();
|
|
||||||
},
|
|
||||||
{
|
|
||||||
wrapper: Wrapper,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
act(() => {
|
act(() => {
|
||||||
const res = result.current.findObjectMetadataItemByNamePlural('people');
|
const res = result.current.findObjectMetadataItemByNamePlural('people');
|
||||||
@ -81,17 +69,9 @@ describe('useFilteredObjectMetadataItems', () => {
|
|||||||
(item) => item.namePlural === 'people',
|
(item) => item.namePlural === 'people',
|
||||||
);
|
);
|
||||||
|
|
||||||
const { result } = renderHook(
|
const { result } = renderHook(useFilteredObjectMetadataItems, {
|
||||||
() => {
|
wrapper: Wrapper,
|
||||||
const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
|
});
|
||||||
setMetadataItems(generatedMockObjectMetadataItems);
|
|
||||||
|
|
||||||
return useFilteredObjectMetadataItems();
|
|
||||||
},
|
|
||||||
{
|
|
||||||
wrapper: Wrapper,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
act(() => {
|
act(() => {
|
||||||
const res = result.current.findObjectMetadataItemById(
|
const res = result.current.findObjectMetadataItemById(
|
||||||
@ -103,17 +83,9 @@ describe('useFilteredObjectMetadataItems', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should findObjectMetadataItemByNamePlural', async () => {
|
it('should findObjectMetadataItemByNamePlural', async () => {
|
||||||
const { result } = renderHook(
|
const { result } = renderHook(useFilteredObjectMetadataItems, {
|
||||||
() => {
|
wrapper: Wrapper,
|
||||||
const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
|
});
|
||||||
setMetadataItems(generatedMockObjectMetadataItems);
|
|
||||||
|
|
||||||
return useFilteredObjectMetadataItems();
|
|
||||||
},
|
|
||||||
{
|
|
||||||
wrapper: Wrapper,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
act(() => {
|
act(() => {
|
||||||
const res =
|
const res =
|
||||||
|
|||||||
@ -15,7 +15,7 @@ describe('computeDepthOneRecordGqlFieldsFromRecord', () => {
|
|||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
{
|
{
|
||||||
"attachments": false,
|
"attachments": false,
|
||||||
"avatarUrl": false,
|
"avatarUrl": true,
|
||||||
"calendarEventParticipants": false,
|
"calendarEventParticipants": false,
|
||||||
"city": true,
|
"city": true,
|
||||||
"company": true,
|
"company": true,
|
||||||
@ -23,25 +23,25 @@ describe('computeDepthOneRecordGqlFieldsFromRecord', () => {
|
|||||||
"createdAt": true,
|
"createdAt": true,
|
||||||
"createdBy": true,
|
"createdBy": true,
|
||||||
"deletedAt": true,
|
"deletedAt": true,
|
||||||
"emails": false,
|
"emails": true,
|
||||||
"favorites": false,
|
"favorites": false,
|
||||||
"id": true,
|
"id": true,
|
||||||
"intro": false,
|
"intro": true,
|
||||||
"jobTitle": true,
|
"jobTitle": true,
|
||||||
"linkedinLink": true,
|
"linkedinLink": true,
|
||||||
"messageParticipants": false,
|
"messageParticipants": false,
|
||||||
"name": true,
|
"name": true,
|
||||||
"noteTargets": true,
|
"noteTargets": true,
|
||||||
"performanceRating": false,
|
"performanceRating": true,
|
||||||
"phones": true,
|
"phones": true,
|
||||||
"pointOfContactForOpportunities": false,
|
"pointOfContactForOpportunities": false,
|
||||||
"position": true,
|
"position": true,
|
||||||
"searchVector": false,
|
"searchVector": false,
|
||||||
"taskTargets": true,
|
"taskTargets": true,
|
||||||
"timelineActivities": false,
|
"timelineActivities": false,
|
||||||
"updatedAt": false,
|
"updatedAt": true,
|
||||||
"whatsapp": false,
|
"whatsapp": true,
|
||||||
"workPreference": false,
|
"workPreference": true,
|
||||||
"xLink": true,
|
"xLink": true,
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
|||||||
@ -11,6 +11,7 @@ exports[`useDeleteOneRecord A. Starting from empty cache 1. Should successfully
|
|||||||
exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle successfull record deletion 1`] = `
|
exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle successfull record deletion 1`] = `
|
||||||
{
|
{
|
||||||
"__typename": "Person",
|
"__typename": "Person",
|
||||||
|
"avatarUrl": null,
|
||||||
"city": "ASd",
|
"city": "ASd",
|
||||||
"company": {
|
"company": {
|
||||||
"__typename": "Company",
|
"__typename": "Company",
|
||||||
@ -54,12 +55,18 @@ exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle succe
|
|||||||
"createdAt": "2025-01-02T09:52:46.814Z",
|
"createdAt": "2025-01-02T09:52:46.814Z",
|
||||||
"createdBy": {
|
"createdBy": {
|
||||||
"__typename": "Actor",
|
"__typename": "Actor",
|
||||||
|
"context": null,
|
||||||
"name": "Tim Apple",
|
"name": "Tim Apple",
|
||||||
"source": "MANUAL",
|
"source": "MANUAL",
|
||||||
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
||||||
},
|
},
|
||||||
"deletedAt": "2024-02-14T09:45:00Z",
|
"deletedAt": "2024-02-14T09:45:00Z",
|
||||||
|
"emails": {
|
||||||
|
"additionalEmails": [],
|
||||||
|
"primaryEmail": "asd.com",
|
||||||
|
},
|
||||||
"id": "da3c2c4b-da01-4b81-9734-226069eb4cd0",
|
"id": "da3c2c4b-da01-4b81-9734-226069eb4cd0",
|
||||||
|
"intro": "",
|
||||||
"jobTitle": "",
|
"jobTitle": "",
|
||||||
"linkedinLink": {
|
"linkedinLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
@ -73,13 +80,23 @@ exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle succe
|
|||||||
"lastName": "Test",
|
"lastName": "Test",
|
||||||
},
|
},
|
||||||
"noteTargets": [],
|
"noteTargets": [],
|
||||||
|
"performanceRating": null,
|
||||||
"phones": {
|
"phones": {
|
||||||
|
"additionalPhones": [],
|
||||||
"primaryPhoneCallingCode": "+33",
|
"primaryPhoneCallingCode": "+33",
|
||||||
"primaryPhoneCountryCode": "FR",
|
"primaryPhoneCountryCode": "FR",
|
||||||
"primaryPhoneNumber": "781234562",
|
"primaryPhoneNumber": "781234562",
|
||||||
},
|
},
|
||||||
"position": 0,
|
"position": 0,
|
||||||
"taskTargets": [],
|
"taskTargets": [],
|
||||||
|
"updatedAt": "2025-01-02T09:52:46.814Z",
|
||||||
|
"whatsapp": {
|
||||||
|
"additionalPhones": [],
|
||||||
|
"primaryPhoneCallingCode": "",
|
||||||
|
"primaryPhoneCountryCode": "",
|
||||||
|
"primaryPhoneNumber": "",
|
||||||
|
},
|
||||||
|
"workPreference": null,
|
||||||
"xLink": {
|
"xLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
"primaryLinkLabel": "",
|
"primaryLinkLabel": "",
|
||||||
@ -135,16 +152,23 @@ exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle succe
|
|||||||
"people": [
|
"people": [
|
||||||
{
|
{
|
||||||
"__typename": "Person",
|
"__typename": "Person",
|
||||||
|
"avatarUrl": null,
|
||||||
"city": "Seattle",
|
"city": "Seattle",
|
||||||
"createdAt": "2025-01-01T09:50:00.000Z",
|
"createdAt": "2025-01-01T09:50:00.000Z",
|
||||||
"createdBy": {
|
"createdBy": {
|
||||||
"__typename": "Actor",
|
"__typename": "Actor",
|
||||||
|
"context": null,
|
||||||
"name": "Tim Apple",
|
"name": "Tim Apple",
|
||||||
"source": "MANUAL",
|
"source": "MANUAL",
|
||||||
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
||||||
},
|
},
|
||||||
"deletedAt": null,
|
"deletedAt": null,
|
||||||
|
"emails": {
|
||||||
|
"additionalEmails": [],
|
||||||
|
"primaryEmail": "christoph.calisto@linkedin.com",
|
||||||
|
},
|
||||||
"id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
|
"id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
|
||||||
|
"intro": "",
|
||||||
"jobTitle": "",
|
"jobTitle": "",
|
||||||
"linkedinLink": {
|
"linkedinLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
@ -157,12 +181,22 @@ exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle succe
|
|||||||
"firstName": "Christoph",
|
"firstName": "Christoph",
|
||||||
"lastName": "Callisto",
|
"lastName": "Callisto",
|
||||||
},
|
},
|
||||||
|
"performanceRating": null,
|
||||||
"phones": {
|
"phones": {
|
||||||
|
"additionalPhones": [],
|
||||||
"primaryPhoneCallingCode": "+33",
|
"primaryPhoneCallingCode": "+33",
|
||||||
"primaryPhoneCountryCode": "FR",
|
"primaryPhoneCountryCode": "FR",
|
||||||
"primaryPhoneNumber": "781234562",
|
"primaryPhoneNumber": "781234562",
|
||||||
},
|
},
|
||||||
"position": 1,
|
"position": 1,
|
||||||
|
"updatedAt": "2025-01-01T09:50:00.000Z",
|
||||||
|
"whatsapp": {
|
||||||
|
"additionalPhones": [],
|
||||||
|
"primaryPhoneCallingCode": "",
|
||||||
|
"primaryPhoneCountryCode": "",
|
||||||
|
"primaryPhoneNumber": "",
|
||||||
|
},
|
||||||
|
"workPreference": null,
|
||||||
"xLink": {
|
"xLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
"primaryLinkLabel": "",
|
"primaryLinkLabel": "",
|
||||||
@ -195,6 +229,7 @@ exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle succe
|
|||||||
"lastName": "Palmer",
|
"lastName": "Palmer",
|
||||||
},
|
},
|
||||||
"phones": {
|
"phones": {
|
||||||
|
"additionalPhones": [],
|
||||||
"primaryPhoneCallingCode": "+33",
|
"primaryPhoneCallingCode": "+33",
|
||||||
"primaryPhoneCountryCode": "FR",
|
"primaryPhoneCountryCode": "FR",
|
||||||
"primaryPhoneNumber": "781234576",
|
"primaryPhoneNumber": "781234576",
|
||||||
@ -216,6 +251,7 @@ exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle succe
|
|||||||
exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optimistic cache on record deletion 1`] = `
|
exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optimistic cache on record deletion 1`] = `
|
||||||
{
|
{
|
||||||
"__typename": "Person",
|
"__typename": "Person",
|
||||||
|
"avatarUrl": null,
|
||||||
"city": "ASd",
|
"city": "ASd",
|
||||||
"company": {
|
"company": {
|
||||||
"__typename": "Company",
|
"__typename": "Company",
|
||||||
@ -259,12 +295,18 @@ exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optim
|
|||||||
"createdAt": "2025-01-02T09:52:46.814Z",
|
"createdAt": "2025-01-02T09:52:46.814Z",
|
||||||
"createdBy": {
|
"createdBy": {
|
||||||
"__typename": "Actor",
|
"__typename": "Actor",
|
||||||
|
"context": null,
|
||||||
"name": "Tim Apple",
|
"name": "Tim Apple",
|
||||||
"source": "MANUAL",
|
"source": "MANUAL",
|
||||||
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
||||||
},
|
},
|
||||||
"deletedAt": Any<String>,
|
"deletedAt": Any<String>,
|
||||||
|
"emails": {
|
||||||
|
"additionalEmails": [],
|
||||||
|
"primaryEmail": "asd.com",
|
||||||
|
},
|
||||||
"id": "da3c2c4b-da01-4b81-9734-226069eb4cd0",
|
"id": "da3c2c4b-da01-4b81-9734-226069eb4cd0",
|
||||||
|
"intro": "",
|
||||||
"jobTitle": "",
|
"jobTitle": "",
|
||||||
"linkedinLink": {
|
"linkedinLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
@ -278,13 +320,23 @@ exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optim
|
|||||||
"lastName": "Test",
|
"lastName": "Test",
|
||||||
},
|
},
|
||||||
"noteTargets": [],
|
"noteTargets": [],
|
||||||
|
"performanceRating": null,
|
||||||
"phones": {
|
"phones": {
|
||||||
|
"additionalPhones": [],
|
||||||
"primaryPhoneCallingCode": "+33",
|
"primaryPhoneCallingCode": "+33",
|
||||||
"primaryPhoneCountryCode": "FR",
|
"primaryPhoneCountryCode": "FR",
|
||||||
"primaryPhoneNumber": "781234562",
|
"primaryPhoneNumber": "781234562",
|
||||||
},
|
},
|
||||||
"position": 0,
|
"position": 0,
|
||||||
"taskTargets": [],
|
"taskTargets": [],
|
||||||
|
"updatedAt": "2025-01-02T09:52:46.814Z",
|
||||||
|
"whatsapp": {
|
||||||
|
"additionalPhones": [],
|
||||||
|
"primaryPhoneCallingCode": "",
|
||||||
|
"primaryPhoneCountryCode": "",
|
||||||
|
"primaryPhoneNumber": "",
|
||||||
|
},
|
||||||
|
"workPreference": null,
|
||||||
"xLink": {
|
"xLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
"primaryLinkLabel": "",
|
"primaryLinkLabel": "",
|
||||||
@ -340,16 +392,23 @@ exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optim
|
|||||||
"people": [
|
"people": [
|
||||||
{
|
{
|
||||||
"__typename": "Person",
|
"__typename": "Person",
|
||||||
|
"avatarUrl": null,
|
||||||
"city": "Seattle",
|
"city": "Seattle",
|
||||||
"createdAt": "2025-01-01T09:50:00.000Z",
|
"createdAt": "2025-01-01T09:50:00.000Z",
|
||||||
"createdBy": {
|
"createdBy": {
|
||||||
"__typename": "Actor",
|
"__typename": "Actor",
|
||||||
|
"context": null,
|
||||||
"name": "Tim Apple",
|
"name": "Tim Apple",
|
||||||
"source": "MANUAL",
|
"source": "MANUAL",
|
||||||
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
||||||
},
|
},
|
||||||
"deletedAt": null,
|
"deletedAt": null,
|
||||||
|
"emails": {
|
||||||
|
"additionalEmails": [],
|
||||||
|
"primaryEmail": "christoph.calisto@linkedin.com",
|
||||||
|
},
|
||||||
"id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
|
"id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
|
||||||
|
"intro": "",
|
||||||
"jobTitle": "",
|
"jobTitle": "",
|
||||||
"linkedinLink": {
|
"linkedinLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
@ -362,12 +421,22 @@ exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optim
|
|||||||
"firstName": "Christoph",
|
"firstName": "Christoph",
|
||||||
"lastName": "Callisto",
|
"lastName": "Callisto",
|
||||||
},
|
},
|
||||||
|
"performanceRating": null,
|
||||||
"phones": {
|
"phones": {
|
||||||
|
"additionalPhones": [],
|
||||||
"primaryPhoneCallingCode": "+33",
|
"primaryPhoneCallingCode": "+33",
|
||||||
"primaryPhoneCountryCode": "FR",
|
"primaryPhoneCountryCode": "FR",
|
||||||
"primaryPhoneNumber": "781234562",
|
"primaryPhoneNumber": "781234562",
|
||||||
},
|
},
|
||||||
"position": 1,
|
"position": 1,
|
||||||
|
"updatedAt": "2025-01-01T09:50:00.000Z",
|
||||||
|
"whatsapp": {
|
||||||
|
"additionalPhones": [],
|
||||||
|
"primaryPhoneCallingCode": "",
|
||||||
|
"primaryPhoneCountryCode": "",
|
||||||
|
"primaryPhoneNumber": "",
|
||||||
|
},
|
||||||
|
"workPreference": null,
|
||||||
"xLink": {
|
"xLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
"primaryLinkLabel": "",
|
"primaryLinkLabel": "",
|
||||||
@ -400,6 +469,7 @@ exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optim
|
|||||||
"lastName": "Palmer",
|
"lastName": "Palmer",
|
||||||
},
|
},
|
||||||
"phones": {
|
"phones": {
|
||||||
|
"additionalPhones": [],
|
||||||
"primaryPhoneCallingCode": "+33",
|
"primaryPhoneCallingCode": "+33",
|
||||||
"primaryPhoneCountryCode": "FR",
|
"primaryPhoneCountryCode": "FR",
|
||||||
"primaryPhoneNumber": "781234576",
|
"primaryPhoneNumber": "781234576",
|
||||||
@ -421,6 +491,7 @@ exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optim
|
|||||||
exports[`useDeleteOneRecord B. Starting from filled cache 3. Should handle optimistic cache rollback on record deletion failure 1`] = `
|
exports[`useDeleteOneRecord B. Starting from filled cache 3. Should handle optimistic cache rollback on record deletion failure 1`] = `
|
||||||
{
|
{
|
||||||
"__typename": "Person",
|
"__typename": "Person",
|
||||||
|
"avatarUrl": null,
|
||||||
"city": "ASd",
|
"city": "ASd",
|
||||||
"company": {
|
"company": {
|
||||||
"__typename": "Company",
|
"__typename": "Company",
|
||||||
@ -464,12 +535,18 @@ exports[`useDeleteOneRecord B. Starting from filled cache 3. Should handle optim
|
|||||||
"createdAt": "2025-01-02T09:52:46.814Z",
|
"createdAt": "2025-01-02T09:52:46.814Z",
|
||||||
"createdBy": {
|
"createdBy": {
|
||||||
"__typename": "Actor",
|
"__typename": "Actor",
|
||||||
|
"context": null,
|
||||||
"name": "Tim Apple",
|
"name": "Tim Apple",
|
||||||
"source": "MANUAL",
|
"source": "MANUAL",
|
||||||
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
||||||
},
|
},
|
||||||
"deletedAt": null,
|
"deletedAt": null,
|
||||||
|
"emails": {
|
||||||
|
"additionalEmails": [],
|
||||||
|
"primaryEmail": "asd.com",
|
||||||
|
},
|
||||||
"id": "da3c2c4b-da01-4b81-9734-226069eb4cd0",
|
"id": "da3c2c4b-da01-4b81-9734-226069eb4cd0",
|
||||||
|
"intro": "",
|
||||||
"jobTitle": "",
|
"jobTitle": "",
|
||||||
"linkedinLink": {
|
"linkedinLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
@ -483,13 +560,23 @@ exports[`useDeleteOneRecord B. Starting from filled cache 3. Should handle optim
|
|||||||
"lastName": "Test",
|
"lastName": "Test",
|
||||||
},
|
},
|
||||||
"noteTargets": [],
|
"noteTargets": [],
|
||||||
|
"performanceRating": null,
|
||||||
"phones": {
|
"phones": {
|
||||||
|
"additionalPhones": [],
|
||||||
"primaryPhoneCallingCode": "+33",
|
"primaryPhoneCallingCode": "+33",
|
||||||
"primaryPhoneCountryCode": "FR",
|
"primaryPhoneCountryCode": "FR",
|
||||||
"primaryPhoneNumber": "781234562",
|
"primaryPhoneNumber": "781234562",
|
||||||
},
|
},
|
||||||
"position": 0,
|
"position": 0,
|
||||||
"taskTargets": [],
|
"taskTargets": [],
|
||||||
|
"updatedAt": "2025-01-02T09:52:46.814Z",
|
||||||
|
"whatsapp": {
|
||||||
|
"additionalPhones": [],
|
||||||
|
"primaryPhoneCallingCode": "",
|
||||||
|
"primaryPhoneCountryCode": "",
|
||||||
|
"primaryPhoneNumber": "",
|
||||||
|
},
|
||||||
|
"workPreference": null,
|
||||||
"xLink": {
|
"xLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
"primaryLinkLabel": "",
|
"primaryLinkLabel": "",
|
||||||
@ -545,16 +632,23 @@ exports[`useDeleteOneRecord B. Starting from filled cache 3. Should handle optim
|
|||||||
"people": [
|
"people": [
|
||||||
{
|
{
|
||||||
"__typename": "Person",
|
"__typename": "Person",
|
||||||
|
"avatarUrl": null,
|
||||||
"city": "Seattle",
|
"city": "Seattle",
|
||||||
"createdAt": "2025-01-01T09:50:00.000Z",
|
"createdAt": "2025-01-01T09:50:00.000Z",
|
||||||
"createdBy": {
|
"createdBy": {
|
||||||
"__typename": "Actor",
|
"__typename": "Actor",
|
||||||
|
"context": null,
|
||||||
"name": "Tim Apple",
|
"name": "Tim Apple",
|
||||||
"source": "MANUAL",
|
"source": "MANUAL",
|
||||||
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
||||||
},
|
},
|
||||||
"deletedAt": null,
|
"deletedAt": null,
|
||||||
|
"emails": {
|
||||||
|
"additionalEmails": [],
|
||||||
|
"primaryEmail": "christoph.calisto@linkedin.com",
|
||||||
|
},
|
||||||
"id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
|
"id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
|
||||||
|
"intro": "",
|
||||||
"jobTitle": "",
|
"jobTitle": "",
|
||||||
"linkedinLink": {
|
"linkedinLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
@ -567,12 +661,22 @@ exports[`useDeleteOneRecord B. Starting from filled cache 3. Should handle optim
|
|||||||
"firstName": "Christoph",
|
"firstName": "Christoph",
|
||||||
"lastName": "Callisto",
|
"lastName": "Callisto",
|
||||||
},
|
},
|
||||||
|
"performanceRating": null,
|
||||||
"phones": {
|
"phones": {
|
||||||
|
"additionalPhones": [],
|
||||||
"primaryPhoneCallingCode": "+33",
|
"primaryPhoneCallingCode": "+33",
|
||||||
"primaryPhoneCountryCode": "FR",
|
"primaryPhoneCountryCode": "FR",
|
||||||
"primaryPhoneNumber": "781234562",
|
"primaryPhoneNumber": "781234562",
|
||||||
},
|
},
|
||||||
"position": 1,
|
"position": 1,
|
||||||
|
"updatedAt": "2025-01-01T09:50:00.000Z",
|
||||||
|
"whatsapp": {
|
||||||
|
"additionalPhones": [],
|
||||||
|
"primaryPhoneCallingCode": "",
|
||||||
|
"primaryPhoneCountryCode": "",
|
||||||
|
"primaryPhoneNumber": "",
|
||||||
|
},
|
||||||
|
"workPreference": null,
|
||||||
"xLink": {
|
"xLink": {
|
||||||
"__typename": "Links",
|
"__typename": "Links",
|
||||||
"primaryLinkLabel": "",
|
"primaryLinkLabel": "",
|
||||||
@ -605,6 +709,7 @@ exports[`useDeleteOneRecord B. Starting from filled cache 3. Should handle optim
|
|||||||
"lastName": "Palmer",
|
"lastName": "Palmer",
|
||||||
},
|
},
|
||||||
"phones": {
|
"phones": {
|
||||||
|
"additionalPhones": [],
|
||||||
"primaryPhoneCallingCode": "+33",
|
"primaryPhoneCallingCode": "+33",
|
||||||
"primaryPhoneCountryCode": "FR",
|
"primaryPhoneCountryCode": "FR",
|
||||||
"primaryPhoneNumber": "781234576",
|
"primaryPhoneNumber": "781234576",
|
||||||
|
|||||||
@ -1,58 +1,35 @@
|
|||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
import { useSetRecoilState } from 'recoil';
|
|
||||||
|
|
||||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||||
import {
|
|
||||||
query,
|
|
||||||
responseData,
|
|
||||||
variables,
|
|
||||||
} from '@/object-record/hooks/__mocks__/useFindManyRecords';
|
|
||||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||||
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
|
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
|
||||||
import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems';
|
import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems';
|
||||||
|
|
||||||
const mocks = [
|
|
||||||
{
|
|
||||||
request: {
|
|
||||||
query,
|
|
||||||
variables,
|
|
||||||
},
|
|
||||||
result: jest.fn(() => ({
|
|
||||||
data: {
|
|
||||||
deletePeople: responseData,
|
|
||||||
},
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const Wrapper = getJestMetadataAndApolloMocksWrapper({
|
const Wrapper = getJestMetadataAndApolloMocksWrapper({
|
||||||
apolloMocks: mocks,
|
apolloMocks: [],
|
||||||
|
onInitializeRecoilSnapshot: (snapshot) => {
|
||||||
|
snapshot.set(currentWorkspaceMemberState, {
|
||||||
|
id: '32219445-f587-4c40-b2b1-6d3205ed96da',
|
||||||
|
name: { firstName: 'John', lastName: 'Connor' },
|
||||||
|
locale: 'en',
|
||||||
|
colorScheme: 'Light',
|
||||||
|
userEmail: 'userEmail',
|
||||||
|
});
|
||||||
|
snapshot.set(objectMetadataItemsState, generatedMockObjectMetadataItems);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('useFindManyRecords', () => {
|
describe('useFindManyRecords', () => {
|
||||||
it('should work as expected', async () => {
|
it('should work as expected', async () => {
|
||||||
const onCompleted = jest.fn();
|
const onCompleted = jest.fn();
|
||||||
|
|
||||||
const { result } = renderHook(
|
const { result } = renderHook(
|
||||||
() => {
|
() => {
|
||||||
const setCurrentWorkspaceMember = useSetRecoilState(
|
|
||||||
currentWorkspaceMemberState,
|
|
||||||
);
|
|
||||||
setCurrentWorkspaceMember({
|
|
||||||
id: '32219445-f587-4c40-b2b1-6d3205ed96da',
|
|
||||||
name: { firstName: 'John', lastName: 'Connor' },
|
|
||||||
locale: 'en',
|
|
||||||
colorScheme: 'Light',
|
|
||||||
userEmail: 'userEmail',
|
|
||||||
});
|
|
||||||
|
|
||||||
const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
|
|
||||||
|
|
||||||
setMetadataItems(generatedMockObjectMetadataItems);
|
|
||||||
|
|
||||||
return useFindManyRecords({
|
return useFindManyRecords({
|
||||||
objectNameSingular: 'person',
|
objectNameSingular: 'person',
|
||||||
onCompleted,
|
onCompleted,
|
||||||
|
skip: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -60,8 +37,9 @@ describe('useFindManyRecords', () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.current.loading).toBe(true);
|
expect(result.current.loading).toBe(false);
|
||||||
expect(result.current.error).toBeUndefined();
|
expect(result.current.error).toBeUndefined();
|
||||||
expect(result.current.records.length).toBe(0);
|
expect(result.current.records.length).toBe(0);
|
||||||
|
expect(result.current.objectMetadataItem).toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||||
import { PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS } from '@/object-record/hooks/__mocks__/personFragments';
|
import { PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS } from '@/object-record/hooks/__mocks__/personFragments';
|
||||||
|
import { responseData } from '@/object-record/hooks/__mocks__/useUpdateOneRecord';
|
||||||
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
||||||
import {
|
import {
|
||||||
phonesFieldDefinition,
|
phonesFieldDefinition,
|
||||||
@ -36,6 +37,8 @@ const phoneMock = {
|
|||||||
additionalPhones: [],
|
additionalPhones: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mockPersonResponse = { ...responseData, id: 'recordId' };
|
||||||
|
|
||||||
const mocks: MockedResponse[] = [
|
const mocks: MockedResponse[] = [
|
||||||
{
|
{
|
||||||
request: {
|
request: {
|
||||||
@ -49,9 +52,7 @@ const mocks: MockedResponse[] = [
|
|||||||
},
|
},
|
||||||
result: jest.fn(() => ({
|
result: jest.fn(() => ({
|
||||||
data: {
|
data: {
|
||||||
updatePerson: {
|
updatePerson: mockPersonResponse,
|
||||||
id: 'recordId',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
@ -65,9 +66,7 @@ const mocks: MockedResponse[] = [
|
|||||||
},
|
},
|
||||||
result: jest.fn(() => ({
|
result: jest.fn(() => ({
|
||||||
data: {
|
data: {
|
||||||
updatePerson: {
|
updatePerson: mockPersonResponse,
|
||||||
id: 'recordId',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { act } from 'react-dom/test-utils';
|
|
||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
|
import { act } from 'react';
|
||||||
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
||||||
|
|
||||||
import { CurrentUser, currentUserState } from '@/auth/states/currentUserState';
|
import { CurrentUser, currentUserState } from '@/auth/states/currentUserState';
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { MockedProvider } from '@apollo/client/testing';
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
import { renderHook } from '@testing-library/react';
|
import { act, renderHook } from '@testing-library/react';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
@ -99,7 +99,9 @@ describe('useWebhookForm', () => {
|
|||||||
secret: 'test-secret',
|
secret: 'test-secret',
|
||||||
};
|
};
|
||||||
|
|
||||||
await result.current.handleSave(formData);
|
await act(async () => {
|
||||||
|
await result.current.handleSave(formData);
|
||||||
|
});
|
||||||
|
|
||||||
expect(mockCreateOneRecord).toHaveBeenCalledWith({
|
expect(mockCreateOneRecord).toHaveBeenCalledWith({
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
@ -132,7 +134,9 @@ describe('useWebhookForm', () => {
|
|||||||
secret: 'test-secret',
|
secret: 'test-secret',
|
||||||
};
|
};
|
||||||
|
|
||||||
await result.current.handleSave(formData);
|
await act(async () => {
|
||||||
|
await result.current.handleSave(formData);
|
||||||
|
});
|
||||||
|
|
||||||
expect(mockEnqueueErrorSnackBar).toHaveBeenCalledWith({
|
expect(mockEnqueueErrorSnackBar).toHaveBeenCalledWith({
|
||||||
apolloError: error,
|
apolloError: error,
|
||||||
@ -159,7 +163,9 @@ describe('useWebhookForm', () => {
|
|||||||
secret: 'test-secret',
|
secret: 'test-secret',
|
||||||
};
|
};
|
||||||
|
|
||||||
await result.current.handleSave(formData);
|
await act(async () => {
|
||||||
|
await result.current.handleSave(formData);
|
||||||
|
});
|
||||||
|
|
||||||
expect(mockCreateOneRecord).toHaveBeenCalledWith({
|
expect(mockCreateOneRecord).toHaveBeenCalledWith({
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
@ -206,7 +212,9 @@ describe('useWebhookForm', () => {
|
|||||||
secret: 'updated-secret',
|
secret: 'updated-secret',
|
||||||
};
|
};
|
||||||
|
|
||||||
await result.current.handleSave(formData);
|
await act(async () => {
|
||||||
|
await result.current.handleSave(formData);
|
||||||
|
});
|
||||||
|
|
||||||
expect(mockUpdateOneRecord).toHaveBeenCalledWith({
|
expect(mockUpdateOneRecord).toHaveBeenCalledWith({
|
||||||
idToUpdate: webhookId,
|
idToUpdate: webhookId,
|
||||||
@ -241,7 +249,9 @@ describe('useWebhookForm', () => {
|
|||||||
secret: 'test-secret',
|
secret: 'test-secret',
|
||||||
};
|
};
|
||||||
|
|
||||||
await result.current.handleSave(formData);
|
await act(async () => {
|
||||||
|
await result.current.handleSave(formData);
|
||||||
|
});
|
||||||
|
|
||||||
expect(mockEnqueueErrorSnackBar).toHaveBeenCalledWith({
|
expect(mockEnqueueErrorSnackBar).toHaveBeenCalledWith({
|
||||||
apolloError: error,
|
apolloError: error,
|
||||||
@ -256,7 +266,9 @@ describe('useWebhookForm', () => {
|
|||||||
{ wrapper: Wrapper },
|
{ wrapper: Wrapper },
|
||||||
);
|
);
|
||||||
|
|
||||||
result.current.updateOperation(0, 'object', 'person');
|
act(() => {
|
||||||
|
result.current.updateOperation(0, 'object', 'person');
|
||||||
|
});
|
||||||
|
|
||||||
const operations = result.current.formConfig.getValues('operations');
|
const operations = result.current.formConfig.getValues('operations');
|
||||||
expect(operations[0].object).toBe('person');
|
expect(operations[0].object).toBe('person');
|
||||||
@ -268,16 +280,20 @@ describe('useWebhookForm', () => {
|
|||||||
{ wrapper: Wrapper },
|
{ wrapper: Wrapper },
|
||||||
);
|
);
|
||||||
|
|
||||||
result.current.formConfig.setValue('operations', [
|
act(() => {
|
||||||
{ object: 'person', action: 'created' },
|
result.current.formConfig.setValue('operations', [
|
||||||
{ object: 'company', action: 'updated' },
|
{ object: 'person', action: 'created' },
|
||||||
]);
|
{ object: 'company', action: 'updated' },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
const initialOperations =
|
const initialOperations =
|
||||||
result.current.formConfig.getValues('operations');
|
result.current.formConfig.getValues('operations');
|
||||||
const initialCount = initialOperations.length;
|
const initialCount = initialOperations.length;
|
||||||
|
|
||||||
result.current.removeOperation(0);
|
act(() => {
|
||||||
|
result.current.removeOperation(0);
|
||||||
|
});
|
||||||
|
|
||||||
const updatedOperations =
|
const updatedOperations =
|
||||||
result.current.formConfig.getValues('operations');
|
result.current.formConfig.getValues('operations');
|
||||||
@ -300,7 +316,9 @@ describe('useWebhookForm', () => {
|
|||||||
{ wrapper: Wrapper },
|
{ wrapper: Wrapper },
|
||||||
);
|
);
|
||||||
|
|
||||||
await result.current.deleteWebhook();
|
await act(async () => {
|
||||||
|
await result.current.deleteWebhook();
|
||||||
|
});
|
||||||
|
|
||||||
expect(mockDeleteOneRecord).toHaveBeenCalledWith(webhookId);
|
expect(mockDeleteOneRecord).toHaveBeenCalledWith(webhookId);
|
||||||
expect(mockEnqueueSuccessSnackBar).toHaveBeenCalledWith({
|
expect(mockEnqueueSuccessSnackBar).toHaveBeenCalledWith({
|
||||||
@ -314,7 +332,9 @@ describe('useWebhookForm', () => {
|
|||||||
{ wrapper: Wrapper },
|
{ wrapper: Wrapper },
|
||||||
);
|
);
|
||||||
|
|
||||||
await result.current.deleteWebhook();
|
await act(async () => {
|
||||||
|
await result.current.deleteWebhook();
|
||||||
|
});
|
||||||
|
|
||||||
expect(mockEnqueueErrorSnackBar).toHaveBeenCalledWith({
|
expect(mockEnqueueErrorSnackBar).toHaveBeenCalledWith({
|
||||||
message: 'Webhook ID is required for deletion',
|
message: 'Webhook ID is required for deletion',
|
||||||
@ -336,7 +356,9 @@ describe('useWebhookForm', () => {
|
|||||||
{ wrapper: Wrapper },
|
{ wrapper: Wrapper },
|
||||||
);
|
);
|
||||||
|
|
||||||
await result.current.deleteWebhook();
|
await act(async () => {
|
||||||
|
await result.current.deleteWebhook();
|
||||||
|
});
|
||||||
|
|
||||||
expect(mockEnqueueErrorSnackBar).toHaveBeenCalledWith({
|
expect(mockEnqueueErrorSnackBar).toHaveBeenCalledWith({
|
||||||
apolloError: error,
|
apolloError: error,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { act } from 'react-dom/test-utils';
|
import { act, renderHook } from '@testing-library/react';
|
||||||
import { renderHook } from '@testing-library/react';
|
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { act } from 'react-dom/test-utils';
|
import { act, renderHook } from '@testing-library/react';
|
||||||
import { renderHook } from '@testing-library/react';
|
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
|
|
||||||
import { useDialogManagerScopedStates } from '@/ui/feedback/dialog-manager/hooks/internal/useDialogManagerScopedStates';
|
import { useDialogManagerScopedStates } from '@/ui/feedback/dialog-manager/hooks/internal/useDialogManagerScopedStates';
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { act } from 'react-dom/test-utils';
|
import { act, renderHook } from '@testing-library/react';
|
||||||
import { renderHook } from '@testing-library/react';
|
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
|
|
||||||
import { useSnackBarManagerScopedStates } from '@/ui/feedback/snack-bar-manager/hooks/internal/useSnackBarManagerScopedStates';
|
import { useSnackBarManagerScopedStates } from '@/ui/feedback/snack-bar-manager/hooks/internal/useSnackBarManagerScopedStates';
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { act } from 'react-dom/test-utils';
|
|
||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
|
import { act } from 'react';
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
|
|
||||||
import { useIconPicker } from '@/ui/input/hooks/useIconPicker';
|
import { useIconPicker } from '@/ui/input/hooks/useIconPicker';
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
import { act } from 'react-dom/test-utils';
|
import { act } from 'react';
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
|
|
||||||
import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
|
import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { act } from 'react-dom/test-utils';
|
import { act, renderHook } from '@testing-library/react';
|
||||||
import { renderHook } from '@testing-library/react';
|
|
||||||
import { RecoilRoot, useRecoilValue } from 'recoil';
|
import { RecoilRoot, useRecoilValue } from 'recoil';
|
||||||
|
|
||||||
import { stepBarInternalState } from '../../states/stepBarInternalState';
|
import { stepBarInternalState } from '../../states/stepBarInternalState';
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { render } from '@testing-library/react';
|
import { render } from '@testing-library/react';
|
||||||
|
import { act } from 'react';
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
|
|
||||||
import { PointerEventListener } from '@/ui/utilities/pointer-event/types/PointerEventListener';
|
import { PointerEventListener } from '@/ui/utilities/pointer-event/types/PointerEventListener';
|
||||||
@ -70,10 +71,12 @@ describe('DragSelect', () => {
|
|||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
callbacks.onMouseDown({
|
act(() => {
|
||||||
x: 150,
|
callbacks.onMouseDown({
|
||||||
y: 150,
|
x: 150,
|
||||||
event: mockEvent,
|
y: 150,
|
||||||
|
event: mockEvent,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockEvent.preventDefault).not.toHaveBeenCalled();
|
expect(mockEvent.preventDefault).not.toHaveBeenCalled();
|
||||||
@ -92,10 +95,12 @@ describe('DragSelect', () => {
|
|||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
callbacks.onMouseDown({
|
act(() => {
|
||||||
x: 150,
|
callbacks.onMouseDown({
|
||||||
y: 150,
|
x: 150,
|
||||||
event: mockEvent,
|
y: 150,
|
||||||
|
event: mockEvent,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockEvent.preventDefault).toHaveBeenCalled();
|
expect(mockEvent.preventDefault).toHaveBeenCalled();
|
||||||
@ -131,10 +136,12 @@ describe('DragSelect', () => {
|
|||||||
.mockReturnValue(mockBoundaryElement);
|
.mockReturnValue(mockBoundaryElement);
|
||||||
mockBoundaryElement.contains = jest.fn().mockReturnValue(true);
|
mockBoundaryElement.contains = jest.fn().mockReturnValue(true);
|
||||||
|
|
||||||
callbacks.onMouseDown({
|
act(() => {
|
||||||
x: 150,
|
callbacks.onMouseDown({
|
||||||
y: 150,
|
x: 150,
|
||||||
event: { target: mockTarget, preventDefault: jest.fn() },
|
y: 150,
|
||||||
|
event: { target: mockTarget, preventDefault: jest.fn() },
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockSelectableContainer.closest).toHaveBeenCalledWith(
|
expect(mockSelectableContainer.closest).toHaveBeenCalledWith(
|
||||||
@ -160,10 +167,12 @@ describe('DragSelect', () => {
|
|||||||
mockSelectableContainer.contains = jest.fn().mockReturnValue(true);
|
mockSelectableContainer.contains = jest.fn().mockReturnValue(true);
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
callbacks.onMouseDown({
|
act(() => {
|
||||||
x: 150,
|
callbacks.onMouseDown({
|
||||||
y: 150,
|
x: 150,
|
||||||
event: { target: mockTarget, preventDefault: jest.fn() },
|
y: 150,
|
||||||
|
event: { target: mockTarget, preventDefault: jest.fn() },
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { act } from 'react-dom/test-utils';
|
|
||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
|
import { act } from 'react';
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
|
|
||||||
import { useDragSelect } from '../useDragSelect';
|
import { useDragSelect } from '../useDragSelect';
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { fireEvent, renderHook } from '@testing-library/react';
|
import { act, fireEvent, renderHook } from '@testing-library/react';
|
||||||
import { act } from 'react-dom/test-utils';
|
|
||||||
import { MemoryRouter, useLocation } from 'react-router-dom';
|
import { MemoryRouter, useLocation } from 'react-router-dom';
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { createContext } from 'react';
|
|
||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
|
import { createContext } from 'react';
|
||||||
|
|
||||||
import { useContextScopeId } from '@/ui/utilities/recoil-scope/hooks/useContextScopeId';
|
import { useContextScopeId } from '@/ui/utilities/recoil-scope/hooks/useContextScopeId';
|
||||||
|
|
||||||
@ -25,8 +25,19 @@ describe('useContextScopeId', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should throw an error when used outside of the specified context', () => {
|
it('Should throw an error when used outside of the specified context', () => {
|
||||||
|
// Suppress console errors for this test since we're expecting an error
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
const originalConsoleError = console.error;
|
||||||
|
console.error = jest.fn();
|
||||||
|
/* eslint-enable no-console */
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
renderHook(() => useContextScopeId(nullContext));
|
renderHook(() => useContextScopeId(nullContext));
|
||||||
}).toThrow(ERROR_MESSAGE);
|
}).toThrow(ERROR_MESSAGE);
|
||||||
|
|
||||||
|
// Restore console.error
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
console.error = originalConsoleError;
|
||||||
|
/* eslint-enable no-console */
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { createContext } from 'react';
|
|
||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
|
import { createContext } from 'react';
|
||||||
|
|
||||||
import { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopeId';
|
import { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopeId';
|
||||||
|
|
||||||
@ -25,8 +25,19 @@ describe('useRecoilScopeId', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should throw an error when used outside of the specified context', () => {
|
it('Should throw an error when used outside of the specified context', () => {
|
||||||
|
// Suppress console errors for this test since we're expecting an error
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
const originalConsoleError = console.error;
|
||||||
|
console.error = jest.fn();
|
||||||
|
/* eslint-enable no-console */
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
renderHook(() => useRecoilScopeId(nullContext));
|
renderHook(() => useRecoilScopeId(nullContext));
|
||||||
}).toThrow(ERROR_MESSAGE);
|
}).toThrow(ERROR_MESSAGE);
|
||||||
|
|
||||||
|
// Restore console.error
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
console.error = originalConsoleError;
|
||||||
|
/* eslint-enable no-console */
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { WorkflowWithCurrentVersion } from '@/workflow/types/Workflow';
|
import { WorkflowWithCurrentVersion } from '@/workflow/types/Workflow';
|
||||||
import { renderHook } from '@testing-library/react';
|
import { act, renderHook } from '@testing-library/react';
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot } from 'recoil';
|
||||||
import { WorkflowVisualizerComponentInstanceContext } from '../../../workflow-diagram/states/contexts/WorkflowVisualizerComponentInstanceContext';
|
import { WorkflowVisualizerComponentInstanceContext } from '../../../workflow-diagram/states/contexts/WorkflowVisualizerComponentInstanceContext';
|
||||||
import { useCreateStep } from '../useCreateStep';
|
import { useCreateStep } from '../useCreateStep';
|
||||||
@ -63,10 +63,13 @@ describe('useCreateStep', () => {
|
|||||||
wrapper,
|
wrapper,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
await result.current.createStep({
|
|
||||||
newStepType: 'CODE',
|
await act(async () => {
|
||||||
parentStepId: 'parent-step-id',
|
await result.current.createStep({
|
||||||
nextStepId: undefined,
|
newStepType: 'CODE',
|
||||||
|
parentStepId: 'parent-step-id',
|
||||||
|
nextStepId: undefined,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockCreateWorkflowVersionStep).toHaveBeenCalled();
|
expect(mockCreateWorkflowVersionStep).toHaveBeenCalled();
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { renderHook } from '@testing-library/react';
|
import { act, renderHook } from '@testing-library/react';
|
||||||
import { act } from 'react-dom/test-utils';
|
|
||||||
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
|
|||||||
@ -29,11 +29,27 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234562',
|
primaryPhoneNumber: '781234562',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: 'da3c2c4b-da01-4b81-9734-226069eb4cd0',
|
id: 'da3c2c4b-da01-4b81-9734-226069eb4cd0',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
position: 0,
|
position: 0,
|
||||||
email: 'asd.com',
|
email: 'asd.com',
|
||||||
|
avatarUrl: null,
|
||||||
|
emails: {
|
||||||
|
primaryEmail: 'asd.com',
|
||||||
|
additionalEmails: [],
|
||||||
|
},
|
||||||
|
intro: '',
|
||||||
|
performanceRating: null,
|
||||||
|
updatedAt: '2025-01-02T09:52:46.814Z',
|
||||||
|
whatsapp: {
|
||||||
|
primaryPhoneNumber: '',
|
||||||
|
primaryPhoneCountryCode: '',
|
||||||
|
primaryPhoneCallingCode: '',
|
||||||
|
additionalPhones: [],
|
||||||
|
},
|
||||||
|
workPreference: null,
|
||||||
name: {
|
name: {
|
||||||
__typename: 'FullName',
|
__typename: 'FullName',
|
||||||
firstName: 'Test',
|
firstName: 'Test',
|
||||||
@ -58,6 +74,7 @@ export const peopleQueryResult = {
|
|||||||
source: 'MANUAL',
|
source: 'MANUAL',
|
||||||
workspaceMemberId: '20202020-0687-4c41-b707-ed1bfca972a7',
|
workspaceMemberId: '20202020-0687-4c41-b707-ed1bfca972a7',
|
||||||
name: 'Tim Apple',
|
name: 'Tim Apple',
|
||||||
|
context: null,
|
||||||
},
|
},
|
||||||
xLink: {
|
xLink: {
|
||||||
__typename: 'Links',
|
__typename: 'Links',
|
||||||
@ -161,11 +178,27 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234562',
|
primaryPhoneNumber: '781234562',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-1c0e-494c-a1b6-85b1c6fefaa5',
|
id: '20202020-1c0e-494c-a1b6-85b1c6fefaa5',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
position: 1,
|
position: 1,
|
||||||
email: 'christoph.calisto@linkedin.com',
|
email: 'christoph.calisto@linkedin.com',
|
||||||
|
avatarUrl: null,
|
||||||
|
emails: {
|
||||||
|
primaryEmail: 'christoph.calisto@linkedin.com',
|
||||||
|
additionalEmails: [],
|
||||||
|
},
|
||||||
|
intro: '',
|
||||||
|
performanceRating: null,
|
||||||
|
updatedAt: '2025-01-01T09:50:00.000Z',
|
||||||
|
whatsapp: {
|
||||||
|
primaryPhoneNumber: '',
|
||||||
|
primaryPhoneCountryCode: '',
|
||||||
|
primaryPhoneCallingCode: '',
|
||||||
|
additionalPhones: [],
|
||||||
|
},
|
||||||
|
workPreference: null,
|
||||||
name: {
|
name: {
|
||||||
__typename: 'FullName',
|
__typename: 'FullName',
|
||||||
firstName: 'Christoph',
|
firstName: 'Christoph',
|
||||||
@ -190,6 +223,7 @@ export const peopleQueryResult = {
|
|||||||
source: 'MANUAL',
|
source: 'MANUAL',
|
||||||
workspaceMemberId: '20202020-0687-4c41-b707-ed1bfca972a7',
|
workspaceMemberId: '20202020-0687-4c41-b707-ed1bfca972a7',
|
||||||
name: 'Tim Apple',
|
name: 'Tim Apple',
|
||||||
|
context: null,
|
||||||
},
|
},
|
||||||
xLink: {
|
xLink: {
|
||||||
__typename: 'Links',
|
__typename: 'Links',
|
||||||
@ -293,6 +327,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234576',
|
primaryPhoneNumber: '781234576',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-ac73-4797-824e-87a1f5aea9e0',
|
id: '20202020-ac73-4797-824e-87a1f5aea9e0',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -394,6 +429,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234545',
|
primaryPhoneNumber: '781234545',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-f517-42fd-80ae-14173b3b70ae',
|
id: '20202020-f517-42fd-80ae-14173b3b70ae',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -495,6 +531,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234587',
|
primaryPhoneNumber: '781234587',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-eee1-4690-ad2c-8619e5b56a2e',
|
id: '20202020-eee1-4690-ad2c-8619e5b56a2e',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -596,6 +633,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234599',
|
primaryPhoneNumber: '781234599',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-6784-4449-afdf-dc62cb8702f2',
|
id: '20202020-6784-4449-afdf-dc62cb8702f2',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -697,6 +735,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234572',
|
primaryPhoneNumber: '781234572',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-490f-4466-8391-733cfd66a0c8',
|
id: '20202020-490f-4466-8391-733cfd66a0c8',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -798,6 +837,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234582',
|
primaryPhoneNumber: '781234582',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-80f1-4dff-b570-a74942528de3',
|
id: '20202020-80f1-4dff-b570-a74942528de3',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -899,6 +939,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234569',
|
primaryPhoneNumber: '781234569',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-338b-46df-8811-fa08c7d19d35',
|
id: '20202020-338b-46df-8811-fa08c7d19d35',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -1000,6 +1041,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234962',
|
primaryPhoneNumber: '781234962',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-64ad-4b0e-bbfd-e9fd795b7016',
|
id: '20202020-64ad-4b0e-bbfd-e9fd795b7016',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -1101,6 +1143,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234502',
|
primaryPhoneNumber: '781234502',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-5d54-41b7-ba36-f0d20e1417ae',
|
id: '20202020-5d54-41b7-ba36-f0d20e1417ae',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -1202,6 +1245,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234563',
|
primaryPhoneNumber: '781234563',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-623d-41fe-92e7-dd45b7c568e1',
|
id: '20202020-623d-41fe-92e7-dd45b7c568e1',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -1303,6 +1347,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781234542',
|
primaryPhoneNumber: '781234542',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-2d40-4e49-8df4-9c6a049190ef',
|
id: '20202020-2d40-4e49-8df4-9c6a049190ef',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -1404,6 +1449,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '782234562',
|
primaryPhoneNumber: '782234562',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-2d40-4e49-8df4-9c6a049190df',
|
id: '20202020-2d40-4e49-8df4-9c6a049190df',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -1505,6 +1551,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781274562',
|
primaryPhoneNumber: '781274562',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-2d40-4e49-8df4-9c6a049191de',
|
id: '20202020-2d40-4e49-8df4-9c6a049191de',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
@ -1606,6 +1653,7 @@ export const peopleQueryResult = {
|
|||||||
primaryPhoneNumber: '781239562',
|
primaryPhoneNumber: '781239562',
|
||||||
primaryPhoneCountryCode: 'FR',
|
primaryPhoneCountryCode: 'FR',
|
||||||
primaryPhoneCallingCode: '+33',
|
primaryPhoneCallingCode: '+33',
|
||||||
|
additionalPhones: [],
|
||||||
},
|
},
|
||||||
id: '20202020-2d40-4e49-8df4-9c6a049191df',
|
id: '20202020-2d40-4e49-8df4-9c6a049191df',
|
||||||
jobTitle: '',
|
jobTitle: '',
|
||||||
|
|||||||
@ -21,7 +21,7 @@ const jestConfig: JestConfigWithTsJest = {
|
|||||||
// Prettier v3 should be supported in jest v30 https://github.com/jestjs/jest/releases/tag/v30.0.0-alpha.1
|
// Prettier v3 should be supported in jest v30 https://github.com/jestjs/jest/releases/tag/v30.0.0-alpha.1
|
||||||
prettierPath: null,
|
prettierPath: null,
|
||||||
silent: false,
|
silent: false,
|
||||||
verbose: true,
|
errorOnDeprecated: true,
|
||||||
moduleFileExtensions: ['js', 'json', 'ts'],
|
moduleFileExtensions: ['js', 'json', 'ts'],
|
||||||
rootDir: '.',
|
rootDir: '.',
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
|
|||||||
@ -4,6 +4,7 @@ const jestConfig = {
|
|||||||
prettierPath: null,
|
prettierPath: null,
|
||||||
// to enable logs, comment out the following line
|
// to enable logs, comment out the following line
|
||||||
silent: true,
|
silent: true,
|
||||||
|
errorOnDeprecated: true,
|
||||||
clearMocks: true,
|
clearMocks: true,
|
||||||
displayName: 'twenty-server',
|
displayName: 'twenty-server',
|
||||||
rootDir: './',
|
rootDir: './',
|
||||||
|
|||||||
Reference in New Issue
Block a user