mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-27 06:13:16 +03:00
parent
94c2358c89
commit
e6f6069fe7
@ -24,8 +24,8 @@ const jestConfig: JestConfigWithTsJest = {
|
||||
extensionsToTreatAsEsm: ['.ts', '.tsx'],
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
statements: 65,
|
||||
lines: 64,
|
||||
statements: 64,
|
||||
lines: 63,
|
||||
functions: 55,
|
||||
},
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { gql } from '@apollo/client';
|
||||
import { MockedProvider, MockedResponse } from '@apollo/client/testing';
|
||||
import { act, renderHook, waitFor } from '@testing-library/react';
|
||||
import { ReactNode } from 'react';
|
||||
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
||||
|
||||
import { useActivities } from '@/activities/hooks/useActivities';
|
||||
@ -71,6 +71,7 @@ const mocks: MockedResponse[] = [
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
startCursor
|
||||
endCursor
|
||||
}
|
||||
@ -132,6 +133,7 @@ const mocks: MockedResponse[] = [
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
startCursor
|
||||
endCursor
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { MockedProvider, MockedResponse } from '@apollo/client/testing';
|
||||
import { act, renderHook, waitFor } from '@testing-library/react';
|
||||
import gql from 'graphql-tag';
|
||||
import { ReactNode } from 'react';
|
||||
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
||||
|
||||
import { useActivityTargetsForTargetableObject } from '@/activities/hooks/useActivityTargetsForTargetableObject';
|
||||
@ -58,6 +58,7 @@ const mocks: MockedResponse[] = [
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
startCursor
|
||||
endCursor
|
||||
}
|
||||
@ -67,8 +68,9 @@ const mocks: MockedResponse[] = [
|
||||
`,
|
||||
variables: {
|
||||
filter: { personId: { eq: '1234' } },
|
||||
limit: undefined,
|
||||
orderBy: undefined,
|
||||
lastCursor: undefined,
|
||||
limit: undefined,
|
||||
},
|
||||
},
|
||||
result: jest.fn(() => ({
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { MockedProvider, MockedResponse } from '@apollo/client/testing';
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import gql from 'graphql-tag';
|
||||
import pick from 'lodash.pick';
|
||||
import { ReactNode } from 'react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
import { useCreateActivityInDB } from '@/activities/hooks/useCreateActivityInDB';
|
||||
|
@ -2,10 +2,168 @@ import { Meta, StoryObj } from '@storybook/react';
|
||||
import { ComponentDecorator } from 'twenty-ui';
|
||||
|
||||
import { TaskList } from '@/activities/tasks/components/TaskList';
|
||||
import { Activity } from '@/activities/types/Activity';
|
||||
import { WorkspaceMember } from '@/workspace-member/types/WorkspaceMember';
|
||||
import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';
|
||||
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||
import { mockedActivities } from '~/testing/mock-data/activities';
|
||||
|
||||
const workspaceMember: WorkspaceMember = {
|
||||
__typename: 'WorkspaceMember',
|
||||
id: '374fe3a5-df1e-4119-afe0-2a62a2ba481e',
|
||||
name: {
|
||||
firstName: 'Charles',
|
||||
lastName: 'Test',
|
||||
},
|
||||
avatarUrl: '',
|
||||
locale: 'en',
|
||||
createdAt: '2023-04-26T10:23:42.33625+00:00',
|
||||
updatedAt: '2023-04-26T10:23:42.33625+00:00',
|
||||
userId: 'e2409670-1088-46b4-858e-f20a598d9d0f',
|
||||
userEmail: 'charles@test.com',
|
||||
colorScheme: 'Light',
|
||||
};
|
||||
|
||||
const mockedActivities: Array<Activity> = [
|
||||
{
|
||||
id: '3ecaa1be-aac7-463a-a38e-64078dd451d5',
|
||||
createdAt: '2023-04-26T10:12:42.33625+00:00',
|
||||
updatedAt: '2023-04-26T10:23:42.33625+00:00',
|
||||
reminderAt: null,
|
||||
title: 'My very first note',
|
||||
type: 'Note',
|
||||
body: '',
|
||||
dueAt: '2023-04-26T10:12:42.33625+00:00',
|
||||
completedAt: null,
|
||||
author: workspaceMember,
|
||||
assignee: workspaceMember,
|
||||
assigneeId: workspaceMember.id,
|
||||
authorId: workspaceMember.id,
|
||||
comments: [],
|
||||
activityTargets: [
|
||||
{
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb300',
|
||||
createdAt: '2023-04-26T10:12:42.33625+00:00',
|
||||
updatedAt: '2023-04-26T10:23:42.33625+00:00',
|
||||
targetObjectNameSingular: 'company',
|
||||
personId: null,
|
||||
companyId: '89bb825c-171e-4bcc-9cf7-43448d6fb280',
|
||||
company: {
|
||||
__typename: 'Company',
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb280',
|
||||
name: 'Airbnb',
|
||||
domainName: 'airbnb.com',
|
||||
},
|
||||
person: null,
|
||||
activityId: '89bb825c-171e-4bcc-9cf7-43448d6fb230',
|
||||
activity: {
|
||||
__typename: 'Activity',
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb230',
|
||||
createdAt: '2023-04-26T10:12:42.33625+00:00',
|
||||
updatedAt: '2023-04-26T10:23:42.33625+00:00',
|
||||
},
|
||||
__typename: 'ActivityTarget',
|
||||
},
|
||||
{
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb301',
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
targetObjectNameSingular: 'company',
|
||||
personId: null,
|
||||
companyId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae',
|
||||
company: {
|
||||
__typename: 'Company',
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
|
||||
name: 'Aircall',
|
||||
domainName: 'aircall.io',
|
||||
},
|
||||
person: null,
|
||||
activityId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae',
|
||||
activity: {
|
||||
__typename: 'Activity',
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb231',
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
},
|
||||
__typename: 'ActivityTarget',
|
||||
},
|
||||
],
|
||||
__typename: 'Activity',
|
||||
},
|
||||
{
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278a',
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
reminderAt: null,
|
||||
title: 'Another note',
|
||||
body: '',
|
||||
type: 'Note',
|
||||
completedAt: null,
|
||||
dueAt: '2029-08-26T10:12:42.33625+00:00',
|
||||
author: {
|
||||
...workspaceMember,
|
||||
},
|
||||
assignee: { ...workspaceMember },
|
||||
assigneeId: workspaceMember.id,
|
||||
authorId: workspaceMember.id,
|
||||
comments: [],
|
||||
activityTargets: [
|
||||
{
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278t',
|
||||
createdAt: '2023-04-26T10:12:42.33625+00:00',
|
||||
updatedAt: '2023-04-26T10:23:42.33625+00:00',
|
||||
targetObjectNameSingular: 'person',
|
||||
personId: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b', // Alexandre
|
||||
person: {
|
||||
__typename: 'Person',
|
||||
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b',
|
||||
name: {
|
||||
firstName: 'Alexandre',
|
||||
lastName: 'Test',
|
||||
},
|
||||
avatarUrl: '',
|
||||
},
|
||||
company: null,
|
||||
companyId: null,
|
||||
activityId: '89bb825c-171e-4bcc-9cf7-43448d6fb278a',
|
||||
activity: {
|
||||
__typename: 'Activity',
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278a',
|
||||
createdAt: '2023-04-26T10:12:42.33625+00:00',
|
||||
updatedAt: '2023-04-26T10:23:42.33625+00:00',
|
||||
},
|
||||
__typename: 'ActivityTarget',
|
||||
},
|
||||
{
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb279t',
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
personId: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6d', // Jean d'Eau
|
||||
companyId: null,
|
||||
targetObjectNameSingular: 'person',
|
||||
company: null,
|
||||
person: {
|
||||
__typename: 'Person',
|
||||
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6d',
|
||||
name: {
|
||||
firstName: 'Jean',
|
||||
lastName: "d'Eau",
|
||||
},
|
||||
avatarUrl: '',
|
||||
},
|
||||
activityId: '89bb825c-171e-4bcc-9cf7-43448d6fb278a',
|
||||
activity: {
|
||||
__typename: 'Activity',
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278a',
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
},
|
||||
__typename: 'ActivityTarget',
|
||||
},
|
||||
],
|
||||
__typename: 'Activity',
|
||||
},
|
||||
];
|
||||
|
||||
const meta: Meta<typeof TaskList> = {
|
||||
title: 'Modules/Activity/TaskList',
|
||||
|
@ -8,9 +8,9 @@ export type ActivityTarget = {
|
||||
updatedAt: string;
|
||||
companyId?: string | null;
|
||||
personId?: string | null;
|
||||
activity: Pick<Activity, 'id' | 'createdAt' | 'updatedAt'>;
|
||||
person?: Pick<Person, 'id' | 'name' | 'avatarUrl'> | null;
|
||||
company?: Pick<Company, 'id' | 'name' | 'domainName'> | null;
|
||||
activity: Pick<Activity, 'id' | 'createdAt' | 'updatedAt' | '__typename'>;
|
||||
person?: Pick<Person, 'id' | 'name' | 'avatarUrl' | '__typename'> | null;
|
||||
company?: Pick<Company, 'id' | 'name' | 'domainName' | '__typename'> | null;
|
||||
[key: string]: any;
|
||||
__typename: 'ActivityTarget';
|
||||
};
|
||||
|
@ -16,6 +16,7 @@ export const query = gql`
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
startCursor
|
||||
endCursor
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ const expectedQueryTemplate = `
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
startCursor
|
||||
endCursor
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ export const useRecordShowPagePagination = (
|
||||
|
||||
const setLastShowPageRecordId = useSetRecoilState(lastShowPageRecordIdState);
|
||||
|
||||
const [isLoadedRecords, setIsLoadedRecords] = useState(false);
|
||||
const [isLoadedRecords] = useState(false);
|
||||
|
||||
const objectNameSingular = propsObjectNameSingular || paramObjectNameSingular;
|
||||
const objectRecordId = propsObjectRecordId || paramObjectRecordId;
|
||||
|
Loading…
Reference in New Issue
Block a user