mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-27 11:03:40 +03:00
parent
1b2ed80c1c
commit
ccd1100773
@ -10,6 +10,7 @@ const calendarEvents: CalendarEvent[] = [
|
||||
isFullDay: false,
|
||||
startsAt: '2024-02-17T21:45:27.822Z',
|
||||
visibility: 'METADATA',
|
||||
__typename: 'CalendarEvent',
|
||||
},
|
||||
{
|
||||
id: '5678',
|
||||
@ -17,6 +18,7 @@ const calendarEvents: CalendarEvent[] = [
|
||||
isFullDay: false,
|
||||
startsAt: '2024-02-18T21:43:27.754Z',
|
||||
visibility: 'SHARE_EVERYTHING',
|
||||
__typename: 'CalendarEvent',
|
||||
},
|
||||
{
|
||||
id: '91011',
|
||||
@ -24,6 +26,7 @@ const calendarEvents: CalendarEvent[] = [
|
||||
isFullDay: true,
|
||||
startsAt: '2024-02-19T22:05:27.653Z',
|
||||
visibility: 'METADATA',
|
||||
__typename: 'CalendarEvent',
|
||||
},
|
||||
{
|
||||
id: '121314',
|
||||
@ -31,6 +34,7 @@ const calendarEvents: CalendarEvent[] = [
|
||||
isFullDay: true,
|
||||
startsAt: '2024-02-20T23:15:23.150Z',
|
||||
visibility: 'SHARE_EVERYTHING',
|
||||
__typename: 'CalendarEvent',
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -4,7 +4,13 @@ import { Comment } from '@/activities/types/Comment';
|
||||
|
||||
export const mockComment: Pick<
|
||||
Comment,
|
||||
'id' | 'author' | 'createdAt' | 'body' | 'updatedAt' | 'activityId'
|
||||
| 'id'
|
||||
| 'author'
|
||||
| 'createdAt'
|
||||
| 'body'
|
||||
| 'updatedAt'
|
||||
| 'activityId'
|
||||
| '__typename'
|
||||
> = {
|
||||
id: 'fake_comment_1_uuid',
|
||||
body: 'Hello, this is a comment.',
|
||||
@ -19,11 +25,18 @@ export const mockComment: Pick<
|
||||
createdAt: DateTime.fromFormat('2021-03-12', 'yyyy-MM-dd').toISO() ?? '',
|
||||
updatedAt: DateTime.fromFormat('2021-03-13', 'yyyy-MM-dd').toISO() ?? '',
|
||||
activityId: 'fake_activity_1_uuid',
|
||||
__typename: 'Comment',
|
||||
};
|
||||
|
||||
export const mockCommentWithLongValues: Pick<
|
||||
Comment,
|
||||
'id' | 'author' | 'createdAt' | 'body' | 'updatedAt' | 'activityId'
|
||||
| 'id'
|
||||
| 'author'
|
||||
| 'createdAt'
|
||||
| 'body'
|
||||
| 'updatedAt'
|
||||
| 'activityId'
|
||||
| '__typename'
|
||||
> = {
|
||||
id: 'fake_comment_2_uuid',
|
||||
body: 'Hello, this is a comment. Hello, this is a comment. Hello, this is a comment. Hello, this is a comment. Hello, this is a comment. Hello, this is a comment.',
|
||||
@ -38,4 +51,5 @@ export const mockCommentWithLongValues: Pick<
|
||||
createdAt: DateTime.fromFormat('2021-03-12', 'yyyy-MM-dd').toISO() ?? '',
|
||||
updatedAt: DateTime.fromFormat('2021-03-13', 'yyyy-MM-dd').toISO() ?? '',
|
||||
activityId: 'fake_activity_1_uuid',
|
||||
__typename: 'Comment',
|
||||
};
|
||||
|
@ -14,6 +14,7 @@ describe('useMapToObjectRecordIdentifier', () => {
|
||||
return mapToObjectRecordIdentifier({
|
||||
id: 'id',
|
||||
name: { firstName: 'Sheldon', lastName: 'Cooper' },
|
||||
__typename: 'Person',
|
||||
});
|
||||
},
|
||||
{
|
||||
|
@ -45,6 +45,7 @@ describe('useIsFieldEmpty', () => {
|
||||
result.current.setFieldState({
|
||||
id: 'id',
|
||||
phone: '+1 233223',
|
||||
__typename: 'Person',
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -19,6 +19,7 @@ const ChipFieldValueSetterEffect = () => {
|
||||
firstName: 'Henry',
|
||||
lastName: 'Cavill',
|
||||
},
|
||||
__typename: 'Person',
|
||||
});
|
||||
}, [setEntityFields]);
|
||||
|
||||
|
@ -22,7 +22,7 @@ const BooleanFieldValueSetterEffect = ({
|
||||
const setField = useSetRecoilState(recordStoreFamilyState(entityId));
|
||||
|
||||
useEffect(() => {
|
||||
setField({ id: entityId, Boolean: value });
|
||||
setField({ id: entityId, Boolean: value, __typename: 'Person' });
|
||||
}, [entityId, setField, value]);
|
||||
|
||||
return <></>;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { CurrencyFilter } from '@/object-record/record-filter/types/ObjectRecordQueryFilter';
|
||||
import { CurrencyFilter } from '@/object-record/graphql/types/RecordGqlOperationFilter';
|
||||
import { isMatchingCurrencyFilter } from '@/object-record/record-filter/utils/isMatchingCurrencyFilter';
|
||||
|
||||
describe('isMatchingCurrencyFilter', () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ObjectRecordQueryFilter } from '@/object-record/record-filter/types/ObjectRecordQueryFilter';
|
||||
import { RecordGqlOperationFilter } from '@/object-record/graphql/types/RecordGqlOperationFilter';
|
||||
import { mockedCompaniesData } from '~/testing/mock-data/companies';
|
||||
import { mockObjectMetadataItem } from '~/testing/mock-data/objectMetadataItems';
|
||||
|
||||
@ -161,7 +161,7 @@ describe('isRecordMatchingFilter', () => {
|
||||
|
||||
describe('Complex And/Or/Not Nesting', () => {
|
||||
it('matches record with a combination of and + or filters', () => {
|
||||
const filter: ObjectRecordQueryFilter = {
|
||||
const filter: RecordGqlOperationFilter = {
|
||||
and: [
|
||||
{ domainName: { eq: 'airbnb.com' } },
|
||||
{
|
||||
@ -191,7 +191,7 @@ describe('isRecordMatchingFilter', () => {
|
||||
});
|
||||
|
||||
it('matches record with nested not filter', () => {
|
||||
const filter: ObjectRecordQueryFilter = {
|
||||
const filter: RecordGqlOperationFilter = {
|
||||
not: {
|
||||
and: [
|
||||
{ name: { eq: 'Airbnb' } },
|
||||
@ -218,7 +218,7 @@ describe('isRecordMatchingFilter', () => {
|
||||
});
|
||||
|
||||
it('matches record with deep nesting of and, or, and not filters', () => {
|
||||
const filter: ObjectRecordQueryFilter = {
|
||||
const filter: RecordGqlOperationFilter = {
|
||||
and: [
|
||||
{ domainName: { eq: 'apple.com' } },
|
||||
{
|
||||
@ -245,7 +245,7 @@ describe('isRecordMatchingFilter', () => {
|
||||
});
|
||||
|
||||
it('matches record with and filter at root level', () => {
|
||||
const filter: ObjectRecordQueryFilter = {
|
||||
const filter: RecordGqlOperationFilter = {
|
||||
and: [
|
||||
{ name: { eq: 'Facebook' } },
|
||||
{ idealCustomerProfile: { eq: true } },
|
||||
@ -270,7 +270,7 @@ describe('isRecordMatchingFilter', () => {
|
||||
});
|
||||
|
||||
it('matches record with or filter at root level including a not condition', () => {
|
||||
const filter: ObjectRecordQueryFilter = {
|
||||
const filter: RecordGqlOperationFilter = {
|
||||
or: [{ name: { eq: 'Sequoia' } }, { not: { employees: { eq: 1 } } }],
|
||||
};
|
||||
|
||||
|
@ -19,7 +19,7 @@ const entities = mockedPeopleData.map<EntityForSelect>((person) => ({
|
||||
name: person.name.firstName + ' ' + person.name.lastName,
|
||||
avatarUrl: person.avatarUrl,
|
||||
avatarType: 'rounded',
|
||||
record: person,
|
||||
record: { ...person, __typename: 'Person' },
|
||||
}));
|
||||
|
||||
const meta: Meta<typeof SingleEntitySelect> = {
|
||||
|
@ -36,8 +36,10 @@ describe('useMultiObjectRecordsQueryResultFormattedAsObjectRecordForSelectArray'
|
||||
'e992bda7-d797-4e12-af04-9b427f42244c',
|
||||
updatedAt: '2023-11-30T11:13:15.308Z',
|
||||
createdAt: '2023-11-30T11:13:15.308Z',
|
||||
__typename: 'Opportunity',
|
||||
},
|
||||
cursor: 'cursor',
|
||||
__typename: 'OpportunityEdge',
|
||||
},
|
||||
],
|
||||
pageInfo: {},
|
||||
@ -49,8 +51,10 @@ describe('useMultiObjectRecordsQueryResultFormattedAsObjectRecordForSelectArray'
|
||||
id: personId,
|
||||
updatedAt: '2023-11-30T11:13:15.308Z',
|
||||
createdAt: '2023-11-30T11:13:15.308Z',
|
||||
__typename: 'Person',
|
||||
},
|
||||
cursor: 'cursor',
|
||||
__typename: 'PersonEdge',
|
||||
},
|
||||
],
|
||||
pageInfo: {},
|
||||
|
@ -3,10 +3,18 @@ import { OrderBy } from '@/object-metadata/types/OrderBy';
|
||||
import { sortObjectRecordByDateField } from './sortObjectRecordByDateField';
|
||||
|
||||
describe('sortByObjectRecordByCreatedAt', () => {
|
||||
const recordOldest = { id: '', createdAt: '2022-01-01T00:00:00.000Z' };
|
||||
const recordNewest = { id: '', createdAt: '2022-01-02T00:00:00.000Z' };
|
||||
const recordNull1 = { id: '', createdAt: null };
|
||||
const recordNull2 = { id: '', createdAt: null };
|
||||
const recordOldest = {
|
||||
id: '',
|
||||
createdAt: '2022-01-01T00:00:00.000Z',
|
||||
__typename: 'RecordType',
|
||||
};
|
||||
const recordNewest = {
|
||||
id: '',
|
||||
createdAt: '2022-01-02T00:00:00.000Z',
|
||||
__typename: 'RecordType',
|
||||
};
|
||||
const recordNull1 = { id: '', createdAt: null, __typename: 'RecordType' };
|
||||
const recordNull2 = { id: '', createdAt: null, __typename: 'RecordType' };
|
||||
|
||||
it('should sort in ascending order with null values first', () => {
|
||||
const sortDirection = 'AscNullsFirst' satisfies OrderBy;
|
||||
|
@ -20,6 +20,7 @@ const meta: Meta<typeof SettingsAccountsEmailsBlocklistInput> = {
|
||||
decorators: [ComponentDecorator, ClearMocksDecorator],
|
||||
args: {
|
||||
updateBlockedEmailList: updateBlockedEmailListJestFn,
|
||||
blockedEmailOrDomainList: [],
|
||||
},
|
||||
argTypes: {
|
||||
updateBlockedEmailList: { control: false },
|
||||
|
@ -1,28 +1,34 @@
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
export const mockedBlocklist = [
|
||||
import { BlocklistItem } from '@/accounts/types/BlocklistItem';
|
||||
|
||||
export const mockedBlocklist: BlocklistItem[] = [
|
||||
{
|
||||
id: '1',
|
||||
handle: 'test1@twenty.com',
|
||||
workspaceMemberId: '1',
|
||||
createdAt: DateTime.now().minus({ hours: 2 }).toISO() ?? '',
|
||||
__typename: 'BlocklistItem',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
handle: 'test2@twenty.com',
|
||||
workspaceMemberId: '1',
|
||||
createdAt: DateTime.now().minus({ days: 2 }).toISO() ?? '',
|
||||
__typename: 'BlocklistItem',
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
handle: 'test3@twenty.com',
|
||||
workspaceMemberId: '1',
|
||||
createdAt: DateTime.now().minus({ days: 3 }).toISO() ?? '',
|
||||
__typename: 'BlocklistItem',
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
handle: '@twenty.com',
|
||||
workspaceMemberId: '1',
|
||||
createdAt: DateTime.now().minus({ days: 4 }).toISO() ?? '',
|
||||
__typename: 'BlocklistItem',
|
||||
},
|
||||
];
|
||||
|
@ -12,7 +12,11 @@ describe('getFieldPreviewValueFromRecord', () => {
|
||||
describe('SELECT field', () => {
|
||||
it('returns the select option corresponding to the record field value', () => {
|
||||
// Given
|
||||
const record: ObjectRecord = { id: '', stage: 'MEETING' };
|
||||
const record: ObjectRecord = {
|
||||
id: '',
|
||||
stage: 'MEETING',
|
||||
__typename: 'Opportunity',
|
||||
};
|
||||
const fieldMetadataItem = mockedOpportunityObjectMetadataItem.fields.find(
|
||||
({ name }) => name === 'stage',
|
||||
)!;
|
||||
@ -32,7 +36,11 @@ describe('getFieldPreviewValueFromRecord', () => {
|
||||
|
||||
it('returns undefined if the select option was not found', () => {
|
||||
// Given
|
||||
const record: ObjectRecord = { id: '', industry: 'DOES_NOT_EXIST' };
|
||||
const record: ObjectRecord = {
|
||||
id: '',
|
||||
industry: 'DOES_NOT_EXIST',
|
||||
__typename: 'Opportunity',
|
||||
};
|
||||
const fieldMetadataItem = mockedOpportunityObjectMetadataItem.fields.find(
|
||||
({ name }) => name === 'stage',
|
||||
)!;
|
||||
@ -63,6 +71,7 @@ describe('getFieldPreviewValueFromRecord', () => {
|
||||
people: {
|
||||
edges: [{ node: firstRelationRecord }, { node: { id: '2' } }],
|
||||
},
|
||||
__typename: 'Opportunity',
|
||||
};
|
||||
const fieldMetadataItem = mockedCompanyObjectMetadataItem.fields.find(
|
||||
({ name }) => name === 'people',
|
||||
@ -81,7 +90,11 @@ describe('getFieldPreviewValueFromRecord', () => {
|
||||
it('returns the record field value ("to one" relation)', () => {
|
||||
// Given
|
||||
const relationRecord = { id: '20', name: 'Twenty' };
|
||||
const record = { id: '', company: relationRecord };
|
||||
const record = {
|
||||
id: '',
|
||||
company: relationRecord,
|
||||
__typename: 'Opportunity',
|
||||
};
|
||||
const fieldMetadataItem = mockedPersonObjectMetadataItem.fields.find(
|
||||
({ name }) => name === 'company',
|
||||
)!;
|
||||
@ -100,7 +113,7 @@ describe('getFieldPreviewValueFromRecord', () => {
|
||||
describe('Other fields', () => {
|
||||
it('returns the record field value', () => {
|
||||
// Given
|
||||
const record = { id: '', name: 'Twenty' };
|
||||
const record = { id: '', name: 'Twenty', __typename: 'Opportunity' };
|
||||
const fieldMetadataItem = mockedCompanyObjectMetadataItem.fields.find(
|
||||
({ name }) => name === 'name',
|
||||
)!;
|
||||
|
Loading…
Reference in New Issue
Block a user