+2
-3
@@ -1,11 +1,10 @@
|
||||
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
|
||||
import { getPeopleRecordConnectionMock } from '~/testing/mock-data/people';
|
||||
|
||||
import { mockedPersonRecords } from '~/testing/mock-data/generated/data/people/mock-people-data';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
import { getRecordNodeFromRecord } from '@/object-record/cache/utils/getRecordNodeFromRecord';
|
||||
|
||||
const peopleMock = getPeopleRecordConnectionMock();
|
||||
const peopleMock = [...mockedPersonRecords];
|
||||
|
||||
describe('getRecordNodeFromRecord', () => {
|
||||
it('computes relation records cache references by default', () => {
|
||||
|
||||
+10
-3
@@ -1,6 +1,7 @@
|
||||
import { getRecordFromRecordNode } from '@/object-record/cache/utils/getRecordFromRecordNode';
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { gql } from '@apollo/client';
|
||||
import { getMockPersonRecord } from '~/testing/mock-data/people';
|
||||
import { mockedPersonRecords } from '~/testing/mock-data/generated/data/people/mock-people-data';
|
||||
|
||||
export const query = gql`
|
||||
mutation DeleteManyPeople($filter: PersonFilterInput!) {
|
||||
@@ -16,10 +17,16 @@ export const personIds = [
|
||||
'37faabcd-cb39-4a0a-8618-7e3fda9afca0',
|
||||
];
|
||||
|
||||
export const personRecords = personIds.map<ObjectRecord>((personId, index) =>
|
||||
getMockPersonRecord({ id: personId, deletedAt: null }, index),
|
||||
const flatPersonRecords = mockedPersonRecords.map((record) =>
|
||||
getRecordFromRecordNode({ recordNode: record }),
|
||||
);
|
||||
|
||||
export const personRecords = personIds.map<ObjectRecord>((personId, index) => ({
|
||||
...flatPersonRecords[index],
|
||||
id: personId,
|
||||
deletedAt: null,
|
||||
}));
|
||||
|
||||
export const variables = {
|
||||
filter: {
|
||||
id: {
|
||||
|
||||
+16
-5
@@ -1,7 +1,9 @@
|
||||
import { RecordGqlConnectionEdgesRequired } from '@/object-record/graphql/types/RecordGqlConnectionEdgesRequired';
|
||||
import { type RecordGqlConnectionEdgesRequired } from '@/object-record/graphql/types/RecordGqlConnectionEdgesRequired';
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
import { peopleQueryResult } from '~/testing/mock-data/people';
|
||||
import { getRecordFromRecordNode } from '@/object-record/cache/utils/getRecordFromRecordNode';
|
||||
import { mockedPersonRecords } from '~/testing/mock-data/generated/data/people/mock-people-data';
|
||||
import { generateMockRecordConnection } from '~/testing/utils/generateMockRecordConnection';
|
||||
|
||||
export const query = gql`
|
||||
query FindManyPeople(
|
||||
@@ -36,11 +38,20 @@ export const query = gql`
|
||||
|
||||
export const mockPageSize = 2;
|
||||
|
||||
const flatPersonRecords = mockedPersonRecords.map((record) =>
|
||||
getRecordFromRecordNode({ recordNode: record }),
|
||||
);
|
||||
|
||||
const baseConnection = generateMockRecordConnection({
|
||||
objectNameSingular: 'person',
|
||||
records: flatPersonRecords,
|
||||
});
|
||||
|
||||
export const peopleMockWithIdsOnly: RecordGqlConnectionEdgesRequired = {
|
||||
...peopleQueryResult.people,
|
||||
edges: peopleQueryResult.people.edges.map((edge) => ({
|
||||
...baseConnection,
|
||||
edges: baseConnection.edges.map((edge, index) => ({
|
||||
...edge,
|
||||
node: { __typename: 'Person', id: edge.node.id },
|
||||
cursor: `cursor-${index}`,
|
||||
})),
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import { PERSON_FRAGMENT_WITH_DEPTH_ZERO_RELATIONS } from '@/object-record/hooks/__mocks__/personFragments';
|
||||
import { gql } from '@apollo/client';
|
||||
import { getPeopleRecordConnectionMock } from '~/testing/mock-data/people';
|
||||
import { mockedPersonRecords } from '~/testing/mock-data/generated/data/people/mock-people-data';
|
||||
|
||||
const peopleMock = getPeopleRecordConnectionMock();
|
||||
const peopleMock = [...mockedPersonRecords];
|
||||
|
||||
export const query = gql`
|
||||
query FindDuplicatePerson($ids: [UUID!]!) {
|
||||
|
||||
+14
-5
@@ -1,6 +1,7 @@
|
||||
import { getRecordFromRecordNode } from '@/object-record/cache/utils/getRecordFromRecordNode';
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { gql } from '@apollo/client';
|
||||
import { getMockPersonRecord } from '~/testing/mock-data/people';
|
||||
import { mockedPersonRecords } from '~/testing/mock-data/generated/data/people/mock-people-data';
|
||||
|
||||
export const query = gql`
|
||||
mutation UpdateManyPeople(
|
||||
@@ -19,10 +20,15 @@ export const personIds = [
|
||||
'37faabcd-cb39-4a0a-8618-7e3fda9afca0',
|
||||
];
|
||||
|
||||
export const personRecords = personIds.map<ObjectRecord>((personId, index) =>
|
||||
getMockPersonRecord({ id: personId }, index),
|
||||
const flatPersonRecords = mockedPersonRecords.map((record) =>
|
||||
getRecordFromRecordNode({ recordNode: record }),
|
||||
);
|
||||
|
||||
export const personRecords = personIds.map<ObjectRecord>((personId, index) => ({
|
||||
...flatPersonRecords[index],
|
||||
id: personId,
|
||||
}));
|
||||
|
||||
export const updateInput = {
|
||||
city: 'Updated City',
|
||||
};
|
||||
@@ -37,8 +43,11 @@ export const variables = {
|
||||
};
|
||||
|
||||
export const updatedPersonRecords = personIds.map<ObjectRecord>(
|
||||
(personId, index) =>
|
||||
getMockPersonRecord({ id: personId, city: 'Updated City' }, index),
|
||||
(personId, index) => ({
|
||||
...flatPersonRecords[index],
|
||||
id: personId,
|
||||
city: 'Updated City',
|
||||
}),
|
||||
);
|
||||
|
||||
export const responseData = personIds.map((personId) => ({ id: personId }));
|
||||
|
||||
+169
-160
@@ -4,71 +4,91 @@ exports[`useDeleteOneRecord A. Starting from empty cache 1. Should successfully
|
||||
{
|
||||
"__typename": "Person",
|
||||
"deletedAt": "2024-02-14T09:45:00Z",
|
||||
"id": "da3c2c4b-da01-4b81-9734-226069eb4cd0",
|
||||
"id": "20202020-b000-4485-94de-70c2a98daef2",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle successfull record deletion 1`] = `
|
||||
{
|
||||
"__typename": "Person",
|
||||
"avatarUrl": null,
|
||||
"city": "ASd",
|
||||
"company": {
|
||||
"__typename": "Company",
|
||||
"domainName": {
|
||||
"__typename": "Links",
|
||||
"primaryLinkLabel": "",
|
||||
"primaryLinkUrl": "https://linkedin.com",
|
||||
"secondaryLinks": [],
|
||||
},
|
||||
"id": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
|
||||
"name": "Linkedin",
|
||||
},
|
||||
"createdAt": "2025-01-02T09:52:46.814Z",
|
||||
"attachments": [],
|
||||
"avatarFile": null,
|
||||
"avatarUrl": "https://twentyhq.github.io/placeholder-images/people/image-88.png",
|
||||
"calendarEventParticipants": [],
|
||||
"caredForPets": [],
|
||||
"city": "New Jennifer",
|
||||
"company": {},
|
||||
"companyId": "20202020-aa0b-48a9-85ba-e223975696ea",
|
||||
"createdAt": "2026-02-27T01:17:29.464Z",
|
||||
"createdBy": {
|
||||
"__typename": "Actor",
|
||||
"context": null,
|
||||
"name": "Tim Apple",
|
||||
"source": "MANUAL",
|
||||
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
||||
"name": "Jony Ive",
|
||||
"source": "WEBHOOK",
|
||||
"workspaceMemberId": "20202020-77d5-4cb6-b60a-f4a835a85d61",
|
||||
},
|
||||
"deletedAt": "2024-02-14T09:45:00Z",
|
||||
"emails": {
|
||||
"__typename": "Emails",
|
||||
"additionalEmails": [],
|
||||
"primaryEmail": "asd.com",
|
||||
"primaryEmail": "jeffery.griffin@example.com",
|
||||
},
|
||||
"id": "da3c2c4b-da01-4b81-9734-226069eb4cd0",
|
||||
"favorites": [],
|
||||
"id": "20202020-b000-4485-94de-70c2a98daef2",
|
||||
"intro": "",
|
||||
"jobTitle": "",
|
||||
"jobTitle": "Embryologist, clinical",
|
||||
"linkedinLink": {
|
||||
"__typename": "Links",
|
||||
"primaryLinkLabel": "",
|
||||
"primaryLinkUrl": "",
|
||||
"primaryLinkUrl": "https://linkedin.com/in/person-442",
|
||||
"secondaryLinks": [],
|
||||
},
|
||||
"messageParticipants": [
|
||||
{},
|
||||
],
|
||||
"name": {
|
||||
"__typename": "FullName",
|
||||
"firstName": "Test",
|
||||
"lastName": "Test",
|
||||
"firstName": "Jeffery",
|
||||
"lastName": "Griffin",
|
||||
},
|
||||
"noteTargets": [],
|
||||
"noteTargets": [
|
||||
{},
|
||||
],
|
||||
"performanceRating": null,
|
||||
"phones": {
|
||||
"__typename": "Phones",
|
||||
"additionalPhones": [],
|
||||
"primaryPhoneCallingCode": "+49",
|
||||
"primaryPhoneCountryCode": "DE",
|
||||
"primaryPhoneNumber": "7114567890",
|
||||
},
|
||||
"pointOfContactForOpportunities": [],
|
||||
"position": 442,
|
||||
"previousCompanies": [],
|
||||
"taskTargets": [
|
||||
{},
|
||||
],
|
||||
"timelineActivities": [
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
],
|
||||
"updatedAt": "2026-02-27T01:17:29.464Z",
|
||||
"updatedBy": {
|
||||
"__typename": "Actor",
|
||||
"context": null,
|
||||
"name": "Jony Ive",
|
||||
"source": "WEBHOOK",
|
||||
"workspaceMemberId": "20202020-77d5-4cb6-b60a-f4a835a85d61",
|
||||
},
|
||||
"whatsapp": {
|
||||
"__typename": "Phones",
|
||||
"additionalPhones": [],
|
||||
"primaryPhoneCallingCode": "+33",
|
||||
"primaryPhoneCountryCode": "FR",
|
||||
"primaryPhoneNumber": "781234562",
|
||||
},
|
||||
"position": 0,
|
||||
"taskTargets": [],
|
||||
"updatedAt": "2025-01-02T09:52:46.814Z",
|
||||
"whatsapp": {
|
||||
"additionalPhones": [],
|
||||
"primaryPhoneCallingCode": "",
|
||||
"primaryPhoneCountryCode": "",
|
||||
"primaryPhoneNumber": "",
|
||||
},
|
||||
"workPreference": null,
|
||||
"workPreference": [],
|
||||
"xLink": {
|
||||
"__typename": "Links",
|
||||
"primaryLinkLabel": "",
|
||||
@@ -122,25 +142,8 @@ exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle succe
|
||||
{},
|
||||
],
|
||||
"people": [
|
||||
{
|
||||
"__typename": "Person",
|
||||
"avatarUrl": null,
|
||||
"id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
|
||||
"name": {
|
||||
"__typename": "FullName",
|
||||
"firstName": "Christoph",
|
||||
"lastName": "Callisto",
|
||||
},
|
||||
},
|
||||
{
|
||||
"__typename": "Person",
|
||||
"id": "20202020-ac73-4797-824e-87a1f5aea9e0",
|
||||
"name": {
|
||||
"__typename": "FullName",
|
||||
"firstName": "Sylvie",
|
||||
"lastName": "Palmer",
|
||||
},
|
||||
},
|
||||
{},
|
||||
{},
|
||||
],
|
||||
"position": 1,
|
||||
"taskTargets": [],
|
||||
@@ -150,64 +153,84 @@ 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`] = `
|
||||
{
|
||||
"__typename": "Person",
|
||||
"avatarUrl": null,
|
||||
"city": "ASd",
|
||||
"company": {
|
||||
"__typename": "Company",
|
||||
"domainName": {
|
||||
"__typename": "Links",
|
||||
"primaryLinkLabel": "",
|
||||
"primaryLinkUrl": "https://linkedin.com",
|
||||
"secondaryLinks": [],
|
||||
},
|
||||
"id": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
|
||||
"name": "Linkedin",
|
||||
},
|
||||
"createdAt": "2025-01-02T09:52:46.814Z",
|
||||
"attachments": [],
|
||||
"avatarFile": null,
|
||||
"avatarUrl": "https://twentyhq.github.io/placeholder-images/people/image-88.png",
|
||||
"calendarEventParticipants": [],
|
||||
"caredForPets": [],
|
||||
"city": "New Jennifer",
|
||||
"company": {},
|
||||
"companyId": "20202020-aa0b-48a9-85ba-e223975696ea",
|
||||
"createdAt": "2026-02-27T01:17:29.464Z",
|
||||
"createdBy": {
|
||||
"__typename": "Actor",
|
||||
"context": null,
|
||||
"name": "Tim Apple",
|
||||
"source": "MANUAL",
|
||||
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
||||
"name": "Jony Ive",
|
||||
"source": "WEBHOOK",
|
||||
"workspaceMemberId": "20202020-77d5-4cb6-b60a-f4a835a85d61",
|
||||
},
|
||||
"deletedAt": Any<String>,
|
||||
"emails": {
|
||||
"__typename": "Emails",
|
||||
"additionalEmails": [],
|
||||
"primaryEmail": "asd.com",
|
||||
"primaryEmail": "jeffery.griffin@example.com",
|
||||
},
|
||||
"id": "da3c2c4b-da01-4b81-9734-226069eb4cd0",
|
||||
"favorites": [],
|
||||
"id": "20202020-b000-4485-94de-70c2a98daef2",
|
||||
"intro": "",
|
||||
"jobTitle": "",
|
||||
"jobTitle": "Embryologist, clinical",
|
||||
"linkedinLink": {
|
||||
"__typename": "Links",
|
||||
"primaryLinkLabel": "",
|
||||
"primaryLinkUrl": "",
|
||||
"primaryLinkUrl": "https://linkedin.com/in/person-442",
|
||||
"secondaryLinks": [],
|
||||
},
|
||||
"messageParticipants": [
|
||||
{},
|
||||
],
|
||||
"name": {
|
||||
"__typename": "FullName",
|
||||
"firstName": "Test",
|
||||
"lastName": "Test",
|
||||
"firstName": "Jeffery",
|
||||
"lastName": "Griffin",
|
||||
},
|
||||
"noteTargets": [],
|
||||
"noteTargets": [
|
||||
{},
|
||||
],
|
||||
"performanceRating": null,
|
||||
"phones": {
|
||||
"__typename": "Phones",
|
||||
"additionalPhones": [],
|
||||
"primaryPhoneCallingCode": "+49",
|
||||
"primaryPhoneCountryCode": "DE",
|
||||
"primaryPhoneNumber": "7114567890",
|
||||
},
|
||||
"pointOfContactForOpportunities": [],
|
||||
"position": 442,
|
||||
"previousCompanies": [],
|
||||
"taskTargets": [
|
||||
{},
|
||||
],
|
||||
"timelineActivities": [
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
],
|
||||
"updatedAt": "2026-02-27T01:17:29.464Z",
|
||||
"updatedBy": {
|
||||
"__typename": "Actor",
|
||||
"context": null,
|
||||
"name": "Jony Ive",
|
||||
"source": "WEBHOOK",
|
||||
"workspaceMemberId": "20202020-77d5-4cb6-b60a-f4a835a85d61",
|
||||
},
|
||||
"whatsapp": {
|
||||
"__typename": "Phones",
|
||||
"additionalPhones": [],
|
||||
"primaryPhoneCallingCode": "+33",
|
||||
"primaryPhoneCountryCode": "FR",
|
||||
"primaryPhoneNumber": "781234562",
|
||||
},
|
||||
"position": 0,
|
||||
"taskTargets": [],
|
||||
"updatedAt": "2025-01-02T09:52:46.814Z",
|
||||
"whatsapp": {
|
||||
"additionalPhones": [],
|
||||
"primaryPhoneCallingCode": "",
|
||||
"primaryPhoneCountryCode": "",
|
||||
"primaryPhoneNumber": "",
|
||||
},
|
||||
"workPreference": null,
|
||||
"workPreference": [],
|
||||
"xLink": {
|
||||
"__typename": "Links",
|
||||
"primaryLinkLabel": "",
|
||||
@@ -261,25 +284,8 @@ exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optim
|
||||
{},
|
||||
],
|
||||
"people": [
|
||||
{
|
||||
"__typename": "Person",
|
||||
"avatarUrl": null,
|
||||
"id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
|
||||
"name": {
|
||||
"__typename": "FullName",
|
||||
"firstName": "Christoph",
|
||||
"lastName": "Callisto",
|
||||
},
|
||||
},
|
||||
{
|
||||
"__typename": "Person",
|
||||
"id": "20202020-ac73-4797-824e-87a1f5aea9e0",
|
||||
"name": {
|
||||
"__typename": "FullName",
|
||||
"firstName": "Sylvie",
|
||||
"lastName": "Palmer",
|
||||
},
|
||||
},
|
||||
{},
|
||||
{},
|
||||
],
|
||||
"position": 1,
|
||||
"taskTargets": [],
|
||||
@@ -289,64 +295,84 @@ 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`] = `
|
||||
{
|
||||
"__typename": "Person",
|
||||
"avatarUrl": null,
|
||||
"city": "ASd",
|
||||
"company": {
|
||||
"__typename": "Company",
|
||||
"domainName": {
|
||||
"__typename": "Links",
|
||||
"primaryLinkLabel": "",
|
||||
"primaryLinkUrl": "https://linkedin.com",
|
||||
"secondaryLinks": [],
|
||||
},
|
||||
"id": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
|
||||
"name": "Linkedin",
|
||||
},
|
||||
"createdAt": "2025-01-02T09:52:46.814Z",
|
||||
"attachments": [],
|
||||
"avatarFile": null,
|
||||
"avatarUrl": "https://twentyhq.github.io/placeholder-images/people/image-88.png",
|
||||
"calendarEventParticipants": [],
|
||||
"caredForPets": [],
|
||||
"city": "New Jennifer",
|
||||
"company": {},
|
||||
"companyId": "20202020-aa0b-48a9-85ba-e223975696ea",
|
||||
"createdAt": "2026-02-27T01:17:29.464Z",
|
||||
"createdBy": {
|
||||
"__typename": "Actor",
|
||||
"context": null,
|
||||
"name": "Tim Apple",
|
||||
"source": "MANUAL",
|
||||
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
|
||||
"name": "Jony Ive",
|
||||
"source": "WEBHOOK",
|
||||
"workspaceMemberId": "20202020-77d5-4cb6-b60a-f4a835a85d61",
|
||||
},
|
||||
"deletedAt": null,
|
||||
"emails": {
|
||||
"__typename": "Emails",
|
||||
"additionalEmails": [],
|
||||
"primaryEmail": "asd.com",
|
||||
"primaryEmail": "jeffery.griffin@example.com",
|
||||
},
|
||||
"id": "da3c2c4b-da01-4b81-9734-226069eb4cd0",
|
||||
"favorites": [],
|
||||
"id": "20202020-b000-4485-94de-70c2a98daef2",
|
||||
"intro": "",
|
||||
"jobTitle": "",
|
||||
"jobTitle": "Embryologist, clinical",
|
||||
"linkedinLink": {
|
||||
"__typename": "Links",
|
||||
"primaryLinkLabel": "",
|
||||
"primaryLinkUrl": "",
|
||||
"primaryLinkUrl": "https://linkedin.com/in/person-442",
|
||||
"secondaryLinks": [],
|
||||
},
|
||||
"messageParticipants": [
|
||||
{},
|
||||
],
|
||||
"name": {
|
||||
"__typename": "FullName",
|
||||
"firstName": "Test",
|
||||
"lastName": "Test",
|
||||
"firstName": "Jeffery",
|
||||
"lastName": "Griffin",
|
||||
},
|
||||
"noteTargets": [],
|
||||
"noteTargets": [
|
||||
{},
|
||||
],
|
||||
"performanceRating": null,
|
||||
"phones": {
|
||||
"__typename": "Phones",
|
||||
"additionalPhones": [],
|
||||
"primaryPhoneCallingCode": "+49",
|
||||
"primaryPhoneCountryCode": "DE",
|
||||
"primaryPhoneNumber": "7114567890",
|
||||
},
|
||||
"pointOfContactForOpportunities": [],
|
||||
"position": 442,
|
||||
"previousCompanies": [],
|
||||
"taskTargets": [
|
||||
{},
|
||||
],
|
||||
"timelineActivities": [
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
],
|
||||
"updatedAt": "2026-02-27T01:17:29.464Z",
|
||||
"updatedBy": {
|
||||
"__typename": "Actor",
|
||||
"context": null,
|
||||
"name": "Jony Ive",
|
||||
"source": "WEBHOOK",
|
||||
"workspaceMemberId": "20202020-77d5-4cb6-b60a-f4a835a85d61",
|
||||
},
|
||||
"whatsapp": {
|
||||
"__typename": "Phones",
|
||||
"additionalPhones": [],
|
||||
"primaryPhoneCallingCode": "+33",
|
||||
"primaryPhoneCountryCode": "FR",
|
||||
"primaryPhoneNumber": "781234562",
|
||||
},
|
||||
"position": 0,
|
||||
"taskTargets": [],
|
||||
"updatedAt": "2025-01-02T09:52:46.814Z",
|
||||
"whatsapp": {
|
||||
"additionalPhones": [],
|
||||
"primaryPhoneCallingCode": "",
|
||||
"primaryPhoneCountryCode": "",
|
||||
"primaryPhoneNumber": "",
|
||||
},
|
||||
"workPreference": null,
|
||||
"workPreference": [],
|
||||
"xLink": {
|
||||
"__typename": "Links",
|
||||
"primaryLinkLabel": "",
|
||||
@@ -400,25 +426,8 @@ exports[`useDeleteOneRecord B. Starting from filled cache 3. Should handle optim
|
||||
{},
|
||||
],
|
||||
"people": [
|
||||
{
|
||||
"__typename": "Person",
|
||||
"avatarUrl": null,
|
||||
"id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
|
||||
"name": {
|
||||
"__typename": "FullName",
|
||||
"firstName": "Christoph",
|
||||
"lastName": "Callisto",
|
||||
},
|
||||
},
|
||||
{
|
||||
"__typename": "Person",
|
||||
"id": "20202020-ac73-4797-824e-87a1f5aea9e0",
|
||||
"name": {
|
||||
"__typename": "FullName",
|
||||
"firstName": "Sylvie",
|
||||
"lastName": "Palmer",
|
||||
},
|
||||
},
|
||||
{},
|
||||
{},
|
||||
],
|
||||
"position": 1,
|
||||
"taskTargets": [],
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@ import { InMemoryCache } from '@apollo/client';
|
||||
import { type MockedResponse } from '@apollo/client/testing';
|
||||
import { act } from 'react';
|
||||
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
|
||||
import { getMockPersonObjectMetadataItem } from '~/testing/mock-data/people';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
|
||||
|
||||
const getDefaultMocks = (
|
||||
overrides?: Partial<MockedResponse>,
|
||||
@@ -42,7 +42,7 @@ const mockRefetchAggregateQueries = jest.fn();
|
||||
(useRefetchAggregateQueries as jest.Mock).mockReturnValue({
|
||||
refetchAggregateQueries: mockRefetchAggregateQueries,
|
||||
});
|
||||
const objectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const objectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
const objectMetadataItems = generatedMockObjectMetadataItems;
|
||||
const expectedCachedRecordsWithDeletedAt = personRecords.map(
|
||||
(personRecord) => ({
|
||||
|
||||
+18
-18
@@ -8,17 +8,11 @@ import { type MockedResponse } from '@apollo/client/testing';
|
||||
|
||||
import { InMemoryTestingCacheInstance } from '~/testing/cache/inMemoryTestingCacheInstance';
|
||||
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
|
||||
import { getMockCompanyObjectMetadataItem } from '~/testing/mock-data/companies';
|
||||
import {
|
||||
allMockCompanyRecordsWithRelation,
|
||||
findMockCompanyWithRelationRecord,
|
||||
} from '~/testing/mock-data/companiesWithRelations';
|
||||
import {
|
||||
allMockPersonRecords,
|
||||
getMockPersonObjectMetadataItem,
|
||||
getMockPersonRecord,
|
||||
} from '~/testing/mock-data/people';
|
||||
import { getRecordFromRecordNode } from '@/object-record/cache/utils/getRecordFromRecordNode';
|
||||
import { allMockCompanyRecordsWithRelation } from '~/testing/mock-data/companiesWithRelations';
|
||||
import { mockedPersonRecords } from '~/testing/mock-data/generated/data/people/mock-people-data';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
|
||||
|
||||
jest.mock('@/object-record/hooks/useRefetchAggregateQueries');
|
||||
const mockRefetchAggregateQueries = jest.fn();
|
||||
@@ -26,15 +20,21 @@ const mockRefetchAggregateQueries = jest.fn();
|
||||
refetchAggregateQueries: mockRefetchAggregateQueries,
|
||||
});
|
||||
|
||||
const flatPersonRecords = mockedPersonRecords.map((record) =>
|
||||
getRecordFromRecordNode({ recordNode: record }),
|
||||
);
|
||||
|
||||
describe('useDeleteOneRecord', () => {
|
||||
const personRecord = getMockPersonRecord({
|
||||
const matchingCompanyId = allMockCompanyRecordsWithRelation[0].id;
|
||||
const personRecord = {
|
||||
...flatPersonRecords[0],
|
||||
deletedAt: null,
|
||||
});
|
||||
const relatedCompanyRecord = findMockCompanyWithRelationRecord({
|
||||
id: personRecord.company.id,
|
||||
});
|
||||
const personObjectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const companyObjectMetadataItem = getMockCompanyObjectMetadataItem();
|
||||
companyId: matchingCompanyId,
|
||||
company: { ...allMockCompanyRecordsWithRelation[0] },
|
||||
};
|
||||
const relatedCompanyRecord = allMockCompanyRecordsWithRelation[0];
|
||||
const personObjectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
const companyObjectMetadataItem = getMockObjectMetadataItemOrThrow('company');
|
||||
const objectMetadataItems = generatedMockObjectMetadataItems;
|
||||
|
||||
const getDefaultMocks = (
|
||||
@@ -203,7 +203,7 @@ describe('useDeleteOneRecord', () => {
|
||||
},
|
||||
{
|
||||
objectMetadataItem: personObjectMetadataItem,
|
||||
records: allMockPersonRecords,
|
||||
records: flatPersonRecords,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
+14
-14
@@ -11,16 +11,20 @@ import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewCompon
|
||||
import { type MockedResponse } from '@apollo/client/testing';
|
||||
import gql from 'graphql-tag';
|
||||
import { QUERY_DEFAULT_LIMIT_RECORDS } from 'twenty-shared/constants';
|
||||
import { getRecordFromRecordNode } from '@/object-record/cache/utils/getRecordFromRecordNode';
|
||||
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
|
||||
import { JestRecordIndexContextProviderWrapper } from '~/testing/jest/JestRecordIndexContextProviderWrapper';
|
||||
import {
|
||||
getMockPersonObjectMetadataItem,
|
||||
peopleQueryResult,
|
||||
} from '~/testing/mock-data/people';
|
||||
import { mockedPersonRecords } from '~/testing/mock-data/generated/data/people/mock-people-data';
|
||||
import { generateMockRecordConnection } from '~/testing/utils/generateMockRecordConnection';
|
||||
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
|
||||
|
||||
const recordTableId = 'people';
|
||||
const objectNameSingular = 'person';
|
||||
const mockPersonObjectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const mockPersonObjectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
|
||||
const flatPersonRecords = mockedPersonRecords.map((record) =>
|
||||
getRecordFromRecordNode({ recordNode: record }),
|
||||
);
|
||||
|
||||
const ObjectNamePluralSetter = ({ children }: { children: ReactNode }) => {
|
||||
return <>{children}</>;
|
||||
@@ -104,14 +108,10 @@ const mocks: MockedResponse[] = [
|
||||
},
|
||||
result: jest.fn(() => ({
|
||||
data: {
|
||||
people: peopleQueryResult.people,
|
||||
pageInfo: {
|
||||
hasNextPage: false,
|
||||
hasPreviousPage: false,
|
||||
startCursor: null,
|
||||
endCursor: null,
|
||||
},
|
||||
totalCount: 16,
|
||||
people: generateMockRecordConnection({
|
||||
objectNameSingular: 'person',
|
||||
records: flatPersonRecords,
|
||||
}),
|
||||
},
|
||||
})),
|
||||
},
|
||||
@@ -182,7 +182,7 @@ describe('useRecordIndexTableQuery', () => {
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.records).toHaveLength(16);
|
||||
expect(result.current.records).toHaveLength(flatPersonRecords.length);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@ import { InMemoryCache } from '@apollo/client';
|
||||
import { type MockedResponse } from '@apollo/client/testing';
|
||||
import { act } from 'react';
|
||||
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
|
||||
import { getMockPersonObjectMetadataItem } from '~/testing/mock-data/people';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
|
||||
|
||||
const getDefaultMocks = (
|
||||
overrides?: Partial<MockedResponse>,
|
||||
@@ -44,7 +44,7 @@ const mockRefetchAggregateQueries = jest.fn();
|
||||
refetchAggregateQueries: mockRefetchAggregateQueries,
|
||||
});
|
||||
|
||||
const objectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const objectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
const objectMetadataItems = generatedMockObjectMetadataItems;
|
||||
|
||||
const expectedCachedRecordsWithUpdatedCity = personRecords.map(
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
import { getAggregateLabelWithFieldName } from '@/object-record/record-aggregate/utils/getAggregateLabelWithFieldName';
|
||||
import { AggregateOperations } from '@/object-record/record-table/constants/AggregateOperations';
|
||||
import { findByProperty } from 'twenty-shared/utils';
|
||||
import { getMockCompanyObjectMetadataItem } from '~/testing/mock-data/companies';
|
||||
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
|
||||
|
||||
describe('getAggregateLabelWithFieldName', () => {
|
||||
const mockFieldMetadataItem = getMockCompanyObjectMetadataItem().fields.find(
|
||||
findByProperty('name', 'name'),
|
||||
)!;
|
||||
const mockFieldMetadataItem = getMockObjectMetadataItemOrThrow(
|
||||
'company',
|
||||
).fields.find(findByProperty('name', 'name'))!;
|
||||
|
||||
it('should return correct label for provided field metadata item and operation', () => {
|
||||
expect(
|
||||
|
||||
+3
-2
@@ -7,10 +7,11 @@ import { DateAggregateOperations } from '@/object-record/record-table/constants/
|
||||
import { enUS } from 'date-fns/locale';
|
||||
import { findByProperty } from 'twenty-shared/utils';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { getMockCompanyObjectMetadataItem } from '~/testing/mock-data/companies';
|
||||
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
|
||||
|
||||
describe('transformAggregateRawValueIntoAggregateDisplayValue', () => {
|
||||
const mockCompanyObjectMetadataItem = getMockCompanyObjectMetadataItem();
|
||||
const mockCompanyObjectMetadataItem =
|
||||
getMockObjectMetadataItemOrThrow('company');
|
||||
const mockCompanyEmployeesFieldMetadataItem =
|
||||
mockCompanyObjectMetadataItem.fields.find(
|
||||
findByProperty('name', 'employees'),
|
||||
|
||||
+3
-6
@@ -6,13 +6,10 @@ import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorato
|
||||
import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
|
||||
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||
import { getCompaniesMock } from '~/testing/mock-data/companies';
|
||||
|
||||
import { RecordDetailDuplicatesSection } from '@/object-record/record-field-list/record-detail-section/duplicate/components/RecordDetailDuplicatesSection';
|
||||
import { ComponentDecorator } from 'twenty-ui/testing';
|
||||
import { PageLayoutType } from '~/generated-metadata/graphql';
|
||||
|
||||
const companiesMock = getCompaniesMock();
|
||||
import { mockedCompanyRecords } from '~/testing/mock-data/generated/data/companies/mock-companies-data';
|
||||
|
||||
const meta: Meta<typeof RecordDetailDuplicatesSection> = {
|
||||
title:
|
||||
@@ -23,7 +20,7 @@ const meta: Meta<typeof RecordDetailDuplicatesSection> = {
|
||||
<LayoutRenderingProvider
|
||||
value={{
|
||||
targetRecordIdentifier: {
|
||||
id: companiesMock[0].id,
|
||||
id: mockedCompanyRecords[0].id,
|
||||
targetObjectNameSingular: 'company',
|
||||
},
|
||||
layoutType: PageLayoutType.RECORD_PAGE,
|
||||
@@ -39,7 +36,7 @@ const meta: Meta<typeof RecordDetailDuplicatesSection> = {
|
||||
MemoryRouterDecorator,
|
||||
],
|
||||
args: {
|
||||
objectRecordId: companiesMock[0].id,
|
||||
objectRecordId: mockedCompanyRecords[0].id,
|
||||
objectNameSingular: CoreObjectNameSingular.Company,
|
||||
},
|
||||
parameters: {
|
||||
|
||||
+13
-11
@@ -7,8 +7,6 @@ import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadat
|
||||
import { RecordStoreDecorator } from '~/testing/decorators/RecordStoreDecorator';
|
||||
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||
import { getCompaniesMock } from '~/testing/mock-data/companies';
|
||||
|
||||
import { ContextStoreComponentInstanceContext } from '@/context-store/states/contexts/ContextStoreComponentInstanceContext';
|
||||
import { RecordFieldsScopeContextProvider } from '@/object-record/record-field-list/contexts/RecordFieldsScopeContext';
|
||||
import { RecordDetailRelationSection } from '@/object-record/record-field-list/record-detail-section/relation/components/RecordDetailRelationSection';
|
||||
@@ -16,11 +14,11 @@ import { LayoutRenderingProvider } from '@/ui/layout/contexts/LayoutRenderingCon
|
||||
import { ComponentDecorator } from 'twenty-ui/testing';
|
||||
import { PageLayoutType } from '~/generated-metadata/graphql';
|
||||
import { RightDrawerDecorator } from '~/testing/decorators/RightDrawerDecorator';
|
||||
import { allMockPersonRecords } from '~/testing/mock-data/people';
|
||||
import { mockedCompanyRecords } from '~/testing/mock-data/generated/data/companies/mock-companies-data';
|
||||
import { getRecordFromRecordNode } from '@/object-record/cache/utils/getRecordFromRecordNode';
|
||||
import { mockedPersonRecords } from '~/testing/mock-data/generated/data/people/mock-people-data';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
|
||||
const companiesMock = getCompaniesMock();
|
||||
|
||||
const mockedCompanyObjectMetadataItem = generatedMockObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === 'company',
|
||||
);
|
||||
@@ -38,7 +36,7 @@ const meta: Meta<typeof RecordDetailRelationSection> = {
|
||||
<LayoutRenderingProvider
|
||||
value={{
|
||||
targetRecordIdentifier: {
|
||||
id: companiesMock[0].id,
|
||||
id: mockedCompanyRecords[0].id,
|
||||
targetObjectNameSingular: 'company',
|
||||
},
|
||||
layoutType: PageLayoutType.RECORD_PAGE,
|
||||
@@ -50,7 +48,7 @@ const meta: Meta<typeof RecordDetailRelationSection> = {
|
||||
>
|
||||
<FieldContext.Provider
|
||||
value={{
|
||||
recordId: companiesMock[0].id,
|
||||
recordId: mockedCompanyRecords[0].id,
|
||||
isLabelIdentifier: false,
|
||||
fieldDefinition: formatFieldMetadataItemAsFieldDefinition({
|
||||
field: mockedCompanyObjectMetadataItem.fields.find(
|
||||
@@ -78,7 +76,7 @@ const meta: Meta<typeof RecordDetailRelationSection> = {
|
||||
],
|
||||
parameters: {
|
||||
msw: graphqlMocks,
|
||||
records: companiesMock,
|
||||
records: mockedCompanyRecords,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -87,15 +85,19 @@ type Story = StoryObj<typeof RecordDetailRelationSection>;
|
||||
|
||||
export const EmptyState: Story = {};
|
||||
|
||||
const flatPersonRecords = mockedPersonRecords.map((record) =>
|
||||
getRecordFromRecordNode({ recordNode: record }),
|
||||
);
|
||||
|
||||
export const WithRecords: Story = {
|
||||
decorators: [RecordStoreDecorator],
|
||||
parameters: {
|
||||
records: [
|
||||
{
|
||||
...companiesMock[0],
|
||||
people: allMockPersonRecords,
|
||||
...mockedCompanyRecords[0],
|
||||
people: flatPersonRecords,
|
||||
},
|
||||
...allMockPersonRecords,
|
||||
...flatPersonRecords,
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
+9
-6
@@ -27,7 +27,7 @@ import { useSetAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useSe
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
import { RelationManyToOneFieldInput } from '@/object-record/record-field/ui/meta-types/input/components/RelationManyToOneFieldInput';
|
||||
import { getCompaniesMock } from '~/testing/mock-data/companies';
|
||||
import { mockedCompanyRecords } from '~/testing/mock-data/generated/data/companies/mock-companies-data';
|
||||
import { getMockFieldMetadataItemOrThrow } from '~/testing/utils/getMockFieldMetadataItemOrThrow';
|
||||
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
|
||||
import { getFieldInputEventContextProviderWithJestMocks } from './utils/getFieldInputEventContextProviderWithJestMocks';
|
||||
@@ -42,7 +42,6 @@ const peopleFieldOnCompany = getMockFieldMetadataItemOrThrow({
|
||||
objectMetadataItem: companyMetadata,
|
||||
fieldName: 'people',
|
||||
});
|
||||
const companiesMock = getCompaniesMock();
|
||||
|
||||
const RelationWorkspaceSetterEffect = () => {
|
||||
const setRecordFieldInputLayoutDirectionLoading = useSetAtomComponentState(
|
||||
@@ -169,9 +168,13 @@ export const Submit: Story = {
|
||||
|
||||
expect(handleSubmitMocked).toHaveBeenCalledTimes(0);
|
||||
|
||||
const item = await canvas.findByText(companiesMock[0].name, undefined, {
|
||||
timeout: 3000,
|
||||
});
|
||||
const item = await canvas.findByText(
|
||||
mockedCompanyRecords[0].name,
|
||||
undefined,
|
||||
{
|
||||
timeout: 3000,
|
||||
},
|
||||
);
|
||||
|
||||
await userEvent.click(item);
|
||||
|
||||
@@ -186,7 +189,7 @@ export const Cancel: Story = {
|
||||
const canvas = within(canvasElement);
|
||||
|
||||
expect(handleCancelMocked).toHaveBeenCalledTimes(0);
|
||||
await canvas.findByText(companiesMock[0].name, undefined, {
|
||||
await canvas.findByText(mockedCompanyRecords[0].name, undefined, {
|
||||
timeout: 3000,
|
||||
});
|
||||
|
||||
|
||||
+7
-9
@@ -10,13 +10,11 @@ import {
|
||||
isDefined,
|
||||
} from 'twenty-shared/utils';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { getCompaniesMock } from '~/testing/mock-data/companies';
|
||||
import { mockedCompanyRecords } from '~/testing/mock-data/generated/data/companies/mock-companies-data';
|
||||
|
||||
import { getMockFieldMetadataItemOrThrow } from '~/testing/utils/getMockFieldMetadataItemOrThrow';
|
||||
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
|
||||
|
||||
const companiesMock = getCompaniesMock();
|
||||
|
||||
const companyMockObjectMetadataItem =
|
||||
getMockObjectMetadataItemOrThrow('company');
|
||||
|
||||
@@ -44,9 +42,9 @@ describe('computeViewRecordGqlOperationFilter', () => {
|
||||
|
||||
const nameFilter: RecordFilter = {
|
||||
id: 'company-name-filter',
|
||||
value: companiesMock[0].name,
|
||||
value: mockedCompanyRecords[0].name,
|
||||
fieldMetadataId: companyMockNameFieldMetadataId.id,
|
||||
displayValue: companiesMock[0].name,
|
||||
displayValue: mockedCompanyRecords[0].name,
|
||||
operand: RecordFilterOperand.CONTAINS,
|
||||
type: 'TEXT',
|
||||
label: 'Name',
|
||||
@@ -61,7 +59,7 @@ describe('computeViewRecordGqlOperationFilter', () => {
|
||||
|
||||
expect(result).toEqual({
|
||||
name: {
|
||||
ilike: `%${companiesMock[0].name}%`,
|
||||
ilike: `%${mockedCompanyRecords[0].name}%`,
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -87,9 +85,9 @@ describe('computeViewRecordGqlOperationFilter', () => {
|
||||
|
||||
const nameFilter: RecordFilter = {
|
||||
id: 'company-name-filter',
|
||||
value: companiesMock[0].name,
|
||||
value: mockedCompanyRecords[0].name,
|
||||
fieldMetadataId: companyMockNameFieldMetadataId.id,
|
||||
displayValue: companiesMock[0].name,
|
||||
displayValue: mockedCompanyRecords[0].name,
|
||||
operand: ViewFilterOperand.CONTAINS,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Name',
|
||||
@@ -116,7 +114,7 @@ describe('computeViewRecordGqlOperationFilter', () => {
|
||||
and: [
|
||||
{
|
||||
name: {
|
||||
ilike: `%${companiesMock[0].name}%`,
|
||||
ilike: `%${mockedCompanyRecords[0].name}%`,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
+5
-2
@@ -1,12 +1,15 @@
|
||||
import { type RecordGqlOperationFilter } from 'twenty-shared/types';
|
||||
import { getCompaniesMock } from '~/testing/mock-data/companies';
|
||||
import { mockedCompanyRecords } from '~/testing/mock-data/generated/data/companies/mock-companies-data';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
|
||||
import { type Company } from '@/companies/types/Company';
|
||||
import { getCompanyDomainName } from '@/object-metadata/utils/getCompanyDomainName';
|
||||
import { getRecordFromRecordNode } from '@/object-record/cache/utils/getRecordFromRecordNode';
|
||||
import { isRecordMatchingFilter } from '@/object-record/record-filter/utils/isRecordMatchingFilter';
|
||||
|
||||
const companiesMock = getCompaniesMock();
|
||||
const companiesMock = mockedCompanyRecords.map((record) =>
|
||||
getRecordFromRecordNode<Company>({ recordNode: record }),
|
||||
);
|
||||
|
||||
const companyMockObjectMetadataItem = generatedMockObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === 'company',
|
||||
|
||||
+13
-7
@@ -10,13 +10,11 @@ import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorato
|
||||
import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
|
||||
import { RecordTableDecorator } from '~/testing/decorators/RecordTableDecorator';
|
||||
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
||||
import { getCompaniesMock } from '~/testing/mock-data/companies';
|
||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||
import { mockedCompanyRecords } from '~/testing/mock-data/generated/data/companies/mock-companies-data';
|
||||
import { mockedViewsData } from '~/testing/mock-data/views';
|
||||
import { sleep } from '~/utils/sleep';
|
||||
|
||||
const companiesMock = getCompaniesMock();
|
||||
|
||||
const meta: Meta = {
|
||||
title: 'Modules/ObjectRecord/RecordTable/RecordTable',
|
||||
component: RecordTableWithWrappers,
|
||||
@@ -73,7 +71,11 @@ export const ScrolledLeft: Story = {
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await canvas.findAllByText(companiesMock[0].name, {}, { timeout: 3000 });
|
||||
await canvas.findAllByText(
|
||||
mockedCompanyRecords[0].name,
|
||||
{},
|
||||
{ timeout: 3000 },
|
||||
);
|
||||
|
||||
const scrollWrapper = canvasElement.ownerDocument.body.querySelector(
|
||||
'.scroll-wrapper-x-enabled',
|
||||
@@ -91,7 +93,7 @@ export const ScrolledLeft: Story = {
|
||||
},
|
||||
});
|
||||
|
||||
await canvas.findByText(companiesMock[1].name);
|
||||
await canvas.findByText(mockedCompanyRecords[1].name);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -103,7 +105,11 @@ export const ScrolledBottom: Story = {
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await canvas.findAllByText(companiesMock[0].name, {}, { timeout: 3000 });
|
||||
await canvas.findAllByText(
|
||||
mockedCompanyRecords[0].name,
|
||||
{},
|
||||
{ timeout: 3000 },
|
||||
);
|
||||
|
||||
const scrollWrapper = canvasElement.ownerDocument.body.querySelector(
|
||||
'.scroll-wrapper-y-enabled',
|
||||
@@ -121,6 +127,6 @@ export const ScrolledBottom: Story = {
|
||||
},
|
||||
});
|
||||
|
||||
await canvas.findByText(companiesMock[1].name);
|
||||
await canvas.findByText(mockedCompanyRecords[1].name);
|
||||
},
|
||||
};
|
||||
|
||||
+2
-2
@@ -2,11 +2,11 @@ import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataI
|
||||
import { spreadsheetImportGetUnicityTableHook } from '@/object-record/spreadsheet-import/utils/spreadsheetImportGetUnicityTableHook';
|
||||
import { type ImportedStructuredRow } from '@/spreadsheet-import/types';
|
||||
import { IndexType } from '~/generated-metadata/graphql';
|
||||
import { getMockCompanyObjectMetadataItem } from '~/testing/mock-data/companies';
|
||||
import { getMockFieldMetadataItemOrThrow } from '~/testing/utils/getMockFieldMetadataItemOrThrow';
|
||||
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
|
||||
|
||||
describe('spreadsheetImportGetUnicityTableHook', () => {
|
||||
const baseMockCompany = getMockCompanyObjectMetadataItem();
|
||||
const baseMockCompany = getMockObjectMetadataItemOrThrow('company');
|
||||
|
||||
const nameField = getMockFieldMetadataItemOrThrow({
|
||||
objectMetadataItem: baseMockCompany,
|
||||
|
||||
+13
-12
@@ -4,18 +4,17 @@ import { generateDepthRecordGqlFieldsFromRecord } from '@/object-record/graphql/
|
||||
import { type FieldActorForInputValue } from '@/object-record/record-field/ui/types/FieldMetadata';
|
||||
import { computeOptimisticRecordFromInput } from '@/object-record/utils/computeOptimisticRecordFromInput';
|
||||
import { InMemoryCache } from '@apollo/client';
|
||||
import { getMockCompanyObjectMetadataItem } from '~/testing/mock-data/companies';
|
||||
import { getMockPersonObjectMetadataItem } from '~/testing/mock-data/people';
|
||||
import { mockCurrentWorkspaceMembers } from '~/testing/mock-data/workspace-members';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
import { getMockFieldMetadataItemOrThrow } from '~/testing/utils/getMockFieldMetadataItemOrThrow';
|
||||
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
|
||||
|
||||
describe('computeOptimisticRecordFromInput', () => {
|
||||
const currentWorkspaceMember = mockCurrentWorkspaceMembers[0];
|
||||
const currentWorkspaceMemberFullname = `${currentWorkspaceMember.name.firstName} ${currentWorkspaceMember.name.lastName}`;
|
||||
it('should generate correct optimistic record if no relation field is present', () => {
|
||||
const cache = new InMemoryCache();
|
||||
const personObjectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const personObjectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
|
||||
const result = computeOptimisticRecordFromInput({
|
||||
currentWorkspaceMember,
|
||||
@@ -35,7 +34,7 @@ describe('computeOptimisticRecordFromInput', () => {
|
||||
|
||||
it('should generate correct optimistic record with actor field', () => {
|
||||
const cache = new InMemoryCache();
|
||||
const personObjectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const personObjectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
const actorFieldValueForInput: FieldActorForInputValue = {
|
||||
context: {},
|
||||
source: 'API',
|
||||
@@ -65,7 +64,7 @@ describe('computeOptimisticRecordFromInput', () => {
|
||||
|
||||
it('should generate correct optimistic record createdBy when recordInput contains id', () => {
|
||||
const cache = new InMemoryCache();
|
||||
const personObjectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const personObjectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
const result = computeOptimisticRecordFromInput({
|
||||
currentWorkspaceMember,
|
||||
objectMetadataItems: generatedMockObjectMetadataItems,
|
||||
@@ -94,7 +93,7 @@ describe('computeOptimisticRecordFromInput', () => {
|
||||
|
||||
it('should generate correct optimistic record if relation field is present but cache is empty', () => {
|
||||
const cache = new InMemoryCache();
|
||||
const personObjectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const personObjectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
|
||||
const result = computeOptimisticRecordFromInput({
|
||||
currentWorkspaceMember,
|
||||
@@ -114,8 +113,9 @@ describe('computeOptimisticRecordFromInput', () => {
|
||||
|
||||
it('should generate correct optimistic record even if recordInput contains field __typename', () => {
|
||||
const cache = new InMemoryCache();
|
||||
const personObjectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const companyObjectMetadataItem = getMockCompanyObjectMetadataItem();
|
||||
const personObjectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
const companyObjectMetadataItem =
|
||||
getMockObjectMetadataItemOrThrow('company');
|
||||
|
||||
const companyRecord = {
|
||||
id: '123',
|
||||
@@ -163,8 +163,9 @@ describe('computeOptimisticRecordFromInput', () => {
|
||||
|
||||
it('should generate correct optimistic record if relation field is present and cache is not empty', () => {
|
||||
const cache = new InMemoryCache();
|
||||
const personObjectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const companyObjectMetadataItem = getMockCompanyObjectMetadataItem();
|
||||
const personObjectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
const companyObjectMetadataItem =
|
||||
getMockObjectMetadataItemOrThrow('company');
|
||||
|
||||
const companyRecord = {
|
||||
id: '123',
|
||||
@@ -214,7 +215,7 @@ describe('computeOptimisticRecordFromInput', () => {
|
||||
|
||||
it('should generate correct optimistic record if relation field is null and cache is empty', () => {
|
||||
const cache = new InMemoryCache();
|
||||
const personObjectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const personObjectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
|
||||
const result = computeOptimisticRecordFromInput({
|
||||
currentWorkspaceMember,
|
||||
@@ -235,7 +236,7 @@ describe('computeOptimisticRecordFromInput', () => {
|
||||
|
||||
it('should throw an error if recordInput contains fields unrelated to the current objectMetadata', () => {
|
||||
const cache = new InMemoryCache();
|
||||
const personObjectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
const personObjectMetadataItem = getMockObjectMetadataItemOrThrow('person');
|
||||
|
||||
expect(() =>
|
||||
computeOptimisticRecordFromInput({
|
||||
|
||||
Reference in New Issue
Block a user