+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(
|
||||
|
||||
Reference in New Issue
Block a user