Fix createdBy and activity tests (#6569)

As title
This commit is contained in:
Thomas Trompette 2024-08-07 16:21:06 +02:00 committed by GitHub
parent c836bbbfc2
commit 9a0c9672a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 425 additions and 551 deletions

View File

@ -23,20 +23,17 @@ const mocks: MockedResponse[] = [
{
request: {
query: gql`
mutation CreateOneActivity($input: ActivityCreateInput!) {
createActivity(data: $input) {
mutation CreateOneTask($input: TaskCreateInput!) {
createTask(data: $input) {
__typename
createdAt
reminderAt
authorId
title
status
assigneeId
updatedAt
body
createdAt
dueAt
type
id
assigneeId
title
}
}
`,
@ -46,7 +43,7 @@ const mocks: MockedResponse[] = [
},
result: jest.fn(() => ({
data: {
createActivity: {
createTask: {
...mockedActivity,
__typename: 'Activity',
assigneeId: '',

View File

@ -9,7 +9,7 @@ import { Task } from '@/activities/types/Task';
const task: Task = {
id: '123',
status: null,
status: 'DONE',
title: 'Test',
body: 'Test',
dueAt: '2024-03-15T07:33:14.212Z',
@ -25,23 +25,23 @@ const mocks: MockedResponse[] = [
{
request: {
query: gql`
mutation UpdateOneActivity(
$idToUpdate: ID!
$input: ActivityUpdateInput!
) {
updateActivity(id: $idToUpdate, data: $input) {
mutation UpdateOneTask($idToUpdate: ID!, $input: TaskUpdateInput!) {
updateTask(id: $idToUpdate, data: $input) {
__typename
createdAt
reminderAt
authorId
title
status
assigneeId
updatedAt
body
createdAt
dueAt
type
position
id
assigneeId
title
createdBy {
source
workspaceMemberId
name
}
}
}
`,
@ -52,7 +52,7 @@ const mocks: MockedResponse[] = [
},
result: jest.fn(() => ({
data: {
updateActivity: {
updateTask: {
__typename: 'Activity',
createdAt: '2024-03-15T07:33:14.212Z',
reminderAt: null,

View File

@ -1,6 +1,7 @@
import { gql } from '@apollo/client';
import { AvatarType } from 'twenty-ui';
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { ColorScheme } from '@/workspace-member/types/WorkspaceMember';
export const mockId = '8f3b2121-f194-4ba4-9fbf-2d5a37126806';
@ -50,21 +51,21 @@ export const initialFavorites = [
export const sortedFavorites = [
{
id: '1',
recordId: '1',
recordId: '2',
position: 0,
avatarType: 'rounded',
avatarUrl: '',
labelIdentifier: ' ',
link: '/object/person/1',
avatarType: 'squared',
avatarUrl: undefined,
labelIdentifier: 'ABC Corp',
link: '/object/company/2',
},
{
id: '2',
recordId: '3',
recordId: '4',
position: 1,
avatarType: 'rounded',
avatarUrl: '',
labelIdentifier: ' ',
link: '/object/person/3',
avatarType: 'squared',
avatarUrl: undefined,
labelIdentifier: 'Company Test',
link: '/object/company/4',
},
{
id: '3',
@ -85,94 +86,160 @@ export const mocks = [
mutation CreateOneFavorite($input: FavoriteCreateInput!) {
createFavorite(data: $input) {
__typename
id
companyId
createdAt
personId
person {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
}
position
taskId
myCustomObjectId
workspaceMemberId
workspaceMember {
__typename
userId
updatedAt
dateFormat
id
locale
avatarUrl
timeZone
name {
firstName
lastName
}
userEmail
createdAt
timeFormat
colorScheme
}
companyId
myCustomObject {
__typename
createdBy {
source
workspaceMemberId
workspaceMember {
__typename
colorScheme
name {
firstName
lastName
}
locale
userId
avatarUrl
createdAt
updatedAt
id
}
company {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
domainName {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
annualRecurringRevenue {
amountMicros
currencyCode
}
createdAt
address {
addressStreet1
addressStreet2
addressCity
addressState
addressCountry
addressPostcode
addressLat
addressLng
}
updatedAt
name
accountOwnerId
employees
id
idealCustomerProfile
}
updatedAt
name
}
position
updatedAt
name
myCustomField
id
createdAt
}
updatedAt
id
opportunity {
__typename
companyId
closeDate
stage
createdBy {
source
workspaceMemberId
name
}
id
updatedAt
name
createdAt
pointOfContactId
amount {
amountMicros
currencyCode
}
position
}
noteId
note {
__typename
createdBy {
source
workspaceMemberId
name
}
position
body
updatedAt
createdAt
title
id
}
personId
task {
__typename
status
assigneeId
updatedAt
body
createdAt
dueAt
position
id
title
createdBy {
source
workspaceMemberId
name
}
}
opportunityId
position
createdAt
company {
__typename
id
visaSponsorship
createdBy {
source
workspaceMemberId
name
}
domainName {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
introVideo {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
position
annualRecurringRevenue {
amountMicros
currencyCode
}
employees
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
workPolicy
address {
addressStreet1
addressStreet2
addressCity
addressState
addressCountry
addressPostcode
addressLat
addressLng
}
name
updatedAt
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
myCustomField
createdAt
accountOwnerId
tagline
idealCustomerProfile
}
person {
${PERSON_FRAGMENT}
}
}
}
`,
variables: {
input: {
@ -219,92 +286,158 @@ export const mocks = [
) {
updateFavorite(id: $idToUpdate, data: $input) {
__typename
id
companyId
createdAt
personId
person {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
}
position
taskId
myCustomObjectId
workspaceMemberId
workspaceMember {
__typename
userId
updatedAt
dateFormat
id
locale
avatarUrl
timeZone
name {
firstName
lastName
}
userEmail
createdAt
timeFormat
colorScheme
}
companyId
myCustomObject {
__typename
createdBy {
source
workspaceMemberId
workspaceMember {
__typename
colorScheme
name {
firstName
lastName
}
locale
userId
avatarUrl
createdAt
updatedAt
id
}
company {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
domainName {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
annualRecurringRevenue {
amountMicros
currencyCode
}
createdAt
address {
addressStreet1
addressStreet2
addressCity
addressState
addressCountry
addressPostcode
addressLat
addressLng
}
updatedAt
name
accountOwnerId
employees
id
idealCustomerProfile
}
updatedAt
name
}
position
updatedAt
name
myCustomField
id
createdAt
}
updatedAt
id
opportunity {
__typename
companyId
closeDate
stage
createdBy {
source
workspaceMemberId
name
}
id
updatedAt
name
createdAt
pointOfContactId
amount {
amountMicros
currencyCode
}
position
}
noteId
note {
__typename
createdBy {
source
workspaceMemberId
name
}
position
body
updatedAt
createdAt
title
id
}
personId
task {
__typename
status
assigneeId
updatedAt
body
createdAt
dueAt
position
id
title
createdBy {
source
workspaceMemberId
name
}
}
opportunityId
position
createdAt
company {
__typename
id
visaSponsorship
createdBy {
source
workspaceMemberId
name
}
domainName {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
introVideo {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
position
annualRecurringRevenue {
amountMicros
currencyCode
}
employees
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
workPolicy
address {
addressStreet1
addressStreet2
addressCity
addressState
addressCountry
addressPostcode
addressLat
addressLng
}
name
updatedAt
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
myCustomField
createdAt
accountOwnerId
tagline
idealCustomerProfile
}
person {
${PERSON_FRAGMENT}
}
}
}
`,

View File

@ -0,0 +1,37 @@
export const PERSON_FRAGMENT = `
__typename
updatedAt
myCustomObjectId
whatsapp
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
name {
firstName
lastName
}
email
position
createdBy {
source
workspaceMemberId
name
}
avatarUrl
jobTitle
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
performanceRating
createdAt
phone
id
city
companyId
intro
workPrefereance
`

View File

@ -1,34 +1,12 @@
import { gql } from '@apollo/client';
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { Person } from '@/people/types/Person';
export const query = gql`
mutation CreatePeople($data: [PersonCreateInput!]!, $upsert: Boolean) {
createPeople(data: $data, upsert: $upsert) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
}
`;

View File

@ -1,32 +1,10 @@
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { gql } from '@apollo/client';
export const query = gql`
mutation CreateOnePerson($input: PersonCreateInput!) {
createPerson(data: $input) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
}
`;

View File

@ -1,3 +1,4 @@
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { gql } from '@apollo/client';
export { responseData } from './useUpdateOneRecord';
@ -5,30 +6,7 @@ export { responseData } from './useUpdateOneRecord';
export const query = gql`
mutation ExecuteQuickActionOnOnePerson($idToExecuteQuickActionOn: ID!) {
executeQuickActionOnPerson(id: $idToExecuteQuickActionOn) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
}
`;

View File

@ -1,3 +1,4 @@
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { gql } from '@apollo/client';
import { getPeopleMock } from '~/testing/mock-data/people';
@ -8,30 +9,7 @@ export const query = gql`
personDuplicates(ids: $ids) {
edges {
node {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
cursor
}

View File

@ -1,34 +1,12 @@
import { gql } from '@apollo/client';
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { responseData as person } from './useUpdateOneRecord';
export const query = gql`
query FindOnePerson($objectRecordId: ID!) {
person(filter: { id: { eq: $objectRecordId } }) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
}
`;

View File

@ -1,32 +1,10 @@
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { gql } from '@apollo/client';
export const query = gql`
mutation UpdateOnePerson($idToUpdate: ID!, $input: PersonUpdateInput!) {
updatePerson(id: $idToUpdate, data: $input) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
}
`;

View File

@ -2,35 +2,13 @@ import { renderHook } from '@testing-library/react';
import { print } from 'graphql';
import { RecoilRoot } from 'recoil';
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { useCreateManyRecordsMutation } from '@/object-record/hooks/useCreateManyRecordsMutation';
const expectedQueryTemplate = `
mutation CreatePeople($data: [PersonCreateInput!]!, $upsert: Boolean) {
createPeople(data: $data, upsert: $upsert) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
}
`.replace(/\s/g, '');

View File

@ -2,35 +2,13 @@ import { renderHook } from '@testing-library/react';
import { print } from 'graphql';
import { RecoilRoot } from 'recoil';
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { useCreateOneRecordMutation } from '@/object-record/hooks/useCreateOneRecordMutation';
const expectedQueryTemplate = `
mutation CreateOnePerson($input: PersonCreateInput!) {
createPerson(data: $input) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
}
`.replace(/\s/g, '');

View File

@ -2,35 +2,13 @@ import { renderHook } from '@testing-library/react';
import { print } from 'graphql';
import { RecoilRoot } from 'recoil';
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { useExecuteQuickActionOnOneRecordMutation } from '@/object-record/hooks/useExecuteQuickActionOnOneRecordMutation';
const expectedQueryTemplate = `
mutation ExecuteQuickActionOnOnePerson($idToExecuteQuickActionOn: ID!) {
executeQuickActionOnPerson(id: $idToExecuteQuickActionOn) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
}
`.replace(/\s/g, '');

View File

@ -2,6 +2,7 @@ import { renderHook } from '@testing-library/react';
import { print } from 'graphql';
import { RecoilRoot } from 'recoil';
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { useFindDuplicateRecordsQuery } from '@/object-record/hooks/useFindDuplicatesRecordsQuery';
const expectedQueryTemplate = `
@ -9,30 +10,7 @@ const expectedQueryTemplate = `
personDuplicates(ids: $ids) {
edges {
node {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
cursor
}

View File

@ -2,6 +2,7 @@ import { renderHook } from '@testing-library/react';
import { print } from 'graphql';
import { RecoilRoot } from 'recoil';
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { useFindManyRecordsQuery } from '@/object-record/hooks/useFindManyRecordsQuery';
const expectedQueryTemplate = `
@ -9,30 +10,7 @@ const expectedQueryTemplate = `
people(filter: $filter, orderBy: $orderBy, first: $limit, after: $lastCursor) {
edges {
node {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
cursor
}

View File

@ -2,35 +2,13 @@ import { renderHook } from '@testing-library/react';
import { print } from 'graphql';
import { RecoilRoot } from 'recoil';
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { useFindOneRecordQuery } from '@/object-record/hooks/useFindOneRecordQuery';
const expectedQueryTemplate = `
query FindOnePerson($objectRecordId: ID!) {
person(filter: { id: { eq: $objectRecordId } }) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
}
`.replace(/\s/g, '');

View File

@ -2,36 +2,14 @@ import { renderHook } from '@testing-library/react';
import { print } from 'graphql';
import { RecoilRoot } from 'recoil';
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { useUpdateOneRecordMutation } from '@/object-record/hooks/useUpdateOneRecordMutation';
import { normalizeGQLQuery } from '~/utils/normalizeGQLQuery';
const expectedQueryTemplate = `
mutation UpdateOnePerson($idToUpdate: ID!, $input: PersonUpdateInput!) {
updatePerson(id: $idToUpdate, data: $input) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
}`;

View File

@ -5,6 +5,7 @@ import { ReactNode } from 'react';
import { RecoilRoot, useRecoilValue } from 'recoil';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { PERSON_FRAGMENT } from '@/object-record/hooks/__mocks__/personFragment';
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
import {
phoneFieldDefinition,
@ -23,30 +24,7 @@ import { recordStoreFamilySelector } from '@/object-record/record-store/states/s
const query = gql`
mutation UpdateOnePerson($idToUpdate: ID!, $input: PersonUpdateInput!) {
updatePerson(id: $idToUpdate, data: $input) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
id
createdAt
city
email
jobTitle
name {
firstName
lastName
}
phone
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
updatedAt
avatarUrl
companyId
${PERSON_FRAGMENT}
}
}
`;

View File

@ -26,26 +26,35 @@ const mocks: MockedResponse[] = [
) {
updateCompany(id: $idToUpdate, data: $input) {
__typename
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
id
visaSponsorship
createdBy {
source
workspaceMemberId
name
}
domainName {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
introVideo {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
position
annualRecurringRevenue {
amountMicros
currencyCode
}
createdAt
employees
linkedinLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
workPolicy
address {
addressStreet1
addressStreet2
@ -56,11 +65,17 @@ const mocks: MockedResponse[] = [
addressLat
addressLng
}
updatedAt
name
updatedAt
xLink {
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
myCustomField
createdAt
accountOwnerId
employees
id
tagline
idealCustomerProfile
}
}