From 0b554d6cfacc406b0e3a5eddeefcf9b59c4fbced Mon Sep 17 00:00:00 2001 From: gitstart-twenty Date: Mon, 14 Oct 2024 19:04:34 +0000 Subject: [PATCH 1/7] [Server Integration tests] Enrich integration GraphQL API tests --- .../twenty-server/jest-integration.config.ts | 1 + .../test/companies.integration-spec.ts | 67 ----------- .../create-many-companies.integration-spec.ts | 64 ++++++++++ .../create-one-company.integration-spec.ts | 55 +++++++++ .../delete-many-companies.integration.ts | 95 +++++++++++++++ .../delete-one-company.integration-spec.ts | 108 +++++++++++++++++ ...destroy-many-companies.integration-spec.ts | 98 ++++++++++++++++ .../destroy-one-company.integration-spec.ts | 104 ++++++++++++++++ .../find-many-companies.integration-spec.ts | 57 +++++++++ .../find-one-company.integration-spec.ts | 60 ++++++++++ ...erson-company-relation.integration-spec.ts | 111 ++++++++++++++++++ .../update-many-companies.integration-spec.ts | 85 ++++++++++++++ .../update-one-company.integration-spec.ts | 62 ++++++++++ .../test/company.integration-spec.ts | 48 -------- .../twenty-server/test/utils/api-requests.ts | 80 +++++++++++++ .../test/utils/generate-record-name.ts | 4 + .../twenty-server/test/utils/teardown-test.ts | 48 +++++++- 17 files changed, 1031 insertions(+), 116 deletions(-) delete mode 100644 packages/twenty-server/test/companies.integration-spec.ts create mode 100644 packages/twenty-server/test/companies/create-many-companies.integration-spec.ts create mode 100644 packages/twenty-server/test/companies/create-one-company.integration-spec.ts create mode 100644 packages/twenty-server/test/companies/delete-many-companies.integration.ts create mode 100644 packages/twenty-server/test/companies/delete-one-company.integration-spec.ts create mode 100644 packages/twenty-server/test/companies/destroy-many-companies.integration-spec.ts create mode 100644 packages/twenty-server/test/companies/destroy-one-company.integration-spec.ts create mode 100644 packages/twenty-server/test/companies/find-many-companies.integration-spec.ts create mode 100644 packages/twenty-server/test/companies/find-one-company.integration-spec.ts create mode 100644 packages/twenty-server/test/companies/person-company-relation.integration-spec.ts create mode 100644 packages/twenty-server/test/companies/update-many-companies.integration-spec.ts create mode 100644 packages/twenty-server/test/companies/update-one-company.integration-spec.ts delete mode 100644 packages/twenty-server/test/company.integration-spec.ts create mode 100644 packages/twenty-server/test/utils/api-requests.ts create mode 100644 packages/twenty-server/test/utils/generate-record-name.ts diff --git a/packages/twenty-server/jest-integration.config.ts b/packages/twenty-server/jest-integration.config.ts index 10b5cc9e2099..b629f01b60ce 100644 --- a/packages/twenty-server/jest-integration.config.ts +++ b/packages/twenty-server/jest-integration.config.ts @@ -16,6 +16,7 @@ const jestConfig: JestConfigWithTsJest = { testTimeout: 15000, moduleNameMapper: { ...pathsToModuleNameMapper(tsConfig.compilerOptions.paths), + '^test/(.*)$': '/test/$1', 'twenty-emails': '/../twenty-emails/dist/index.js', }, fakeTimers: { diff --git a/packages/twenty-server/test/companies.integration-spec.ts b/packages/twenty-server/test/companies.integration-spec.ts deleted file mode 100644 index 63c7f9eec481..000000000000 --- a/packages/twenty-server/test/companies.integration-spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -import request from 'supertest'; - -const client = request(`http://localhost:${APP_PORT}`); - -describe('companiesResolver (integration)', () => { - it('should find many companies', () => { - const queryData = { - query: ` - query companies { - companies { - edges { - node { - name - employees - idealCustomerProfile - position - id - createdAt - updatedAt - deletedAt - accountOwnerId - tagline - workPolicy - visaSponsorship - } - } - } - } - `, - }; - - return client - .post('/graphql') - .set('Authorization', `Bearer ${ACCESS_TOKEN}`) - .send(queryData) - .expect(200) - .expect((res) => { - expect(res.body.data).toBeDefined(); - expect(res.body.errors).toBeUndefined(); - }) - .expect((res) => { - const data = res.body.data.companies; - - expect(data).toBeDefined(); - expect(Array.isArray(data.edges)).toBe(true); - - const edges = data.edges; - - if (edges.length > 0) { - const companies = edges[0].node; - - expect(companies).toHaveProperty('name'); - expect(companies).toHaveProperty('employees'); - expect(companies).toHaveProperty('idealCustomerProfile'); - expect(companies).toHaveProperty('position'); - expect(companies).toHaveProperty('id'); - expect(companies).toHaveProperty('createdAt'); - expect(companies).toHaveProperty('updatedAt'); - expect(companies).toHaveProperty('deletedAt'); - expect(companies).toHaveProperty('accountOwnerId'); - expect(companies).toHaveProperty('tagline'); - expect(companies).toHaveProperty('workPolicy'); - expect(companies).toHaveProperty('visaSponsorship'); - } - }); - }); -}); diff --git a/packages/twenty-server/test/companies/create-many-companies.integration-spec.ts b/packages/twenty-server/test/companies/create-many-companies.integration-spec.ts new file mode 100644 index 000000000000..7149bff58b1e --- /dev/null +++ b/packages/twenty-server/test/companies/create-many-companies.integration-spec.ts @@ -0,0 +1,64 @@ +import gql from 'graphql-tag'; +import { successfulApiRequest } from 'test/utils/api-requests'; +import { generateRecordName } from 'test/utils/generate-record-name'; + +const createCompaniesQuery = gql` + mutation CreateCompanies($data: [CompanyCreateInput!]!) { + createCompanies(data: $data) { + id + name + employees + idealCustomerProfile + position + createdAt + updatedAt + deletedAt + accountOwnerId + tagline + workPolicy + visaSponsorship + } + } +`; + +describe('createCompaniesResolver (integration)', () => { + it('should create and return companies', async () => { + const companyName1 = generateRecordName(); + const companyName2 = generateRecordName(); + + const queryData = { + query: createCompaniesQuery, + variables: { + data: [ + { + name: companyName1, + }, + { + name: companyName2, + }, + ], + }, + }; + + const createdCompanies = await successfulApiRequest(queryData); + + expect(createdCompanies.body.data.createCompanies).toHaveLength(2); + + createdCompanies.body.data.createCompanies.forEach((company) => { + expect(company).toHaveProperty('name'); + expect([companyName1, companyName2]).toContain(company.name); + + expect(company).toHaveProperty('employees'); + expect(company).toHaveProperty('idealCustomerProfile'); + expect(company).toHaveProperty('position'); + expect(company).toHaveProperty('id'); + expect(company).toHaveProperty('createdAt'); + expect(company).toHaveProperty('updatedAt'); + expect(company).toHaveProperty('deletedAt'); + expect(company).toHaveProperty('accountOwnerId'); + expect(company).toHaveProperty('tagline'); + expect(company).toHaveProperty('workPolicy'); + expect(company).toHaveProperty('visaSponsorship'); + }); + }); +}); diff --git a/packages/twenty-server/test/companies/create-one-company.integration-spec.ts b/packages/twenty-server/test/companies/create-one-company.integration-spec.ts new file mode 100644 index 000000000000..2a92d97866f9 --- /dev/null +++ b/packages/twenty-server/test/companies/create-one-company.integration-spec.ts @@ -0,0 +1,55 @@ +import gql from 'graphql-tag'; +import { successfulApiRequest } from 'test/utils/api-requests'; +import { generateRecordName } from 'test/utils/generate-record-name'; + +const query = gql` + mutation CreateCompany($data: CompanyCreateInput) { + createCompany(data: $data) { + name + employees + idealCustomerProfile + position + id + createdAt + updatedAt + deletedAt + accountOwnerId + tagline + workPolicy + visaSponsorship + } + } +`; + +describe('createCompanyResolver (integration)', () => { + it('should create and return a company', () => { + const companyName = generateRecordName(); + const queryData = { + query, + variables: { + data: { + name: companyName, + }, + }, + }; + + return successfulApiRequest(queryData).expect((res) => { + const createdCompany = res.body.data.createCompany; + + expect(createdCompany).toHaveProperty('name'); + expect(createdCompany.name).toEqual(companyName); + + expect(createdCompany).toHaveProperty('employees'); + expect(createdCompany).toHaveProperty('idealCustomerProfile'); + expect(createdCompany).toHaveProperty('position'); + expect(createdCompany).toHaveProperty('id'); + expect(createdCompany).toHaveProperty('createdAt'); + expect(createdCompany).toHaveProperty('updatedAt'); + expect(createdCompany).toHaveProperty('deletedAt'); + expect(createdCompany).toHaveProperty('accountOwnerId'); + expect(createdCompany).toHaveProperty('tagline'); + expect(createdCompany).toHaveProperty('workPolicy'); + expect(createdCompany).toHaveProperty('visaSponsorship'); + }); + }); +}); diff --git a/packages/twenty-server/test/companies/delete-many-companies.integration.ts b/packages/twenty-server/test/companies/delete-many-companies.integration.ts new file mode 100644 index 000000000000..e4e45fc3ab7f --- /dev/null +++ b/packages/twenty-server/test/companies/delete-many-companies.integration.ts @@ -0,0 +1,95 @@ +import gql from 'graphql-tag'; +import { + createManyObjects, + successfulApiRequest, +} from 'test/utils/api-requests'; +import { generateRecordName } from 'test/utils/generate-record-name'; + +const deleteCompaniesQuery = gql` + mutation DeleteCompanies($filter: CompanyFilterInput) { + deleteCompanies(filter: $filter) { + deletedAt + } + } +`; + +const findCompaniesQuery = gql` + query Companies($filter: CompanyFilterInput) { + companies(filter: $filter) { + edges { + node { + id + } + } + } + } +`; + +describe('deleteCompaniesResolver (integration)', () => { + it('should delete companies and hide them from simple queries', async () => { + const companiesIds = await createManyObjects('Company', [ + { name: generateRecordName() }, + { name: generateRecordName() }, + ]); + + const filter = { + id: { + in: companiesIds, + }, + }; + + const deleteCompaniesQueryData = { + query: deleteCompaniesQuery, + variables: { + filter, + }, + }; + + const deleteCompaniesResponse = await successfulApiRequest( + deleteCompaniesQueryData, + ); + + const deleteCompanies = deleteCompaniesResponse.body.data.deleteCompanies; + + expect(deleteCompanies).toHaveLength(companiesIds.length); + + deleteCompanies.forEach((company) => { + expect(company.deletedAt).toBeTruthy(); + }); + + const findCompaniesQueryData = { + query: findCompaniesQuery, + variables: { + filter, + }, + }; + + const findCompaniesResponse = await successfulApiRequest( + findCompaniesQueryData, + ); + + expect(findCompaniesResponse.body.data.companies.edges).toHaveLength(0); + + const findDeletedCompaniesQueryData = { + query: findCompaniesQuery, + variables: { + filter: { + id: { + in: companiesIds, + }, + deletedAt: { + not: 'NULL', + }, + }, + }, + }; + + const findDeletedCompaniesResponse = await successfulApiRequest( + findDeletedCompaniesQueryData, + ); + + expect(findDeletedCompaniesResponse.body.data.companies.edges).toHaveLength( + companiesIds.length, + ); + }); +}); diff --git a/packages/twenty-server/test/companies/delete-one-company.integration-spec.ts b/packages/twenty-server/test/companies/delete-one-company.integration-spec.ts new file mode 100644 index 000000000000..70454eda8df5 --- /dev/null +++ b/packages/twenty-server/test/companies/delete-one-company.integration-spec.ts @@ -0,0 +1,108 @@ +import gql from 'graphql-tag'; +import { + apiRequest, + createOneObject, + successfulApiRequest, +} from 'test/utils/api-requests'; +import { generateRecordName } from 'test/utils/generate-record-name'; + +const deleteCompanyQuery = gql` + mutation DeleteCompany($companyId: ID!) { + deleteCompany(id: $companyId) { + deletedAt + } + } +`; + +const findCompanyQuery = gql` + query Company($filter: CompanyFilterInput) { + company(filter: $filter) { + id + } + } +`; + +const findCompaniesQuery = gql` + query Companies { + companies { + edges { + node { + id + } + } + } + } +`; + +describe('deleteCompanyResolver (integration)', () => { + it('should delete a company and hide it from simple queries', async () => { + const companyName = generateRecordName(); + const createdCompanyId = await createOneObject('Company', { + name: companyName, + }); + + const deleteCompanyQueryData = { + query: deleteCompanyQuery, + variables: { + companyId: createdCompanyId, + }, + }; + + const deleteCompanyResponse = await successfulApiRequest( + deleteCompanyQueryData, + ); + + expect( + deleteCompanyResponse.body.data.deleteCompany.deletedAt, + ).toBeTruthy(); + + const findCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + }, + }, + }; + + const findCompanyResponse = await apiRequest(findCompanyQueryData); + + expect(findCompanyResponse.body.data.company).toBeNull(); + + const findCompaniesResponse = await successfulApiRequest({ + query: findCompaniesQuery, + }); + + expect( + findCompaniesResponse.body.data.companies.edges.filter( + (c) => c.node.id === createdCompanyId, + ), + ).toHaveLength(0); + + const findDeletedCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }, + }; + + const findDeletedCompanyResponse = await apiRequest( + findDeletedCompanyQueryData, + ); + + expect(findDeletedCompanyResponse.body.data.company.id).toEqual( + createdCompanyId, + ); + }); +}); diff --git a/packages/twenty-server/test/companies/destroy-many-companies.integration-spec.ts b/packages/twenty-server/test/companies/destroy-many-companies.integration-spec.ts new file mode 100644 index 000000000000..e0c869020536 --- /dev/null +++ b/packages/twenty-server/test/companies/destroy-many-companies.integration-spec.ts @@ -0,0 +1,98 @@ +import gql from 'graphql-tag'; +import { + apiRequest, + createManyObjects, + successfulApiRequest, +} from 'test/utils/api-requests'; +import { generateRecordName } from 'test/utils/generate-record-name'; + +const destroyCompaniesQuery = gql` + mutation DestroyCompanies($filter: CompanyFilterInput) { + destroyCompanies(filter: $filter) { + deletedAt + } + } +`; + +const findCompaniesQuery = gql` + query Companies($filter: CompanyFilterInput) { + companies(filter: $filter) { + edges { + node { + id + } + } + } + } +`; + +describe('destroyCompaniesResolver (integration)', () => { + it('should destroy companies and hide them from simple queries', async () => { + const companiesIds = await createManyObjects('Company', [ + { name: generateRecordName() }, + { name: generateRecordName() }, + ]); + + const filter = { + id: { + in: companiesIds, + }, + }; + + const destroyCompaniesQueryData = { + query: destroyCompaniesQuery, + variables: { + filter, + }, + }; + + const destroyCompaniesResponse = await successfulApiRequest( + destroyCompaniesQueryData, + ); + + expect(destroyCompaniesResponse.body.data.destroyCompanies).toHaveLength( + companiesIds.length, + ); + + const findCompaniesQueryData = { + query: findCompaniesQuery, + variables: { + filter, + }, + }; + + const findCompaniesResponse = await successfulApiRequest( + findCompaniesQueryData, + ); + + expect( + findCompaniesResponse.body.data.companies.edges.filter((c) => + companiesIds.includes(c.node.id), + ), + ).toHaveLength(0); + + const findDeletedCompaniesQueryData = { + query: findCompaniesQuery, + variables: { + filter: { + id: { + in: companiesIds, + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }, + }; + + const findDeletedCompaniesResponse = await apiRequest( + findDeletedCompaniesQueryData, + ); + + expect(findDeletedCompaniesResponse.body.data.companies.edges).toHaveLength( + 0, + ); + }); +}); diff --git a/packages/twenty-server/test/companies/destroy-one-company.integration-spec.ts b/packages/twenty-server/test/companies/destroy-one-company.integration-spec.ts new file mode 100644 index 000000000000..cf80298706f6 --- /dev/null +++ b/packages/twenty-server/test/companies/destroy-one-company.integration-spec.ts @@ -0,0 +1,104 @@ +import gql from 'graphql-tag'; +import { + apiRequest, + createOneObject, + successfulApiRequest, +} from 'test/utils/api-requests'; +import { generateRecordName } from 'test/utils/generate-record-name'; + +const destroyCompanyQuery = gql` + mutation DestroyCompany($companyId: ID!) { + destroyCompany(id: $companyId) { + deletedAt + } + } +`; + +const findCompanyQuery = gql` + query Company($filter: CompanyFilterInput) { + company(filter: $filter) { + id + } + } +`; + +const findCompaniesQuery = gql` + query Companies { + companies { + edges { + node { + id + } + } + } + } +`; + +describe('destroyCompanyResolver (integration)', () => { + it('should destroy a company and hide it from simple queries', async () => { + const companyName = generateRecordName(); + const createdCompanyId = await createOneObject('Company', { + name: companyName, + }); + + const destroyCompanyQueryData = { + query: destroyCompanyQuery, + variables: { + companyId: createdCompanyId, + }, + }; + + const destroyCompanyResponse = await successfulApiRequest( + destroyCompanyQueryData, + ); + + expect(destroyCompanyResponse.body.data.destroyCompany).toBeTruthy(); + + const findCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + }, + }, + }; + + const findCompanyResponse = await apiRequest(findCompanyQueryData); + + expect(findCompanyResponse.body.data.company).toBeNull(); + + const findCompaniesResponse = await successfulApiRequest({ + query: findCompaniesQuery, + }); + + expect( + findCompaniesResponse.body.data.companies.edges.filter( + (c) => c.node.id === createdCompanyId, + ), + ).toHaveLength(0); + + const findDeletedCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }, + }; + + const findDeletedCompanyResponse = await apiRequest( + findDeletedCompanyQueryData, + ); + + expect(findDeletedCompanyResponse.body.data.company).toBeNull(); + }); +}); diff --git a/packages/twenty-server/test/companies/find-many-companies.integration-spec.ts b/packages/twenty-server/test/companies/find-many-companies.integration-spec.ts new file mode 100644 index 000000000000..6ec9d209fd35 --- /dev/null +++ b/packages/twenty-server/test/companies/find-many-companies.integration-spec.ts @@ -0,0 +1,57 @@ +import gql from 'graphql-tag'; +import { successfulApiRequest } from 'test/utils/api-requests'; + +describe('companiesResolver (integration)', () => { + it('should find many companies', () => { + const queryData = { + query: gql` + query companies { + companies { + edges { + node { + name + employees + idealCustomerProfile + position + id + createdAt + updatedAt + deletedAt + accountOwnerId + tagline + workPolicy + visaSponsorship + } + } + } + } + `, + }; + + return successfulApiRequest(queryData).expect((res) => { + const data = res.body.data.companies; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const companies = edges[0].node; + + expect(companies).toHaveProperty('name'); + expect(companies).toHaveProperty('employees'); + expect(companies).toHaveProperty('idealCustomerProfile'); + expect(companies).toHaveProperty('position'); + expect(companies).toHaveProperty('id'); + expect(companies).toHaveProperty('createdAt'); + expect(companies).toHaveProperty('updatedAt'); + expect(companies).toHaveProperty('deletedAt'); + expect(companies).toHaveProperty('accountOwnerId'); + expect(companies).toHaveProperty('tagline'); + expect(companies).toHaveProperty('workPolicy'); + expect(companies).toHaveProperty('visaSponsorship'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/companies/find-one-company.integration-spec.ts b/packages/twenty-server/test/companies/find-one-company.integration-spec.ts new file mode 100644 index 000000000000..b054ecc19027 --- /dev/null +++ b/packages/twenty-server/test/companies/find-one-company.integration-spec.ts @@ -0,0 +1,60 @@ +import gql from 'graphql-tag'; +import { createOneObject, successfulApiRequest } from 'test/utils/api-requests'; +import { generateRecordName } from 'test/utils/generate-record-name'; + +const findOneCompanyQuery = gql` + query Company($filter: CompanyFilterInput) { + company(filter: $filter) { + name + employees + idealCustomerProfile + position + id + createdAt + updatedAt + deletedAt + accountOwnerId + tagline + workPolicy + visaSponsorship + } + } +`; + +describe('findOneCompanyResolver (integration)', () => { + it('should find one company', async () => { + const companyName = generateRecordName(); + const createdCompanyId = await createOneObject('Company', { + name: companyName, + }); + const findOneCompanyQueryData = { + query: findOneCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + }, + }, + }; + + successfulApiRequest(findOneCompanyQueryData).expect((res) => { + const company = res.body.data.company; + + expect(company).toHaveProperty('name'); + expect(company.name).toEqual(companyName); + + expect(company).toHaveProperty('employees'); + expect(company).toHaveProperty('idealCustomerProfile'); + expect(company).toHaveProperty('position'); + expect(company).toHaveProperty('id'); + expect(company).toHaveProperty('createdAt'); + expect(company).toHaveProperty('updatedAt'); + expect(company).toHaveProperty('deletedAt'); + expect(company).toHaveProperty('accountOwnerId'); + expect(company).toHaveProperty('tagline'); + expect(company).toHaveProperty('workPolicy'); + expect(company).toHaveProperty('visaSponsorship'); + }); + }); +}); diff --git a/packages/twenty-server/test/companies/person-company-relation.integration-spec.ts b/packages/twenty-server/test/companies/person-company-relation.integration-spec.ts new file mode 100644 index 000000000000..a067ba004219 --- /dev/null +++ b/packages/twenty-server/test/companies/person-company-relation.integration-spec.ts @@ -0,0 +1,111 @@ +import gql from 'graphql-tag'; +import { createOneObject, successfulApiRequest } from 'test/utils/api-requests'; +import { generateRecordName } from 'test/utils/generate-record-name'; + +const updatePersonQuery = gql` + mutation UpdatePerson($personId: ID!, $data: PersonUpdateInput!) { + updatePerson(id: $personId, data: $data) { + id + } + } +`; + +const findCompanyQuery = gql` + query Company($filter: CompanyFilterInput) { + company(filter: $filter) { + people { + edges { + node { + id + name { + firstName + } + companyId + } + } + } + } + } +`; + +const findPersonQuery = gql` + query Person($filter: PersonFilterInput) { + person(filter: $filter) { + company { + id + name + } + } + } +`; + +describe('personCompanyRelationResolver (integration)', () => { + it('should create a company and a person and then update the person with companyId and query the company with person data', async () => { + const companyName = generateRecordName(); + const companyId = await createOneObject('Company', { + name: companyName, + }); + + const personName = generateRecordName(); + const personId = await createOneObject('Person', { + name: { + firstName: personName, + }, + }); + + await successfulApiRequest({ + query: updatePersonQuery, + variables: { + personId, + data: { + companyId, + }, + }, + }); + + const findCompanyResponse = await successfulApiRequest({ + query: findCompanyQuery, + variables: { + filter: { + id: { eq: companyId }, + }, + }, + }); + + const findPersonResponse = await successfulApiRequest({ + query: findPersonQuery, + variables: { + filter: { + id: { eq: personId }, + }, + }, + }); + + expect(findCompanyResponse.body.data.company).toEqual( + expect.objectContaining({ + people: { + edges: [ + { + node: { + id: personId, + companyId, + name: { + firstName: personName, + }, + }, + }, + ], + }, + }), + ); + + expect(findPersonResponse.body.data.person).toEqual( + expect.objectContaining({ + company: { + id: companyId, + name: companyName, + }, + }), + ); + }); +}); diff --git a/packages/twenty-server/test/companies/update-many-companies.integration-spec.ts b/packages/twenty-server/test/companies/update-many-companies.integration-spec.ts new file mode 100644 index 000000000000..8dd3568f733c --- /dev/null +++ b/packages/twenty-server/test/companies/update-many-companies.integration-spec.ts @@ -0,0 +1,85 @@ +import gql from 'graphql-tag'; +import { + createManyObjects, + successfulApiRequest, +} from 'test/utils/api-requests'; +import { generateRecordName } from 'test/utils/generate-record-name'; + +const updateCompaniesQuery = gql` + mutation UpdateCompanies( + $data: CompanyUpdateInput + $filter: CompanyFilterInput + ) { + updateCompanies(data: $data, filter: $filter) { + id + name + } + } +`; + +const findCompaniesQuery = gql` + query Companies($filter: CompanyFilterInput) { + companies(filter: $filter) { + edges { + node { + id + name + } + } + } + } +`; + +describe('updateCompaniesResolver (integration)', () => { + it('should update companies and persist the changes', async () => { + const companiesIds = await createManyObjects('Company', [ + { name: generateRecordName() }, + { name: generateRecordName() }, + ]); + + const filter = { + id: { + in: companiesIds, + }, + }; + + const newName = generateRecordName(); + const updateCompaniesQueryData = { + query: updateCompaniesQuery, + variables: { + data: { + name: newName, + }, + filter, + }, + }; + + const updateCompaniesResponse = await successfulApiRequest( + updateCompaniesQueryData, + ); + + expect(updateCompaniesResponse.body.data.updateCompanies).toHaveLength( + companiesIds.length, + ); + + const findCompaniesQueryData = { + query: findCompaniesQuery, + variables: { + filter, + }, + }; + + const findCompaniesResponse = await successfulApiRequest( + findCompaniesQueryData, + ); + + const edges = findCompaniesResponse.body.data.companies.edges; + + expect(edges).toHaveLength(companiesIds.length); + + edges.forEach((edge) => { + expect(edge.node.name).toEqual(newName); + expect(companiesIds).toContain(edge.node.id); + }); + }); +}); diff --git a/packages/twenty-server/test/companies/update-one-company.integration-spec.ts b/packages/twenty-server/test/companies/update-one-company.integration-spec.ts new file mode 100644 index 000000000000..1a911b6f7f1c --- /dev/null +++ b/packages/twenty-server/test/companies/update-one-company.integration-spec.ts @@ -0,0 +1,62 @@ +import gql from 'graphql-tag'; +import { createOneObject, successfulApiRequest } from 'test/utils/api-requests'; +import { generateRecordName } from 'test/utils/generate-record-name'; + +const updateCompanyQuery = gql` + mutation UpdateCompany($companyId: ID, $data: CompanyUpdateInput) { + updateCompany(id: $companyId, data: $data) { + name + } + } +`; + +const findCompanyQuery = gql` + query Company($filter: CompanyFilterInput) { + company(filter: $filter) { + name + } + } +`; + +describe('updateCompanyResolver (integration)', () => { + it('should update and persist the company update', async () => { + const companyName = generateRecordName(); + const createdCompanyId = await createOneObject('Company', { + name: companyName, + }); + const updateCompanyQueryData = { + query: updateCompanyQuery, + variables: { + companyId: createdCompanyId, + data: { + name: companyName, + }, + }, + }; + + successfulApiRequest(updateCompanyQueryData).expect((res) => { + const updatedCompany = res.body.data.updateCompany; + + expect(updatedCompany).toHaveProperty('name'); + expect(updatedCompany.name).toEqual(companyName); + }); + + const findCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + }, + }, + }; + + successfulApiRequest(findCompanyQueryData).expect((res) => { + const company = res.body.data.company; + + expect(company).toHaveProperty('name'); + expect(company.name).toEqual(companyName); + }); + }); +}); diff --git a/packages/twenty-server/test/company.integration-spec.ts b/packages/twenty-server/test/company.integration-spec.ts deleted file mode 100644 index bd25d66eb4dc..000000000000 --- a/packages/twenty-server/test/company.integration-spec.ts +++ /dev/null @@ -1,48 +0,0 @@ -import request from 'supertest'; - -const graphqlClient = request(`http://localhost:${APP_PORT}`); - -describe('CompanyResolver (integration)', () => { - it('should find many companies', () => { - const queryData = { - query: ` - query Companies { - companies { - edges { - node { - id - name - } - } - } - } - `, - }; - - return graphqlClient - .post('/graphql') - .set('Authorization', `Bearer ${ACCESS_TOKEN}`) - .send(queryData) - .expect(200) - .expect((res) => { - expect(res.body.data).toBeDefined(); - expect(res.body.errors).toBeUndefined(); - }) - .expect((res) => { - const data = res.body.data.companies; - - expect(data).toBeDefined(); - expect(Array.isArray(data.edges)).toBe(true); - - const edges = data.edges; - - if (edges.length > 0) { - const company = edges[0].node; - - expect(company).toBeDefined(); - expect(company).toHaveProperty('id'); - expect(company).toHaveProperty('name'); - } - }); - }); -}); diff --git a/packages/twenty-server/test/utils/api-requests.ts b/packages/twenty-server/test/utils/api-requests.ts new file mode 100644 index 000000000000..799cffb19b4b --- /dev/null +++ b/packages/twenty-server/test/utils/api-requests.ts @@ -0,0 +1,80 @@ +import { ASTNode, print } from 'graphql'; +import gql from 'graphql-tag'; +import pluralize from 'pluralize'; +import request from 'supertest'; + +type QueryData = { + query: ASTNode; + variables?: Record; +}; + +type StandardObjectsSingularName = 'Company' | 'Person'; + +export const apiRequest = (data: QueryData) => { + const client = request(`http://localhost:${APP_PORT}`); + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send({ query: print(data.query), variables: data.variables || {} }); +}; + +export const successfulApiRequest = (data: QueryData) => { + return apiRequest(data).expect((res) => { + expect(res.body.errors).toBeUndefined(); + expect(res.body.data).toBeDefined(); + }); +}; + +export const createOneObject = async ( + ObjectSingularName: StandardObjectsSingularName, + data: object, +) => { + const mutationName = `create${ObjectSingularName}`; + + const query = gql` + mutation Create${ObjectSingularName}($data: ${ObjectSingularName}CreateInput) { + ${mutationName}(data: $data) { + id + } + } + `; + + const variables = { + data, + }; + + return await successfulApiRequest({ query, variables }).then((res) => { + const createdObject = res.body.data[mutationName]; + + return createdObject.id as string; + }); +}; + +export const createManyObjects = async ( + ObjectSingularName: StandardObjectsSingularName, + data: object[], +) => { + const objectPluralName = pluralize(ObjectSingularName); + const mutationName = `create${objectPluralName}`; + + const query = gql` + mutation Create${objectPluralName}($data: [${ObjectSingularName}CreateInput!]) { + ${mutationName}(data: $data) { + id + } + } + `; + + const variables = { + data, + }; + + return await successfulApiRequest({ query, variables }).then((res) => { + const createdObjectsIds: string[] = res.body.data[mutationName].map( + (object) => object.id, + ); + + return createdObjectsIds; + }); +}; diff --git a/packages/twenty-server/test/utils/generate-record-name.ts b/packages/twenty-server/test/utils/generate-record-name.ts new file mode 100644 index 000000000000..fc71362273b6 --- /dev/null +++ b/packages/twenty-server/test/utils/generate-record-name.ts @@ -0,0 +1,4 @@ +export const TEST_NAME_PREFIX = 'integration_test_record_'; + +export const generateRecordName = () => + `${TEST_NAME_PREFIX}${Math.floor(Math.random() * 1000)}`; diff --git a/packages/twenty-server/test/utils/teardown-test.ts b/packages/twenty-server/test/utils/teardown-test.ts index 8cc1946d5053..d0e1a59d741f 100644 --- a/packages/twenty-server/test/utils/teardown-test.ts +++ b/packages/twenty-server/test/utils/teardown-test.ts @@ -1,5 +1,51 @@ +import gql from 'graphql-tag'; +import { apiRequest } from 'test/utils/api-requests'; +import { TEST_NAME_PREFIX } from 'test/utils/generate-record-name'; import 'tsconfig-paths/register'; +// eslint-disable-next-line no-restricted-imports +import jestConfig from '../../jest-integration.config'; + +const query = gql` + mutation DestroyObjects( + $nameFilter: CompanyFilterInput + $personFilter: PersonFilterInput + ) { + destroyCompanies(filter: $nameFilter) { + id + } + destroyPeople(filter: $personFilter) { + id + } + } +`; +const nameFilter = { + name: { + ilike: `%${TEST_NAME_PREFIX}%`, + }, +}; + +const personFilter = { + name: { + firstName: { + ilike: `%${TEST_NAME_PREFIX}%`, + }, + }, +}; + export default async () => { - global.app.close(); + // @ts-expect-error in the teardown this env is not present in the global object anymore + global.APP_PORT = jestConfig.globals?.APP_PORT; + // @ts-expect-error in the teardown this env is not present in the global object anymore + global.ACCESS_TOKEN = jestConfig.globals?.ACCESS_TOKEN; + apiRequest({ + query, + variables: { + nameFilter, + personFilter, + }, + }).then((res) => { + if (res.body.errors) throw new Error(JSON.stringify(res.body.errors)); + global.app.close(); + }); }; From 5c7a74073a95049428f4848fae6005dcb05f5f7f Mon Sep 17 00:00:00 2001 From: gitstart-twenty Date: Wed, 16 Oct 2024 13:02:57 +0000 Subject: [PATCH 2/7] move the tests to one test file, and rename functions --- .../companies.integration-constants.ts | 159 +++++ .../companies/companies.integration-spec.ts | 628 ++++++++++++++++++ .../create-many-companies.integration-spec.ts | 64 -- .../create-one-company.integration-spec.ts | 55 -- .../delete-many-companies.integration.ts | 95 --- .../delete-one-company.integration-spec.ts | 108 --- ...destroy-many-companies.integration-spec.ts | 98 --- .../destroy-one-company.integration-spec.ts | 104 --- .../find-many-companies.integration-spec.ts | 57 -- .../find-one-company.integration-spec.ts | 60 -- ...erson-company-relation.integration-spec.ts | 111 ---- .../update-many-companies.integration-spec.ts | 85 --- .../update-one-company.integration-spec.ts | 62 -- .../twenty-server/test/utils/api-requests.ts | 30 +- .../twenty-server/test/utils/teardown-test.ts | 4 +- 15 files changed, 806 insertions(+), 914 deletions(-) create mode 100644 packages/twenty-server/test/companies/companies.integration-constants.ts create mode 100644 packages/twenty-server/test/companies/companies.integration-spec.ts delete mode 100644 packages/twenty-server/test/companies/create-many-companies.integration-spec.ts delete mode 100644 packages/twenty-server/test/companies/create-one-company.integration-spec.ts delete mode 100644 packages/twenty-server/test/companies/delete-many-companies.integration.ts delete mode 100644 packages/twenty-server/test/companies/delete-one-company.integration-spec.ts delete mode 100644 packages/twenty-server/test/companies/destroy-many-companies.integration-spec.ts delete mode 100644 packages/twenty-server/test/companies/destroy-one-company.integration-spec.ts delete mode 100644 packages/twenty-server/test/companies/find-many-companies.integration-spec.ts delete mode 100644 packages/twenty-server/test/companies/find-one-company.integration-spec.ts delete mode 100644 packages/twenty-server/test/companies/person-company-relation.integration-spec.ts delete mode 100644 packages/twenty-server/test/companies/update-many-companies.integration-spec.ts delete mode 100644 packages/twenty-server/test/companies/update-one-company.integration-spec.ts diff --git a/packages/twenty-server/test/companies/companies.integration-constants.ts b/packages/twenty-server/test/companies/companies.integration-constants.ts new file mode 100644 index 000000000000..fa4463186541 --- /dev/null +++ b/packages/twenty-server/test/companies/companies.integration-constants.ts @@ -0,0 +1,159 @@ +import gql from 'graphql-tag'; + +const companyProperties = ` + id + name + employees + idealCustomerProfile + position + createdAt + updatedAt + deletedAt + accountOwnerId + tagline + workPolicy + visaSponsorship +`; + +export const findCompanyQuery = gql` + query Company($filter: CompanyFilterInput) { + company(filter: $filter) { + ${companyProperties} + } + } +`; + +export const findCompaniesWithFilterQuery = gql` + query Companies($filter: CompanyFilterInput) { + companies(filter: $filter) { + edges { + node { + ${companyProperties} + } + } + } + } +`; + +export const createCompaniesMutation = gql` + mutation CreateCompanies($data: [CompanyCreateInput!]!) { + createCompanies(data: $data) { + ${companyProperties} + } + } +`; + +export const createCompanyMutation = gql` + mutation CreateCompany($data: CompanyCreateInput) { + createCompany(data: $data) { + ${companyProperties} + } + } +`; + +export const deleteCompaniesMutation = gql` + mutation DeleteCompanies($filter: CompanyFilterInput) { + deleteCompanies(filter: $filter) { + deletedAt + } + } +`; + +export const deleteCompanyMutation = gql` + mutation DeleteCompany($companyId: ID!) { + deleteCompany(id: $companyId) { + deletedAt + } + } +`; + +export const destroyCompaniesMutation = gql` + mutation DestroyCompanies($filter: CompanyFilterInput) { + destroyCompanies(filter: $filter) { + deletedAt + } + } +`; +export const destroyCompanyMutation = gql` + mutation DestroyCompany($companyId: ID!) { + destroyCompany(id: $companyId) { + deletedAt + } + } +`; +export const updatePersonMutation = gql` + mutation UpdatePerson($personId: ID!, $data: PersonUpdateInput!) { + updatePerson(id: $personId, data: $data) { + id + } + } +`; + +export const findCompanyWithPeopleRelationQuery = gql` + query Company($filter: CompanyFilterInput) { + company(filter: $filter) { + people { + edges { + node { + id + name { + firstName + } + companyId + } + } + } + } + } +`; + +export const findPersonWithCompanyRelationQuery = gql` + query Person($filter: PersonFilterInput) { + person(filter: $filter) { + company { + id + name + } + } + } +`; + +export const updateCompaniesMutation = gql` + mutation UpdateCompanies( + $data: CompanyUpdateInput + $filter: CompanyFilterInput + ) { + updateCompanies(data: $data, filter: $filter) { + id + name + } + } +`; + +export const findAllCompaniesQuery = gql` + query Companies { + companies { + edges { + node { + ${companyProperties} + } + } + } + } +`; + +export const updateCompanyMutation = gql` + mutation UpdateCompany($companyId: ID, $data: CompanyUpdateInput) { + updateCompany(id: $companyId, data: $data) { + name + } + } +`; + +export const findCompanyWithFilterQuery = gql` + query Company($filter: CompanyFilterInput) { + company(filter: $filter) { + ${companyProperties} + } + } +`; diff --git a/packages/twenty-server/test/companies/companies.integration-spec.ts b/packages/twenty-server/test/companies/companies.integration-spec.ts new file mode 100644 index 000000000000..b28c8e4deefe --- /dev/null +++ b/packages/twenty-server/test/companies/companies.integration-spec.ts @@ -0,0 +1,628 @@ +import { + createCompaniesMutation, + createCompanyMutation, + deleteCompaniesMutation, + deleteCompanyMutation, + destroyCompaniesMutation, + destroyCompanyMutation, + findAllCompaniesQuery, + findCompaniesWithFilterQuery, + findCompanyQuery, + findCompanyWithFilterQuery, + findCompanyWithPeopleRelationQuery, + findPersonWithCompanyRelationQuery, + updateCompaniesMutation, + updatePersonMutation, +} from 'test/companies/companies.integration-constants'; +import { + createManyObjects, + createOneObject, + expectSuccessfullGraphqlAPIRequest, + makeGraphqlAPIRequest, +} from 'test/utils/api-requests'; +import { generateRecordName } from 'test/utils/generate-record-name'; + +describe('companies resolvers (integration)', () => { + describe('createCompaniesResolver (integration)', () => { + it('should create and return companies', async () => { + const companyName1 = generateRecordName(); + const companyName2 = generateRecordName(); + + const queryData = { + query: createCompaniesMutation, + variables: { + data: [ + { + name: companyName1, + }, + { + name: companyName2, + }, + ], + }, + }; + + const createdCompanies = + await expectSuccessfullGraphqlAPIRequest(queryData); + + expect(createdCompanies.body.data.createCompanies).toHaveLength(2); + + createdCompanies.body.data.createCompanies.forEach((company) => { + expect(company).toHaveProperty('name'); + expect([companyName1, companyName2]).toContain(company.name); + + expect(company).toHaveProperty('employees'); + expect(company).toHaveProperty('idealCustomerProfile'); + expect(company).toHaveProperty('position'); + expect(company).toHaveProperty('id'); + expect(company).toHaveProperty('createdAt'); + expect(company).toHaveProperty('updatedAt'); + expect(company).toHaveProperty('deletedAt'); + expect(company).toHaveProperty('accountOwnerId'); + expect(company).toHaveProperty('tagline'); + expect(company).toHaveProperty('workPolicy'); + expect(company).toHaveProperty('visaSponsorship'); + }); + }); + }); + + describe('createCompanyResolver (integration)', () => { + it('should create and return a company', () => { + const companyName = generateRecordName(); + const queryData = { + query: createCompanyMutation, + variables: { + data: { + name: companyName, + }, + }, + }; + + return expectSuccessfullGraphqlAPIRequest(queryData).expect((res) => { + const createdCompany = res.body.data.createCompany; + + expect(createdCompany).toHaveProperty('name'); + expect(createdCompany.name).toEqual(companyName); + + expect(createdCompany).toHaveProperty('employees'); + expect(createdCompany).toHaveProperty('idealCustomerProfile'); + expect(createdCompany).toHaveProperty('position'); + expect(createdCompany).toHaveProperty('id'); + expect(createdCompany).toHaveProperty('createdAt'); + expect(createdCompany).toHaveProperty('updatedAt'); + expect(createdCompany).toHaveProperty('deletedAt'); + expect(createdCompany).toHaveProperty('accountOwnerId'); + expect(createdCompany).toHaveProperty('tagline'); + expect(createdCompany).toHaveProperty('workPolicy'); + expect(createdCompany).toHaveProperty('visaSponsorship'); + }); + }); + }); + + describe('deleteCompaniesResolver (integration)', () => { + it('should delete companies and hide them from simple queries', async () => { + const companiesIds = await createManyObjects('Company', [ + { name: generateRecordName() }, + { name: generateRecordName() }, + ]); + + const filter = { + id: { + in: companiesIds, + }, + }; + + const deleteCompaniesQueryData = { + query: deleteCompaniesMutation, + variables: { + filter, + }, + }; + + const deleteCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + deleteCompaniesQueryData, + ); + + const deleteCompanies = deleteCompaniesResponse.body.data.deleteCompanies; + + expect(deleteCompanies).toHaveLength(companiesIds.length); + + deleteCompanies.forEach((company) => { + expect(company.deletedAt).toBeTruthy(); + }); + + const findCompaniesQueryData = { + query: findCompaniesWithFilterQuery, + variables: { + filter, + }, + }; + + const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + findCompaniesQueryData, + ); + + expect(findCompaniesResponse.body.data.companies.edges).toHaveLength(0); + + const findDeletedCompaniesQueryData = { + query: findCompaniesWithFilterQuery, + variables: { + filter: { + id: { + in: companiesIds, + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }, + }; + + const findDeletedCompaniesResponse = + await expectSuccessfullGraphqlAPIRequest(findDeletedCompaniesQueryData); + + expect( + findDeletedCompaniesResponse.body.data.companies.edges, + ).toHaveLength(companiesIds.length); + }); + }); + + describe('deleteCompanyResolver (integration)', () => { + it('should delete a company and hide it from simple queries', async () => { + const companyName = generateRecordName(); + const createdCompanyId = await createOneObject('Company', { + name: companyName, + }); + + const deleteCompanyQueryData = { + query: deleteCompanyMutation, + variables: { + companyId: createdCompanyId, + }, + }; + + const deleteCompanyResponse = await expectSuccessfullGraphqlAPIRequest( + deleteCompanyQueryData, + ); + + expect( + deleteCompanyResponse.body.data.deleteCompany.deletedAt, + ).toBeTruthy(); + + const findCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + }, + }, + }; + + const findCompanyResponse = + await makeGraphqlAPIRequest(findCompanyQueryData); + + expect(findCompanyResponse.body.data.company).toBeNull(); + + const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest({ + query: findCompaniesWithFilterQuery, + }); + + expect( + findCompaniesResponse.body.data.companies.edges.filter( + (c) => c.node.id === createdCompanyId, + ), + ).toHaveLength(0); + + const findDeletedCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }, + }; + + const findDeletedCompanyResponse = await makeGraphqlAPIRequest( + findDeletedCompanyQueryData, + ); + + expect(findDeletedCompanyResponse.body.data.company.id).toEqual( + createdCompanyId, + ); + }); + }); + + describe('destroyCompaniesResolver (integration)', () => { + it('should destroy companies and hide them from simple queries', async () => { + const companiesIds = await createManyObjects('Company', [ + { name: generateRecordName() }, + { name: generateRecordName() }, + ]); + + const filter = { + id: { + in: companiesIds, + }, + }; + + const destroyCompaniesQueryData = { + query: destroyCompaniesMutation, + variables: { + filter, + }, + }; + + const destroyCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + destroyCompaniesQueryData, + ); + + expect(destroyCompaniesResponse.body.data.destroyCompanies).toHaveLength( + companiesIds.length, + ); + + const findCompaniesQueryData = { + query: findCompaniesWithFilterQuery, + variables: { + filter, + }, + }; + + const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + findCompaniesQueryData, + ); + + expect( + findCompaniesResponse.body.data.companies.edges.filter((c) => + companiesIds.includes(c.node.id), + ), + ).toHaveLength(0); + + const findDeletedCompaniesQueryData = { + query: findCompaniesWithFilterQuery, + variables: { + filter: { + id: { + in: companiesIds, + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }, + }; + + const findDeletedCompaniesResponse = await makeGraphqlAPIRequest( + findDeletedCompaniesQueryData, + ); + + expect( + findDeletedCompaniesResponse.body.data.companies.edges, + ).toHaveLength(0); + }); + }); + + describe('destroyCompanyResolver (integration)', () => { + it('should destroy a company and hide it from simple queries', async () => { + const companyName = generateRecordName(); + const createdCompanyId = await createOneObject('Company', { + name: companyName, + }); + + const destroyCompanyQueryData = { + query: destroyCompanyMutation, + variables: { + companyId: createdCompanyId, + }, + }; + + const destroyCompanyResponse = await expectSuccessfullGraphqlAPIRequest( + destroyCompanyQueryData, + ); + + expect(destroyCompanyResponse.body.data.destroyCompany).toBeTruthy(); + + const findCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + }, + }, + }; + + const findCompanyResponse = + await makeGraphqlAPIRequest(findCompanyQueryData); + + expect(findCompanyResponse.body.data.company).toBeNull(); + + const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest({ + query: findCompaniesWithFilterQuery, + }); + + expect( + findCompaniesResponse.body.data.companies.edges.filter( + (c) => c.node.id === createdCompanyId, + ), + ).toHaveLength(0); + + const findDeletedCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }, + }; + + const findDeletedCompanyResponse = await makeGraphqlAPIRequest( + findDeletedCompanyQueryData, + ); + + expect(findDeletedCompanyResponse.body.data.company).toBeNull(); + }); + }); + + describe('companiesResolver (integration)', () => { + it('should find many companies', () => { + return expectSuccessfullGraphqlAPIRequest({ + query: findAllCompaniesQuery, + }).expect((res) => { + const data = res.body.data.companies; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const companies = edges[0].node; + + expect(companies).toHaveProperty('name'); + expect(companies).toHaveProperty('employees'); + expect(companies).toHaveProperty('idealCustomerProfile'); + expect(companies).toHaveProperty('position'); + expect(companies).toHaveProperty('id'); + expect(companies).toHaveProperty('createdAt'); + expect(companies).toHaveProperty('updatedAt'); + expect(companies).toHaveProperty('deletedAt'); + expect(companies).toHaveProperty('accountOwnerId'); + expect(companies).toHaveProperty('tagline'); + expect(companies).toHaveProperty('workPolicy'); + expect(companies).toHaveProperty('visaSponsorship'); + } + }); + }); + }); + + describe('findOneCompanyResolver (integration)', () => { + it('should find one company', async () => { + const companyName = generateRecordName(); + const createdCompanyId = await createOneObject('Company', { + name: companyName, + }); + const findOneCompanyQueryData = { + query: findCompanyWithFilterQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + }, + }, + }; + + expectSuccessfullGraphqlAPIRequest(findOneCompanyQueryData).expect( + (res) => { + const company = res.body.data.company; + + expect(company).toHaveProperty('name'); + expect(company.name).toEqual(companyName); + + expect(company).toHaveProperty('employees'); + expect(company).toHaveProperty('idealCustomerProfile'); + expect(company).toHaveProperty('position'); + expect(company).toHaveProperty('id'); + expect(company).toHaveProperty('createdAt'); + expect(company).toHaveProperty('updatedAt'); + expect(company).toHaveProperty('deletedAt'); + expect(company).toHaveProperty('accountOwnerId'); + expect(company).toHaveProperty('tagline'); + expect(company).toHaveProperty('workPolicy'); + expect(company).toHaveProperty('visaSponsorship'); + }, + ); + }); + }); + + describe('personCompanyRelationResolver (integration)', () => { + it('should create a company and a person and then update the person with companyId and query the company with person data', async () => { + const companyName = generateRecordName(); + const companyId = await createOneObject('Company', { + name: companyName, + }); + + const personName = generateRecordName(); + const personId = await createOneObject('Person', { + name: { + firstName: personName, + }, + }); + + await expectSuccessfullGraphqlAPIRequest({ + query: updatePersonMutation, + variables: { + personId, + data: { + companyId, + }, + }, + }); + + const findCompanyResponse = await expectSuccessfullGraphqlAPIRequest({ + query: findCompanyWithPeopleRelationQuery, + variables: { + filter: { + id: { eq: companyId }, + }, + }, + }); + + const findPersonResponse = await expectSuccessfullGraphqlAPIRequest({ + query: findPersonWithCompanyRelationQuery, + variables: { + filter: { + id: { eq: personId }, + }, + }, + }); + + expect(findCompanyResponse.body.data.company).toEqual( + expect.objectContaining({ + people: { + edges: [ + { + node: { + id: personId, + companyId, + name: { + firstName: personName, + }, + }, + }, + ], + }, + }), + ); + + expect(findPersonResponse.body.data.person).toEqual( + expect.objectContaining({ + company: { + id: companyId, + name: companyName, + }, + }), + ); + }); + }); + + describe('updateCompaniesResolver (integration)', () => { + it('should update companies and persist the changes', async () => { + const companiesIds = await createManyObjects('Company', [ + { name: generateRecordName() }, + { name: generateRecordName() }, + ]); + + const filter = { + id: { + in: companiesIds, + }, + }; + + const newName = generateRecordName(); + const updateCompaniesQueryData = { + query: updateCompaniesMutation, + variables: { + data: { + name: newName, + }, + filter, + }, + }; + + const updateCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + updateCompaniesQueryData, + ); + + expect(updateCompaniesResponse.body.data.updateCompanies).toHaveLength( + companiesIds.length, + ); + + const findCompaniesQueryData = { + query: findCompaniesWithFilterQuery, + variables: { + filter, + }, + }; + + const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + findCompaniesQueryData, + ); + + const edges = findCompaniesResponse.body.data.companies.edges; + + expect(edges).toHaveLength(companiesIds.length); + + edges.forEach((edge) => { + expect(edge.node.name).toEqual(newName); + expect(companiesIds).toContain(edge.node.id); + }); + }); + }); + + describe('updateCompanyResolver (integration)', () => { + it('should update and persist the company update', async () => { + const companyName = generateRecordName(); + const createdCompanyId = await createOneObject('Company', { + name: companyName, + }); + const updateCompanyQueryData = { + query: updateCompaniesMutation, + variables: { + companyId: createdCompanyId, + data: { + name: companyName, + }, + }, + }; + + expectSuccessfullGraphqlAPIRequest(updateCompanyQueryData).expect( + (res) => { + const updatedCompany = res.body.data.updateCompany; + + expect(updatedCompany).toHaveProperty('name'); + expect(updatedCompany.name).toEqual(companyName); + }, + ); + + const findCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + }, + }, + }; + + expectSuccessfullGraphqlAPIRequest(findCompanyQueryData).expect((res) => { + const company = res.body.data.company; + + expect(company).toHaveProperty('name'); + expect(company.name).toEqual(companyName); + }); + }); + }); +}); diff --git a/packages/twenty-server/test/companies/create-many-companies.integration-spec.ts b/packages/twenty-server/test/companies/create-many-companies.integration-spec.ts deleted file mode 100644 index 7149bff58b1e..000000000000 --- a/packages/twenty-server/test/companies/create-many-companies.integration-spec.ts +++ /dev/null @@ -1,64 +0,0 @@ -import gql from 'graphql-tag'; -import { successfulApiRequest } from 'test/utils/api-requests'; -import { generateRecordName } from 'test/utils/generate-record-name'; - -const createCompaniesQuery = gql` - mutation CreateCompanies($data: [CompanyCreateInput!]!) { - createCompanies(data: $data) { - id - name - employees - idealCustomerProfile - position - createdAt - updatedAt - deletedAt - accountOwnerId - tagline - workPolicy - visaSponsorship - } - } -`; - -describe('createCompaniesResolver (integration)', () => { - it('should create and return companies', async () => { - const companyName1 = generateRecordName(); - const companyName2 = generateRecordName(); - - const queryData = { - query: createCompaniesQuery, - variables: { - data: [ - { - name: companyName1, - }, - { - name: companyName2, - }, - ], - }, - }; - - const createdCompanies = await successfulApiRequest(queryData); - - expect(createdCompanies.body.data.createCompanies).toHaveLength(2); - - createdCompanies.body.data.createCompanies.forEach((company) => { - expect(company).toHaveProperty('name'); - expect([companyName1, companyName2]).toContain(company.name); - - expect(company).toHaveProperty('employees'); - expect(company).toHaveProperty('idealCustomerProfile'); - expect(company).toHaveProperty('position'); - expect(company).toHaveProperty('id'); - expect(company).toHaveProperty('createdAt'); - expect(company).toHaveProperty('updatedAt'); - expect(company).toHaveProperty('deletedAt'); - expect(company).toHaveProperty('accountOwnerId'); - expect(company).toHaveProperty('tagline'); - expect(company).toHaveProperty('workPolicy'); - expect(company).toHaveProperty('visaSponsorship'); - }); - }); -}); diff --git a/packages/twenty-server/test/companies/create-one-company.integration-spec.ts b/packages/twenty-server/test/companies/create-one-company.integration-spec.ts deleted file mode 100644 index 2a92d97866f9..000000000000 --- a/packages/twenty-server/test/companies/create-one-company.integration-spec.ts +++ /dev/null @@ -1,55 +0,0 @@ -import gql from 'graphql-tag'; -import { successfulApiRequest } from 'test/utils/api-requests'; -import { generateRecordName } from 'test/utils/generate-record-name'; - -const query = gql` - mutation CreateCompany($data: CompanyCreateInput) { - createCompany(data: $data) { - name - employees - idealCustomerProfile - position - id - createdAt - updatedAt - deletedAt - accountOwnerId - tagline - workPolicy - visaSponsorship - } - } -`; - -describe('createCompanyResolver (integration)', () => { - it('should create and return a company', () => { - const companyName = generateRecordName(); - const queryData = { - query, - variables: { - data: { - name: companyName, - }, - }, - }; - - return successfulApiRequest(queryData).expect((res) => { - const createdCompany = res.body.data.createCompany; - - expect(createdCompany).toHaveProperty('name'); - expect(createdCompany.name).toEqual(companyName); - - expect(createdCompany).toHaveProperty('employees'); - expect(createdCompany).toHaveProperty('idealCustomerProfile'); - expect(createdCompany).toHaveProperty('position'); - expect(createdCompany).toHaveProperty('id'); - expect(createdCompany).toHaveProperty('createdAt'); - expect(createdCompany).toHaveProperty('updatedAt'); - expect(createdCompany).toHaveProperty('deletedAt'); - expect(createdCompany).toHaveProperty('accountOwnerId'); - expect(createdCompany).toHaveProperty('tagline'); - expect(createdCompany).toHaveProperty('workPolicy'); - expect(createdCompany).toHaveProperty('visaSponsorship'); - }); - }); -}); diff --git a/packages/twenty-server/test/companies/delete-many-companies.integration.ts b/packages/twenty-server/test/companies/delete-many-companies.integration.ts deleted file mode 100644 index e4e45fc3ab7f..000000000000 --- a/packages/twenty-server/test/companies/delete-many-companies.integration.ts +++ /dev/null @@ -1,95 +0,0 @@ -import gql from 'graphql-tag'; -import { - createManyObjects, - successfulApiRequest, -} from 'test/utils/api-requests'; -import { generateRecordName } from 'test/utils/generate-record-name'; - -const deleteCompaniesQuery = gql` - mutation DeleteCompanies($filter: CompanyFilterInput) { - deleteCompanies(filter: $filter) { - deletedAt - } - } -`; - -const findCompaniesQuery = gql` - query Companies($filter: CompanyFilterInput) { - companies(filter: $filter) { - edges { - node { - id - } - } - } - } -`; - -describe('deleteCompaniesResolver (integration)', () => { - it('should delete companies and hide them from simple queries', async () => { - const companiesIds = await createManyObjects('Company', [ - { name: generateRecordName() }, - { name: generateRecordName() }, - ]); - - const filter = { - id: { - in: companiesIds, - }, - }; - - const deleteCompaniesQueryData = { - query: deleteCompaniesQuery, - variables: { - filter, - }, - }; - - const deleteCompaniesResponse = await successfulApiRequest( - deleteCompaniesQueryData, - ); - - const deleteCompanies = deleteCompaniesResponse.body.data.deleteCompanies; - - expect(deleteCompanies).toHaveLength(companiesIds.length); - - deleteCompanies.forEach((company) => { - expect(company.deletedAt).toBeTruthy(); - }); - - const findCompaniesQueryData = { - query: findCompaniesQuery, - variables: { - filter, - }, - }; - - const findCompaniesResponse = await successfulApiRequest( - findCompaniesQueryData, - ); - - expect(findCompaniesResponse.body.data.companies.edges).toHaveLength(0); - - const findDeletedCompaniesQueryData = { - query: findCompaniesQuery, - variables: { - filter: { - id: { - in: companiesIds, - }, - deletedAt: { - not: 'NULL', - }, - }, - }, - }; - - const findDeletedCompaniesResponse = await successfulApiRequest( - findDeletedCompaniesQueryData, - ); - - expect(findDeletedCompaniesResponse.body.data.companies.edges).toHaveLength( - companiesIds.length, - ); - }); -}); diff --git a/packages/twenty-server/test/companies/delete-one-company.integration-spec.ts b/packages/twenty-server/test/companies/delete-one-company.integration-spec.ts deleted file mode 100644 index 70454eda8df5..000000000000 --- a/packages/twenty-server/test/companies/delete-one-company.integration-spec.ts +++ /dev/null @@ -1,108 +0,0 @@ -import gql from 'graphql-tag'; -import { - apiRequest, - createOneObject, - successfulApiRequest, -} from 'test/utils/api-requests'; -import { generateRecordName } from 'test/utils/generate-record-name'; - -const deleteCompanyQuery = gql` - mutation DeleteCompany($companyId: ID!) { - deleteCompany(id: $companyId) { - deletedAt - } - } -`; - -const findCompanyQuery = gql` - query Company($filter: CompanyFilterInput) { - company(filter: $filter) { - id - } - } -`; - -const findCompaniesQuery = gql` - query Companies { - companies { - edges { - node { - id - } - } - } - } -`; - -describe('deleteCompanyResolver (integration)', () => { - it('should delete a company and hide it from simple queries', async () => { - const companyName = generateRecordName(); - const createdCompanyId = await createOneObject('Company', { - name: companyName, - }); - - const deleteCompanyQueryData = { - query: deleteCompanyQuery, - variables: { - companyId: createdCompanyId, - }, - }; - - const deleteCompanyResponse = await successfulApiRequest( - deleteCompanyQueryData, - ); - - expect( - deleteCompanyResponse.body.data.deleteCompany.deletedAt, - ).toBeTruthy(); - - const findCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - }, - }, - }; - - const findCompanyResponse = await apiRequest(findCompanyQueryData); - - expect(findCompanyResponse.body.data.company).toBeNull(); - - const findCompaniesResponse = await successfulApiRequest({ - query: findCompaniesQuery, - }); - - expect( - findCompaniesResponse.body.data.companies.edges.filter( - (c) => c.node.id === createdCompanyId, - ), - ).toHaveLength(0); - - const findDeletedCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - not: { - deletedAt: { - is: 'NULL', - }, - }, - }, - }, - }; - - const findDeletedCompanyResponse = await apiRequest( - findDeletedCompanyQueryData, - ); - - expect(findDeletedCompanyResponse.body.data.company.id).toEqual( - createdCompanyId, - ); - }); -}); diff --git a/packages/twenty-server/test/companies/destroy-many-companies.integration-spec.ts b/packages/twenty-server/test/companies/destroy-many-companies.integration-spec.ts deleted file mode 100644 index e0c869020536..000000000000 --- a/packages/twenty-server/test/companies/destroy-many-companies.integration-spec.ts +++ /dev/null @@ -1,98 +0,0 @@ -import gql from 'graphql-tag'; -import { - apiRequest, - createManyObjects, - successfulApiRequest, -} from 'test/utils/api-requests'; -import { generateRecordName } from 'test/utils/generate-record-name'; - -const destroyCompaniesQuery = gql` - mutation DestroyCompanies($filter: CompanyFilterInput) { - destroyCompanies(filter: $filter) { - deletedAt - } - } -`; - -const findCompaniesQuery = gql` - query Companies($filter: CompanyFilterInput) { - companies(filter: $filter) { - edges { - node { - id - } - } - } - } -`; - -describe('destroyCompaniesResolver (integration)', () => { - it('should destroy companies and hide them from simple queries', async () => { - const companiesIds = await createManyObjects('Company', [ - { name: generateRecordName() }, - { name: generateRecordName() }, - ]); - - const filter = { - id: { - in: companiesIds, - }, - }; - - const destroyCompaniesQueryData = { - query: destroyCompaniesQuery, - variables: { - filter, - }, - }; - - const destroyCompaniesResponse = await successfulApiRequest( - destroyCompaniesQueryData, - ); - - expect(destroyCompaniesResponse.body.data.destroyCompanies).toHaveLength( - companiesIds.length, - ); - - const findCompaniesQueryData = { - query: findCompaniesQuery, - variables: { - filter, - }, - }; - - const findCompaniesResponse = await successfulApiRequest( - findCompaniesQueryData, - ); - - expect( - findCompaniesResponse.body.data.companies.edges.filter((c) => - companiesIds.includes(c.node.id), - ), - ).toHaveLength(0); - - const findDeletedCompaniesQueryData = { - query: findCompaniesQuery, - variables: { - filter: { - id: { - in: companiesIds, - }, - not: { - deletedAt: { - is: 'NULL', - }, - }, - }, - }, - }; - - const findDeletedCompaniesResponse = await apiRequest( - findDeletedCompaniesQueryData, - ); - - expect(findDeletedCompaniesResponse.body.data.companies.edges).toHaveLength( - 0, - ); - }); -}); diff --git a/packages/twenty-server/test/companies/destroy-one-company.integration-spec.ts b/packages/twenty-server/test/companies/destroy-one-company.integration-spec.ts deleted file mode 100644 index cf80298706f6..000000000000 --- a/packages/twenty-server/test/companies/destroy-one-company.integration-spec.ts +++ /dev/null @@ -1,104 +0,0 @@ -import gql from 'graphql-tag'; -import { - apiRequest, - createOneObject, - successfulApiRequest, -} from 'test/utils/api-requests'; -import { generateRecordName } from 'test/utils/generate-record-name'; - -const destroyCompanyQuery = gql` - mutation DestroyCompany($companyId: ID!) { - destroyCompany(id: $companyId) { - deletedAt - } - } -`; - -const findCompanyQuery = gql` - query Company($filter: CompanyFilterInput) { - company(filter: $filter) { - id - } - } -`; - -const findCompaniesQuery = gql` - query Companies { - companies { - edges { - node { - id - } - } - } - } -`; - -describe('destroyCompanyResolver (integration)', () => { - it('should destroy a company and hide it from simple queries', async () => { - const companyName = generateRecordName(); - const createdCompanyId = await createOneObject('Company', { - name: companyName, - }); - - const destroyCompanyQueryData = { - query: destroyCompanyQuery, - variables: { - companyId: createdCompanyId, - }, - }; - - const destroyCompanyResponse = await successfulApiRequest( - destroyCompanyQueryData, - ); - - expect(destroyCompanyResponse.body.data.destroyCompany).toBeTruthy(); - - const findCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - }, - }, - }; - - const findCompanyResponse = await apiRequest(findCompanyQueryData); - - expect(findCompanyResponse.body.data.company).toBeNull(); - - const findCompaniesResponse = await successfulApiRequest({ - query: findCompaniesQuery, - }); - - expect( - findCompaniesResponse.body.data.companies.edges.filter( - (c) => c.node.id === createdCompanyId, - ), - ).toHaveLength(0); - - const findDeletedCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - not: { - deletedAt: { - is: 'NULL', - }, - }, - }, - }, - }; - - const findDeletedCompanyResponse = await apiRequest( - findDeletedCompanyQueryData, - ); - - expect(findDeletedCompanyResponse.body.data.company).toBeNull(); - }); -}); diff --git a/packages/twenty-server/test/companies/find-many-companies.integration-spec.ts b/packages/twenty-server/test/companies/find-many-companies.integration-spec.ts deleted file mode 100644 index 6ec9d209fd35..000000000000 --- a/packages/twenty-server/test/companies/find-many-companies.integration-spec.ts +++ /dev/null @@ -1,57 +0,0 @@ -import gql from 'graphql-tag'; -import { successfulApiRequest } from 'test/utils/api-requests'; - -describe('companiesResolver (integration)', () => { - it('should find many companies', () => { - const queryData = { - query: gql` - query companies { - companies { - edges { - node { - name - employees - idealCustomerProfile - position - id - createdAt - updatedAt - deletedAt - accountOwnerId - tagline - workPolicy - visaSponsorship - } - } - } - } - `, - }; - - return successfulApiRequest(queryData).expect((res) => { - const data = res.body.data.companies; - - expect(data).toBeDefined(); - expect(Array.isArray(data.edges)).toBe(true); - - const edges = data.edges; - - if (edges.length > 0) { - const companies = edges[0].node; - - expect(companies).toHaveProperty('name'); - expect(companies).toHaveProperty('employees'); - expect(companies).toHaveProperty('idealCustomerProfile'); - expect(companies).toHaveProperty('position'); - expect(companies).toHaveProperty('id'); - expect(companies).toHaveProperty('createdAt'); - expect(companies).toHaveProperty('updatedAt'); - expect(companies).toHaveProperty('deletedAt'); - expect(companies).toHaveProperty('accountOwnerId'); - expect(companies).toHaveProperty('tagline'); - expect(companies).toHaveProperty('workPolicy'); - expect(companies).toHaveProperty('visaSponsorship'); - } - }); - }); -}); diff --git a/packages/twenty-server/test/companies/find-one-company.integration-spec.ts b/packages/twenty-server/test/companies/find-one-company.integration-spec.ts deleted file mode 100644 index b054ecc19027..000000000000 --- a/packages/twenty-server/test/companies/find-one-company.integration-spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -import gql from 'graphql-tag'; -import { createOneObject, successfulApiRequest } from 'test/utils/api-requests'; -import { generateRecordName } from 'test/utils/generate-record-name'; - -const findOneCompanyQuery = gql` - query Company($filter: CompanyFilterInput) { - company(filter: $filter) { - name - employees - idealCustomerProfile - position - id - createdAt - updatedAt - deletedAt - accountOwnerId - tagline - workPolicy - visaSponsorship - } - } -`; - -describe('findOneCompanyResolver (integration)', () => { - it('should find one company', async () => { - const companyName = generateRecordName(); - const createdCompanyId = await createOneObject('Company', { - name: companyName, - }); - const findOneCompanyQueryData = { - query: findOneCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - }, - }, - }; - - successfulApiRequest(findOneCompanyQueryData).expect((res) => { - const company = res.body.data.company; - - expect(company).toHaveProperty('name'); - expect(company.name).toEqual(companyName); - - expect(company).toHaveProperty('employees'); - expect(company).toHaveProperty('idealCustomerProfile'); - expect(company).toHaveProperty('position'); - expect(company).toHaveProperty('id'); - expect(company).toHaveProperty('createdAt'); - expect(company).toHaveProperty('updatedAt'); - expect(company).toHaveProperty('deletedAt'); - expect(company).toHaveProperty('accountOwnerId'); - expect(company).toHaveProperty('tagline'); - expect(company).toHaveProperty('workPolicy'); - expect(company).toHaveProperty('visaSponsorship'); - }); - }); -}); diff --git a/packages/twenty-server/test/companies/person-company-relation.integration-spec.ts b/packages/twenty-server/test/companies/person-company-relation.integration-spec.ts deleted file mode 100644 index a067ba004219..000000000000 --- a/packages/twenty-server/test/companies/person-company-relation.integration-spec.ts +++ /dev/null @@ -1,111 +0,0 @@ -import gql from 'graphql-tag'; -import { createOneObject, successfulApiRequest } from 'test/utils/api-requests'; -import { generateRecordName } from 'test/utils/generate-record-name'; - -const updatePersonQuery = gql` - mutation UpdatePerson($personId: ID!, $data: PersonUpdateInput!) { - updatePerson(id: $personId, data: $data) { - id - } - } -`; - -const findCompanyQuery = gql` - query Company($filter: CompanyFilterInput) { - company(filter: $filter) { - people { - edges { - node { - id - name { - firstName - } - companyId - } - } - } - } - } -`; - -const findPersonQuery = gql` - query Person($filter: PersonFilterInput) { - person(filter: $filter) { - company { - id - name - } - } - } -`; - -describe('personCompanyRelationResolver (integration)', () => { - it('should create a company and a person and then update the person with companyId and query the company with person data', async () => { - const companyName = generateRecordName(); - const companyId = await createOneObject('Company', { - name: companyName, - }); - - const personName = generateRecordName(); - const personId = await createOneObject('Person', { - name: { - firstName: personName, - }, - }); - - await successfulApiRequest({ - query: updatePersonQuery, - variables: { - personId, - data: { - companyId, - }, - }, - }); - - const findCompanyResponse = await successfulApiRequest({ - query: findCompanyQuery, - variables: { - filter: { - id: { eq: companyId }, - }, - }, - }); - - const findPersonResponse = await successfulApiRequest({ - query: findPersonQuery, - variables: { - filter: { - id: { eq: personId }, - }, - }, - }); - - expect(findCompanyResponse.body.data.company).toEqual( - expect.objectContaining({ - people: { - edges: [ - { - node: { - id: personId, - companyId, - name: { - firstName: personName, - }, - }, - }, - ], - }, - }), - ); - - expect(findPersonResponse.body.data.person).toEqual( - expect.objectContaining({ - company: { - id: companyId, - name: companyName, - }, - }), - ); - }); -}); diff --git a/packages/twenty-server/test/companies/update-many-companies.integration-spec.ts b/packages/twenty-server/test/companies/update-many-companies.integration-spec.ts deleted file mode 100644 index 8dd3568f733c..000000000000 --- a/packages/twenty-server/test/companies/update-many-companies.integration-spec.ts +++ /dev/null @@ -1,85 +0,0 @@ -import gql from 'graphql-tag'; -import { - createManyObjects, - successfulApiRequest, -} from 'test/utils/api-requests'; -import { generateRecordName } from 'test/utils/generate-record-name'; - -const updateCompaniesQuery = gql` - mutation UpdateCompanies( - $data: CompanyUpdateInput - $filter: CompanyFilterInput - ) { - updateCompanies(data: $data, filter: $filter) { - id - name - } - } -`; - -const findCompaniesQuery = gql` - query Companies($filter: CompanyFilterInput) { - companies(filter: $filter) { - edges { - node { - id - name - } - } - } - } -`; - -describe('updateCompaniesResolver (integration)', () => { - it('should update companies and persist the changes', async () => { - const companiesIds = await createManyObjects('Company', [ - { name: generateRecordName() }, - { name: generateRecordName() }, - ]); - - const filter = { - id: { - in: companiesIds, - }, - }; - - const newName = generateRecordName(); - const updateCompaniesQueryData = { - query: updateCompaniesQuery, - variables: { - data: { - name: newName, - }, - filter, - }, - }; - - const updateCompaniesResponse = await successfulApiRequest( - updateCompaniesQueryData, - ); - - expect(updateCompaniesResponse.body.data.updateCompanies).toHaveLength( - companiesIds.length, - ); - - const findCompaniesQueryData = { - query: findCompaniesQuery, - variables: { - filter, - }, - }; - - const findCompaniesResponse = await successfulApiRequest( - findCompaniesQueryData, - ); - - const edges = findCompaniesResponse.body.data.companies.edges; - - expect(edges).toHaveLength(companiesIds.length); - - edges.forEach((edge) => { - expect(edge.node.name).toEqual(newName); - expect(companiesIds).toContain(edge.node.id); - }); - }); -}); diff --git a/packages/twenty-server/test/companies/update-one-company.integration-spec.ts b/packages/twenty-server/test/companies/update-one-company.integration-spec.ts deleted file mode 100644 index 1a911b6f7f1c..000000000000 --- a/packages/twenty-server/test/companies/update-one-company.integration-spec.ts +++ /dev/null @@ -1,62 +0,0 @@ -import gql from 'graphql-tag'; -import { createOneObject, successfulApiRequest } from 'test/utils/api-requests'; -import { generateRecordName } from 'test/utils/generate-record-name'; - -const updateCompanyQuery = gql` - mutation UpdateCompany($companyId: ID, $data: CompanyUpdateInput) { - updateCompany(id: $companyId, data: $data) { - name - } - } -`; - -const findCompanyQuery = gql` - query Company($filter: CompanyFilterInput) { - company(filter: $filter) { - name - } - } -`; - -describe('updateCompanyResolver (integration)', () => { - it('should update and persist the company update', async () => { - const companyName = generateRecordName(); - const createdCompanyId = await createOneObject('Company', { - name: companyName, - }); - const updateCompanyQueryData = { - query: updateCompanyQuery, - variables: { - companyId: createdCompanyId, - data: { - name: companyName, - }, - }, - }; - - successfulApiRequest(updateCompanyQueryData).expect((res) => { - const updatedCompany = res.body.data.updateCompany; - - expect(updatedCompany).toHaveProperty('name'); - expect(updatedCompany.name).toEqual(companyName); - }); - - const findCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - }, - }, - }; - - successfulApiRequest(findCompanyQueryData).expect((res) => { - const company = res.body.data.company; - - expect(company).toHaveProperty('name'); - expect(company.name).toEqual(companyName); - }); - }); -}); diff --git a/packages/twenty-server/test/utils/api-requests.ts b/packages/twenty-server/test/utils/api-requests.ts index 799cffb19b4b..6c5d9fce54ca 100644 --- a/packages/twenty-server/test/utils/api-requests.ts +++ b/packages/twenty-server/test/utils/api-requests.ts @@ -10,7 +10,7 @@ type QueryData = { type StandardObjectsSingularName = 'Company' | 'Person'; -export const apiRequest = (data: QueryData) => { +export const makeGraphqlAPIRequest = (data: QueryData) => { const client = request(`http://localhost:${APP_PORT}`); return client @@ -19,8 +19,8 @@ export const apiRequest = (data: QueryData) => { .send({ query: print(data.query), variables: data.variables || {} }); }; -export const successfulApiRequest = (data: QueryData) => { - return apiRequest(data).expect((res) => { +export const expectSuccessfullGraphqlAPIRequest = (data: QueryData) => { + return makeGraphqlAPIRequest(data).expect((res) => { expect(res.body.errors).toBeUndefined(); expect(res.body.data).toBeDefined(); }); @@ -44,11 +44,13 @@ export const createOneObject = async ( data, }; - return await successfulApiRequest({ query, variables }).then((res) => { - const createdObject = res.body.data[mutationName]; + return await expectSuccessfullGraphqlAPIRequest({ query, variables }).then( + (res) => { + const createdObject = res.body.data[mutationName]; - return createdObject.id as string; - }); + return createdObject.id as string; + }, + ); }; export const createManyObjects = async ( @@ -70,11 +72,13 @@ export const createManyObjects = async ( data, }; - return await successfulApiRequest({ query, variables }).then((res) => { - const createdObjectsIds: string[] = res.body.data[mutationName].map( - (object) => object.id, - ); + return await expectSuccessfullGraphqlAPIRequest({ query, variables }).then( + (res) => { + const createdObjectsIds: string[] = res.body.data[mutationName].map( + (object) => object.id, + ); - return createdObjectsIds; - }); + return createdObjectsIds; + }, + ); }; diff --git a/packages/twenty-server/test/utils/teardown-test.ts b/packages/twenty-server/test/utils/teardown-test.ts index d0e1a59d741f..c5905dbf9d78 100644 --- a/packages/twenty-server/test/utils/teardown-test.ts +++ b/packages/twenty-server/test/utils/teardown-test.ts @@ -1,5 +1,5 @@ import gql from 'graphql-tag'; -import { apiRequest } from 'test/utils/api-requests'; +import { makeGraphqlAPIRequest } from 'test/utils/api-requests'; import { TEST_NAME_PREFIX } from 'test/utils/generate-record-name'; import 'tsconfig-paths/register'; @@ -38,7 +38,7 @@ export default async () => { global.APP_PORT = jestConfig.globals?.APP_PORT; // @ts-expect-error in the teardown this env is not present in the global object anymore global.ACCESS_TOKEN = jestConfig.globals?.ACCESS_TOKEN; - apiRequest({ + makeGraphqlAPIRequest({ query, variables: { nameFilter, From ac1807efa6b43f01baf2517aa4045aeaac1208dc Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Wed, 16 Oct 2024 18:07:16 +0200 Subject: [PATCH 3/7] Refactor graphql api integration testing --- packages/twenty-server/felix | 1 - .../companies/companies.integration-spec.ts | 628 ------------------ .../graphql}/activities.integration-spec.ts | 0 .../activity-targets.integration-spec.ts | 0 .../graphql}/api-keys.integration-spec.ts | 0 .../graphql}/attachments.integration-spec.ts | 0 .../graphql}/audit-logs.integration-spec.ts | 0 .../graphql}/auth.integration-spec.ts | 0 .../graphql}/blocklists.integration-spec.ts | 0 ...nel-event-associations.integration-spec.ts | 0 .../calendar-channels.integration-spec.ts | 0 ...dar-event-participants.integration-spec.ts | 0 .../graphql}/comments.integration-spec.ts | 0 .../companies.integration-queries.ts} | 86 +-- .../companies/companies.integration-spec.ts | 602 +++++++++++++++++ .../connected-accounts.integration-spec.ts | 0 .../graphql}/favorites.integration-spec.ts | 0 ...l-message-associations.integration-spec.ts | 0 .../message-channels.integration-spec.ts | 0 .../message-participants.integration-spec.ts | 0 .../message-threads.integration-spec.ts | 0 .../graphql}/note-targets.integration-spec.ts | 0 .../graphql}/notes.integration-spec.ts | 0 .../graphql}/objects.integration-spec.ts | 0 .../opportunities.integration-spec.ts | 0 .../graphql}/people.integration-spec.ts | 0 .../graphql}/task-targets.integration-spec.ts | 0 .../graphql}/tasks.integration-spec.ts | 0 .../timeline-activities.integration-spec.ts | 0 .../graphql}/view-fields.integration-spec.ts | 0 .../graphql}/view-filters.integration-spec.ts | 0 .../graphql}/view-sorts.integration-spec.ts | 0 .../graphql}/views.integration-spec.ts | 0 .../graphql}/webhooks.integration-spec.ts | 0 .../workspace-members.integration-spec.ts | 0 .../{ => integration}/utils/create-app.ts | 0 .../integration/utils/generate-record-name.ts | 4 + .../utils/make-graphql-api-request.ts | 19 + .../{ => integration}/utils/setup-test.ts | 0 .../test/integration/utils/teardown-test.ts | 5 + .../twenty-server/test/utils/api-requests.ts | 84 --- .../test/utils/generate-record-name.ts | 4 - .../twenty-server/test/utils/teardown-test.ts | 51 -- 43 files changed, 664 insertions(+), 820 deletions(-) delete mode 160000 packages/twenty-server/felix delete mode 100644 packages/twenty-server/test/companies/companies.integration-spec.ts rename packages/twenty-server/test/{ => integration/graphql}/activities.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/activity-targets.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/api-keys.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/attachments.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/audit-logs.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/auth.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/blocklists.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/calendar-channel-event-associations.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/calendar-channels.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/calendar-event-participants.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/comments.integration-spec.ts (100%) rename packages/twenty-server/test/{companies/companies.integration-constants.ts => integration/graphql/companies/companies.integration-queries.ts} (87%) create mode 100644 packages/twenty-server/test/integration/graphql/companies/companies.integration-spec.ts rename packages/twenty-server/test/{ => integration/graphql}/connected-accounts.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/favorites.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/message-channel-message-associations.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/message-channels.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/message-participants.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/message-threads.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/note-targets.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/notes.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/objects.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/opportunities.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/people.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/task-targets.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/tasks.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/timeline-activities.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/view-fields.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/view-filters.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/view-sorts.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/views.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/webhooks.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration/graphql}/workspace-members.integration-spec.ts (100%) rename packages/twenty-server/test/{ => integration}/utils/create-app.ts (100%) create mode 100644 packages/twenty-server/test/integration/utils/generate-record-name.ts create mode 100644 packages/twenty-server/test/integration/utils/make-graphql-api-request.ts rename packages/twenty-server/test/{ => integration}/utils/setup-test.ts (100%) create mode 100644 packages/twenty-server/test/integration/utils/teardown-test.ts delete mode 100644 packages/twenty-server/test/utils/api-requests.ts delete mode 100644 packages/twenty-server/test/utils/generate-record-name.ts delete mode 100644 packages/twenty-server/test/utils/teardown-test.ts diff --git a/packages/twenty-server/felix b/packages/twenty-server/felix deleted file mode 160000 index a33b01797795..000000000000 --- a/packages/twenty-server/felix +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a33b01797795419edef84f122b5214472648d1ce diff --git a/packages/twenty-server/test/companies/companies.integration-spec.ts b/packages/twenty-server/test/companies/companies.integration-spec.ts deleted file mode 100644 index b28c8e4deefe..000000000000 --- a/packages/twenty-server/test/companies/companies.integration-spec.ts +++ /dev/null @@ -1,628 +0,0 @@ -import { - createCompaniesMutation, - createCompanyMutation, - deleteCompaniesMutation, - deleteCompanyMutation, - destroyCompaniesMutation, - destroyCompanyMutation, - findAllCompaniesQuery, - findCompaniesWithFilterQuery, - findCompanyQuery, - findCompanyWithFilterQuery, - findCompanyWithPeopleRelationQuery, - findPersonWithCompanyRelationQuery, - updateCompaniesMutation, - updatePersonMutation, -} from 'test/companies/companies.integration-constants'; -import { - createManyObjects, - createOneObject, - expectSuccessfullGraphqlAPIRequest, - makeGraphqlAPIRequest, -} from 'test/utils/api-requests'; -import { generateRecordName } from 'test/utils/generate-record-name'; - -describe('companies resolvers (integration)', () => { - describe('createCompaniesResolver (integration)', () => { - it('should create and return companies', async () => { - const companyName1 = generateRecordName(); - const companyName2 = generateRecordName(); - - const queryData = { - query: createCompaniesMutation, - variables: { - data: [ - { - name: companyName1, - }, - { - name: companyName2, - }, - ], - }, - }; - - const createdCompanies = - await expectSuccessfullGraphqlAPIRequest(queryData); - - expect(createdCompanies.body.data.createCompanies).toHaveLength(2); - - createdCompanies.body.data.createCompanies.forEach((company) => { - expect(company).toHaveProperty('name'); - expect([companyName1, companyName2]).toContain(company.name); - - expect(company).toHaveProperty('employees'); - expect(company).toHaveProperty('idealCustomerProfile'); - expect(company).toHaveProperty('position'); - expect(company).toHaveProperty('id'); - expect(company).toHaveProperty('createdAt'); - expect(company).toHaveProperty('updatedAt'); - expect(company).toHaveProperty('deletedAt'); - expect(company).toHaveProperty('accountOwnerId'); - expect(company).toHaveProperty('tagline'); - expect(company).toHaveProperty('workPolicy'); - expect(company).toHaveProperty('visaSponsorship'); - }); - }); - }); - - describe('createCompanyResolver (integration)', () => { - it('should create and return a company', () => { - const companyName = generateRecordName(); - const queryData = { - query: createCompanyMutation, - variables: { - data: { - name: companyName, - }, - }, - }; - - return expectSuccessfullGraphqlAPIRequest(queryData).expect((res) => { - const createdCompany = res.body.data.createCompany; - - expect(createdCompany).toHaveProperty('name'); - expect(createdCompany.name).toEqual(companyName); - - expect(createdCompany).toHaveProperty('employees'); - expect(createdCompany).toHaveProperty('idealCustomerProfile'); - expect(createdCompany).toHaveProperty('position'); - expect(createdCompany).toHaveProperty('id'); - expect(createdCompany).toHaveProperty('createdAt'); - expect(createdCompany).toHaveProperty('updatedAt'); - expect(createdCompany).toHaveProperty('deletedAt'); - expect(createdCompany).toHaveProperty('accountOwnerId'); - expect(createdCompany).toHaveProperty('tagline'); - expect(createdCompany).toHaveProperty('workPolicy'); - expect(createdCompany).toHaveProperty('visaSponsorship'); - }); - }); - }); - - describe('deleteCompaniesResolver (integration)', () => { - it('should delete companies and hide them from simple queries', async () => { - const companiesIds = await createManyObjects('Company', [ - { name: generateRecordName() }, - { name: generateRecordName() }, - ]); - - const filter = { - id: { - in: companiesIds, - }, - }; - - const deleteCompaniesQueryData = { - query: deleteCompaniesMutation, - variables: { - filter, - }, - }; - - const deleteCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - deleteCompaniesQueryData, - ); - - const deleteCompanies = deleteCompaniesResponse.body.data.deleteCompanies; - - expect(deleteCompanies).toHaveLength(companiesIds.length); - - deleteCompanies.forEach((company) => { - expect(company.deletedAt).toBeTruthy(); - }); - - const findCompaniesQueryData = { - query: findCompaniesWithFilterQuery, - variables: { - filter, - }, - }; - - const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - findCompaniesQueryData, - ); - - expect(findCompaniesResponse.body.data.companies.edges).toHaveLength(0); - - const findDeletedCompaniesQueryData = { - query: findCompaniesWithFilterQuery, - variables: { - filter: { - id: { - in: companiesIds, - }, - not: { - deletedAt: { - is: 'NULL', - }, - }, - }, - }, - }; - - const findDeletedCompaniesResponse = - await expectSuccessfullGraphqlAPIRequest(findDeletedCompaniesQueryData); - - expect( - findDeletedCompaniesResponse.body.data.companies.edges, - ).toHaveLength(companiesIds.length); - }); - }); - - describe('deleteCompanyResolver (integration)', () => { - it('should delete a company and hide it from simple queries', async () => { - const companyName = generateRecordName(); - const createdCompanyId = await createOneObject('Company', { - name: companyName, - }); - - const deleteCompanyQueryData = { - query: deleteCompanyMutation, - variables: { - companyId: createdCompanyId, - }, - }; - - const deleteCompanyResponse = await expectSuccessfullGraphqlAPIRequest( - deleteCompanyQueryData, - ); - - expect( - deleteCompanyResponse.body.data.deleteCompany.deletedAt, - ).toBeTruthy(); - - const findCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - }, - }, - }; - - const findCompanyResponse = - await makeGraphqlAPIRequest(findCompanyQueryData); - - expect(findCompanyResponse.body.data.company).toBeNull(); - - const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest({ - query: findCompaniesWithFilterQuery, - }); - - expect( - findCompaniesResponse.body.data.companies.edges.filter( - (c) => c.node.id === createdCompanyId, - ), - ).toHaveLength(0); - - const findDeletedCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - not: { - deletedAt: { - is: 'NULL', - }, - }, - }, - }, - }; - - const findDeletedCompanyResponse = await makeGraphqlAPIRequest( - findDeletedCompanyQueryData, - ); - - expect(findDeletedCompanyResponse.body.data.company.id).toEqual( - createdCompanyId, - ); - }); - }); - - describe('destroyCompaniesResolver (integration)', () => { - it('should destroy companies and hide them from simple queries', async () => { - const companiesIds = await createManyObjects('Company', [ - { name: generateRecordName() }, - { name: generateRecordName() }, - ]); - - const filter = { - id: { - in: companiesIds, - }, - }; - - const destroyCompaniesQueryData = { - query: destroyCompaniesMutation, - variables: { - filter, - }, - }; - - const destroyCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - destroyCompaniesQueryData, - ); - - expect(destroyCompaniesResponse.body.data.destroyCompanies).toHaveLength( - companiesIds.length, - ); - - const findCompaniesQueryData = { - query: findCompaniesWithFilterQuery, - variables: { - filter, - }, - }; - - const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - findCompaniesQueryData, - ); - - expect( - findCompaniesResponse.body.data.companies.edges.filter((c) => - companiesIds.includes(c.node.id), - ), - ).toHaveLength(0); - - const findDeletedCompaniesQueryData = { - query: findCompaniesWithFilterQuery, - variables: { - filter: { - id: { - in: companiesIds, - }, - not: { - deletedAt: { - is: 'NULL', - }, - }, - }, - }, - }; - - const findDeletedCompaniesResponse = await makeGraphqlAPIRequest( - findDeletedCompaniesQueryData, - ); - - expect( - findDeletedCompaniesResponse.body.data.companies.edges, - ).toHaveLength(0); - }); - }); - - describe('destroyCompanyResolver (integration)', () => { - it('should destroy a company and hide it from simple queries', async () => { - const companyName = generateRecordName(); - const createdCompanyId = await createOneObject('Company', { - name: companyName, - }); - - const destroyCompanyQueryData = { - query: destroyCompanyMutation, - variables: { - companyId: createdCompanyId, - }, - }; - - const destroyCompanyResponse = await expectSuccessfullGraphqlAPIRequest( - destroyCompanyQueryData, - ); - - expect(destroyCompanyResponse.body.data.destroyCompany).toBeTruthy(); - - const findCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - }, - }, - }; - - const findCompanyResponse = - await makeGraphqlAPIRequest(findCompanyQueryData); - - expect(findCompanyResponse.body.data.company).toBeNull(); - - const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest({ - query: findCompaniesWithFilterQuery, - }); - - expect( - findCompaniesResponse.body.data.companies.edges.filter( - (c) => c.node.id === createdCompanyId, - ), - ).toHaveLength(0); - - const findDeletedCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - not: { - deletedAt: { - is: 'NULL', - }, - }, - }, - }, - }; - - const findDeletedCompanyResponse = await makeGraphqlAPIRequest( - findDeletedCompanyQueryData, - ); - - expect(findDeletedCompanyResponse.body.data.company).toBeNull(); - }); - }); - - describe('companiesResolver (integration)', () => { - it('should find many companies', () => { - return expectSuccessfullGraphqlAPIRequest({ - query: findAllCompaniesQuery, - }).expect((res) => { - const data = res.body.data.companies; - - expect(data).toBeDefined(); - expect(Array.isArray(data.edges)).toBe(true); - - const edges = data.edges; - - if (edges.length > 0) { - const companies = edges[0].node; - - expect(companies).toHaveProperty('name'); - expect(companies).toHaveProperty('employees'); - expect(companies).toHaveProperty('idealCustomerProfile'); - expect(companies).toHaveProperty('position'); - expect(companies).toHaveProperty('id'); - expect(companies).toHaveProperty('createdAt'); - expect(companies).toHaveProperty('updatedAt'); - expect(companies).toHaveProperty('deletedAt'); - expect(companies).toHaveProperty('accountOwnerId'); - expect(companies).toHaveProperty('tagline'); - expect(companies).toHaveProperty('workPolicy'); - expect(companies).toHaveProperty('visaSponsorship'); - } - }); - }); - }); - - describe('findOneCompanyResolver (integration)', () => { - it('should find one company', async () => { - const companyName = generateRecordName(); - const createdCompanyId = await createOneObject('Company', { - name: companyName, - }); - const findOneCompanyQueryData = { - query: findCompanyWithFilterQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - }, - }, - }; - - expectSuccessfullGraphqlAPIRequest(findOneCompanyQueryData).expect( - (res) => { - const company = res.body.data.company; - - expect(company).toHaveProperty('name'); - expect(company.name).toEqual(companyName); - - expect(company).toHaveProperty('employees'); - expect(company).toHaveProperty('idealCustomerProfile'); - expect(company).toHaveProperty('position'); - expect(company).toHaveProperty('id'); - expect(company).toHaveProperty('createdAt'); - expect(company).toHaveProperty('updatedAt'); - expect(company).toHaveProperty('deletedAt'); - expect(company).toHaveProperty('accountOwnerId'); - expect(company).toHaveProperty('tagline'); - expect(company).toHaveProperty('workPolicy'); - expect(company).toHaveProperty('visaSponsorship'); - }, - ); - }); - }); - - describe('personCompanyRelationResolver (integration)', () => { - it('should create a company and a person and then update the person with companyId and query the company with person data', async () => { - const companyName = generateRecordName(); - const companyId = await createOneObject('Company', { - name: companyName, - }); - - const personName = generateRecordName(); - const personId = await createOneObject('Person', { - name: { - firstName: personName, - }, - }); - - await expectSuccessfullGraphqlAPIRequest({ - query: updatePersonMutation, - variables: { - personId, - data: { - companyId, - }, - }, - }); - - const findCompanyResponse = await expectSuccessfullGraphqlAPIRequest({ - query: findCompanyWithPeopleRelationQuery, - variables: { - filter: { - id: { eq: companyId }, - }, - }, - }); - - const findPersonResponse = await expectSuccessfullGraphqlAPIRequest({ - query: findPersonWithCompanyRelationQuery, - variables: { - filter: { - id: { eq: personId }, - }, - }, - }); - - expect(findCompanyResponse.body.data.company).toEqual( - expect.objectContaining({ - people: { - edges: [ - { - node: { - id: personId, - companyId, - name: { - firstName: personName, - }, - }, - }, - ], - }, - }), - ); - - expect(findPersonResponse.body.data.person).toEqual( - expect.objectContaining({ - company: { - id: companyId, - name: companyName, - }, - }), - ); - }); - }); - - describe('updateCompaniesResolver (integration)', () => { - it('should update companies and persist the changes', async () => { - const companiesIds = await createManyObjects('Company', [ - { name: generateRecordName() }, - { name: generateRecordName() }, - ]); - - const filter = { - id: { - in: companiesIds, - }, - }; - - const newName = generateRecordName(); - const updateCompaniesQueryData = { - query: updateCompaniesMutation, - variables: { - data: { - name: newName, - }, - filter, - }, - }; - - const updateCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - updateCompaniesQueryData, - ); - - expect(updateCompaniesResponse.body.data.updateCompanies).toHaveLength( - companiesIds.length, - ); - - const findCompaniesQueryData = { - query: findCompaniesWithFilterQuery, - variables: { - filter, - }, - }; - - const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - findCompaniesQueryData, - ); - - const edges = findCompaniesResponse.body.data.companies.edges; - - expect(edges).toHaveLength(companiesIds.length); - - edges.forEach((edge) => { - expect(edge.node.name).toEqual(newName); - expect(companiesIds).toContain(edge.node.id); - }); - }); - }); - - describe('updateCompanyResolver (integration)', () => { - it('should update and persist the company update', async () => { - const companyName = generateRecordName(); - const createdCompanyId = await createOneObject('Company', { - name: companyName, - }); - const updateCompanyQueryData = { - query: updateCompaniesMutation, - variables: { - companyId: createdCompanyId, - data: { - name: companyName, - }, - }, - }; - - expectSuccessfullGraphqlAPIRequest(updateCompanyQueryData).expect( - (res) => { - const updatedCompany = res.body.data.updateCompany; - - expect(updatedCompany).toHaveProperty('name'); - expect(updatedCompany.name).toEqual(companyName); - }, - ); - - const findCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - }, - }, - }; - - expectSuccessfullGraphqlAPIRequest(findCompanyQueryData).expect((res) => { - const company = res.body.data.company; - - expect(company).toHaveProperty('name'); - expect(company.name).toEqual(companyName); - }); - }); - }); -}); diff --git a/packages/twenty-server/test/activities.integration-spec.ts b/packages/twenty-server/test/integration/graphql/activities.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/activities.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/activities.integration-spec.ts diff --git a/packages/twenty-server/test/activity-targets.integration-spec.ts b/packages/twenty-server/test/integration/graphql/activity-targets.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/activity-targets.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/activity-targets.integration-spec.ts diff --git a/packages/twenty-server/test/api-keys.integration-spec.ts b/packages/twenty-server/test/integration/graphql/api-keys.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/api-keys.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/api-keys.integration-spec.ts diff --git a/packages/twenty-server/test/attachments.integration-spec.ts b/packages/twenty-server/test/integration/graphql/attachments.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/attachments.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/attachments.integration-spec.ts diff --git a/packages/twenty-server/test/audit-logs.integration-spec.ts b/packages/twenty-server/test/integration/graphql/audit-logs.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/audit-logs.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/audit-logs.integration-spec.ts diff --git a/packages/twenty-server/test/auth.integration-spec.ts b/packages/twenty-server/test/integration/graphql/auth.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/auth.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/auth.integration-spec.ts diff --git a/packages/twenty-server/test/blocklists.integration-spec.ts b/packages/twenty-server/test/integration/graphql/blocklists.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/blocklists.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/blocklists.integration-spec.ts diff --git a/packages/twenty-server/test/calendar-channel-event-associations.integration-spec.ts b/packages/twenty-server/test/integration/graphql/calendar-channel-event-associations.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/calendar-channel-event-associations.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/calendar-channel-event-associations.integration-spec.ts diff --git a/packages/twenty-server/test/calendar-channels.integration-spec.ts b/packages/twenty-server/test/integration/graphql/calendar-channels.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/calendar-channels.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/calendar-channels.integration-spec.ts diff --git a/packages/twenty-server/test/calendar-event-participants.integration-spec.ts b/packages/twenty-server/test/integration/graphql/calendar-event-participants.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/calendar-event-participants.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/calendar-event-participants.integration-spec.ts diff --git a/packages/twenty-server/test/comments.integration-spec.ts b/packages/twenty-server/test/integration/graphql/comments.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/comments.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/comments.integration-spec.ts diff --git a/packages/twenty-server/test/companies/companies.integration-constants.ts b/packages/twenty-server/test/integration/graphql/companies/companies.integration-queries.ts similarity index 87% rename from packages/twenty-server/test/companies/companies.integration-constants.ts rename to packages/twenty-server/test/integration/graphql/companies/companies.integration-queries.ts index fa4463186541..8ed88b26afa2 100644 --- a/packages/twenty-server/test/companies/companies.integration-constants.ts +++ b/packages/twenty-server/test/integration/graphql/companies/companies.integration-queries.ts @@ -23,7 +23,7 @@ export const findCompanyQuery = gql` } `; -export const findCompaniesWithFilterQuery = gql` +export const findCompaniesQuery = gql` query Companies($filter: CompanyFilterInput) { companies(filter: $filter) { edges { @@ -35,6 +35,14 @@ export const findCompaniesWithFilterQuery = gql` } `; +export const createCompanyMutation = gql` + mutation CreateCompany($data: CompanyCreateInput) { + createCompany(data: $data) { + ${companyProperties} + } + } +`; + export const createCompaniesMutation = gql` mutation CreateCompanies($data: [CompanyCreateInput!]!) { createCompanies(data: $data) { @@ -43,18 +51,22 @@ export const createCompaniesMutation = gql` } `; -export const createCompanyMutation = gql` - mutation CreateCompany($data: CompanyCreateInput) { - createCompany(data: $data) { - ${companyProperties} +export const updateCompanyMutation = gql` + mutation UpdateCompany($companyId: ID, $data: CompanyUpdateInput) { + updateCompany(id: $companyId, data: $data) { + name } } `; -export const deleteCompaniesMutation = gql` - mutation DeleteCompanies($filter: CompanyFilterInput) { - deleteCompanies(filter: $filter) { - deletedAt +export const updateCompaniesMutation = gql` + mutation UpdateCompanies( + $data: CompanyUpdateInput + $filter: CompanyFilterInput + ) { + updateCompanies(data: $data, filter: $filter) { + id + name } } `; @@ -67,13 +79,14 @@ export const deleteCompanyMutation = gql` } `; -export const destroyCompaniesMutation = gql` - mutation DestroyCompanies($filter: CompanyFilterInput) { - destroyCompanies(filter: $filter) { +export const deleteCompaniesMutation = gql` + mutation DeleteCompanies($filter: CompanyFilterInput) { + deleteCompanies(filter: $filter) { deletedAt } } `; + export const destroyCompanyMutation = gql` mutation DestroyCompany($companyId: ID!) { destroyCompany(id: $companyId) { @@ -81,6 +94,15 @@ export const destroyCompanyMutation = gql` } } `; + +export const destroyCompaniesMutation = gql` + mutation DestroyCompanies($filter: CompanyFilterInput) { + destroyCompanies(filter: $filter) { + deletedAt + } + } +`; + export const updatePersonMutation = gql` mutation UpdatePerson($personId: ID!, $data: PersonUpdateInput!) { updatePerson(id: $personId, data: $data) { @@ -117,43 +139,3 @@ export const findPersonWithCompanyRelationQuery = gql` } } `; - -export const updateCompaniesMutation = gql` - mutation UpdateCompanies( - $data: CompanyUpdateInput - $filter: CompanyFilterInput - ) { - updateCompanies(data: $data, filter: $filter) { - id - name - } - } -`; - -export const findAllCompaniesQuery = gql` - query Companies { - companies { - edges { - node { - ${companyProperties} - } - } - } - } -`; - -export const updateCompanyMutation = gql` - mutation UpdateCompany($companyId: ID, $data: CompanyUpdateInput) { - updateCompany(id: $companyId, data: $data) { - name - } - } -`; - -export const findCompanyWithFilterQuery = gql` - query Company($filter: CompanyFilterInput) { - company(filter: $filter) { - ${companyProperties} - } - } -`; diff --git a/packages/twenty-server/test/integration/graphql/companies/companies.integration-spec.ts b/packages/twenty-server/test/integration/graphql/companies/companies.integration-spec.ts new file mode 100644 index 000000000000..0e8d3e8ec2a7 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/companies/companies.integration-spec.ts @@ -0,0 +1,602 @@ +import { + createCompaniesMutation, + createCompanyMutation, + deleteCompaniesMutation, + deleteCompanyMutation, + destroyCompaniesMutation, + destroyCompanyMutation, + findCompaniesQuery, + findCompanyQuery, + findCompanyWithPeopleRelationQuery, + findPersonWithCompanyRelationQuery, + updateCompaniesMutation, + updatePersonMutation, +} from 'test/integration/graphql/companies/companies.integration-queries'; +import { generateRecordName } from 'test/integration/utils/generate-record-name'; +import { makeGraphqlAPIRequest } from 'test/integration/utils/make-graphql-api-request'; + +const COMPANY_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987'; +const COMPANY_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988'; +const COMPANY_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989'; + +describe('companies resolvers (integration)', () => { + it('1. should create and return companies', async () => { + const companyName1 = generateRecordName(COMPANY_1_ID); + const companyName2 = generateRecordName(COMPANY_2_ID); + + const graphqlOperation = { + query: createCompaniesMutation, + variables: { + data: [ + { + id: COMPANY_1_ID, + name: companyName1, + }, + { + id: COMPANY_2_ID, + name: companyName2, + }, + ], + }, + }; + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + expect(response.body.data.createCompanies).toHaveLength(2); + + response.body.data.createCompanies.forEach((company) => { + expect(company).toHaveProperty('name'); + expect([companyName1, companyName2]).toContain(company.name); + + expect(company).toHaveProperty('employees'); + expect(company).toHaveProperty('idealCustomerProfile'); + expect(company).toHaveProperty('position'); + expect(company).toHaveProperty('id'); + expect(company).toHaveProperty('createdAt'); + expect(company).toHaveProperty('updatedAt'); + expect(company).toHaveProperty('deletedAt'); + expect(company).toHaveProperty('accountOwnerId'); + expect(company).toHaveProperty('tagline'); + expect(company).toHaveProperty('workPolicy'); + expect(company).toHaveProperty('visaSponsorship'); + }); + }); + + describe('1b. should create and return one company', async () => { + const companyName = generateRecordName(COMPANY_3_ID); + + const graphqlOperation = { + query: createCompanyMutation, + variables: { + data: { + id: COMPANY_3_ID, + name: companyName, + }, + }, + }; + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + const createdCompany = response.body.data.createCompany; + + expect(createdCompany).toHaveProperty('name'); + expect(createdCompany.name).toEqual(companyName); + + expect(createdCompany).toHaveProperty('employees'); + expect(createdCompany).toHaveProperty('idealCustomerProfile'); + expect(createdCompany).toHaveProperty('position'); + expect(createdCompany).toHaveProperty('id'); + expect(createdCompany).toHaveProperty('createdAt'); + expect(createdCompany).toHaveProperty('updatedAt'); + expect(createdCompany).toHaveProperty('deletedAt'); + expect(createdCompany).toHaveProperty('accountOwnerId'); + expect(createdCompany).toHaveProperty('tagline'); + expect(createdCompany).toHaveProperty('workPolicy'); + expect(createdCompany).toHaveProperty('visaSponsorship'); + }); + + it('2. should find many companies', async () => { + const findCompaniesQueryData = { + query: findCompaniesQuery, + }; + + const result = await makeGraphqlAPIRequest(findCompaniesQueryData); + + const data = result.body.data.companies; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const companies = edges[0].node; + + expect(companies).toHaveProperty('name'); + expect(companies).toHaveProperty('employees'); + expect(companies).toHaveProperty('idealCustomerProfile'); + expect(companies).toHaveProperty('position'); + expect(companies).toHaveProperty('id'); + expect(companies).toHaveProperty('createdAt'); + expect(companies).toHaveProperty('updatedAt'); + expect(companies).toHaveProperty('deletedAt'); + expect(companies).toHaveProperty('accountOwnerId'); + expect(companies).toHaveProperty('tagline'); + expect(companies).toHaveProperty('workPolicy'); + expect(companies).toHaveProperty('visaSponsorship'); + } + }); + + it('2b. should find one company', async () => { + const findOneCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: COMPANY_3_ID, + }, + }, + }, + }; + + expectSuccessfullGraphqlAPIRequest(findOneCompanyQueryData).expect( + (res) => { + const company = res.body.data.company; + + expect(company).toHaveProperty('name'); + + expect(company).toHaveProperty('employees'); + expect(company).toHaveProperty('idealCustomerProfile'); + expect(company).toHaveProperty('position'); + expect(company).toHaveProperty('id'); + expect(company).toHaveProperty('createdAt'); + expect(company).toHaveProperty('updatedAt'); + expect(company).toHaveProperty('deletedAt'); + expect(company).toHaveProperty('accountOwnerId'); + expect(company).toHaveProperty('tagline'); + expect(company).toHaveProperty('workPolicy'); + expect(company).toHaveProperty('visaSponsorship'); + }, + ); + }); + + it('3. should delete many companies', async () => { + const filter = { + id: { + in: [COMPANY_1_ID, COMPANY_2_ID], + }, + }; + + const deleteCompaniesQueryData = { + query: deleteCompaniesMutation, + variables: { + filter, + }, + }; + + const deleteCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + deleteCompaniesQueryData, + ); + + const deleteCompanies = deleteCompaniesResponse.body.data.deleteCompanies; + + expect(deleteCompanies).toHaveLength(2); + + deleteCompanies.forEach((company) => { + expect(company.deletedAt).toBeTruthy(); + }); + }); + + it('3b. should delete one company', async () => { + const deleteCompanyQueryData = { + query: deleteCompanyMutation, + variables: { + companyId: COMPANY_3_ID, + }, + }; + + const deleteCompanyResponse = await expectSuccessfullGraphqlAPIRequest( + deleteCompanyQueryData, + ); + + expect( + deleteCompanyResponse.body.data.deleteCompany.deletedAt, + ).toBeTruthy(); + }); + + it('4. should not find many companies anymore', async () => { + const filter = { + id: { + in: [COMPANY_1_ID, COMPANY_2_ID], + }, + }; + + const findCompaniesQueryData = { + query: findCompaniesQuery, + variables: { + filter, + }, + }; + + const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + findCompaniesQueryData, + ); + + expect(findCompaniesResponse.body.data.companies.edges).toHaveLength(0); + }); + + it('4b. should not find one company anymore', async () => { + const findCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: COMPANY_3_ID, + }, + }, + }, + }; + const findCompanyResponse = + await makeGraphqlAPIRequest(findCompanyQueryData); + + expect(findCompanyResponse.body.data.company).toBeNull(); + + expect( + findCompaniesResponse.body.data.companies.edges.filter( + (c) => c.node.id === COMPANY_3_ID, + ), + ).toHaveLength(0); + }); + + it('5. should find many deleted companies with deletedAt filter', async () => { + const findDeletedCompaniesQueryData = { + query: findCompaniesWithFilterQuery, + variables: { + filter: { + id: { + in: [COMPANY_1_ID, COMPANY_2_ID], + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }, + }; + + const findDeletedCompaniesResponse = + await expectSuccessfullGraphqlAPIRequest(findDeletedCompaniesQueryData); + + expect(findDeletedCompaniesResponse.body.data.companies.edges).toHaveLength( + 2, + ); + }); + + it('should find the deleted company with deletedAt filter', async () => { + const findDeletedCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: COMPANY_3_ID, + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }, + }; + + const findDeletedCompanyResponse = await makeGraphqlAPIRequest( + findDeletedCompanyQueryData, + ); + + expect(findDeletedCompanyResponse.body.data.company.id).toEqual( + COMPANY_3_ID, + ); + }); + + describe('destroyCompaniesResolver (integration)', () => { + it('should destroy companies and hide them from simple queries', async () => { + const filter = { + id: { + in: [COMPANY_1_ID, COMPANY_2_ID], + }, + }; + + const destroyCompaniesQueryData = { + query: destroyCompaniesMutation, + variables: { + filter, + }, + }; + + const destroyCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + destroyCompaniesQueryData, + ); + + expect(destroyCompaniesResponse.body.data.destroyCompanies).toHaveLength( + 2, + ); + + const findCompaniesQueryData = { + query: findCompaniesWithFilterQuery, + variables: { + filter, + }, + }; + + const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + findCompaniesQueryData, + ); + + expect( + findCompaniesResponse.body.data.companies.edges.filter((c) => + [COMPANY_1_ID, COMPANY_2_ID].includes(c.node.id), + ), + ).toHaveLength(0); + + const findDeletedCompaniesQueryData = { + query: findCompaniesWithFilterQuery, + variables: { + filter: { + id: { + in: [COMPANY_1_ID, COMPANY_2_ID], + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }, + }; + + const findDeletedCompaniesResponse = await makeGraphqlAPIRequest( + findDeletedCompaniesQueryData, + ); + + expect( + findDeletedCompaniesResponse.body.data.companies.edges, + ).toHaveLength(0); + }); + }); + + describe('destroyCompanyResolver (integration)', () => { + it('should destroy a company and hide it from simple queries', async () => { + const destroyCompanyQueryData = { + query: destroyCompanyMutation, + variables: { + companyId: COMPANY_3_ID, + }, + }; + + const destroyCompanyResponse = await expectSuccessfullGraphqlAPIRequest( + destroyCompanyQueryData, + ); + + expect(destroyCompanyResponse.body.data.destroyCompany).toBeTruthy(); + + const findCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: COMPANY_3_ID, + }, + }, + }, + }; + + const findCompanyResponse = + await makeGraphqlAPIRequest(findCompanyQueryData); + + expect(findCompanyResponse.body.data.company).toBeNull(); + + const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest({ + query: findCompaniesWithFilterQuery, + }); + + expect( + findCompaniesResponse.body.data.companies.edges.filter( + (c) => c.node.id === COMPANY_3_ID, + ), + ).toHaveLength(0); + + const findDeletedCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: COMPANY_3_ID, + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }, + }; + + const findDeletedCompanyResponse = await makeGraphqlAPIRequest( + findDeletedCompanyQueryData, + ); + + expect(findDeletedCompanyResponse.body.data.company).toBeNull(); + }); + }); + + describe('personCompanyRelationResolver (integration)', () => { + it('should create a company and a person and then update the person with companyId and query the company with person data', async () => { + const companyName = generateRecordName(); + const companyId = await createOneObject('Company', { + name: companyName, + }); + + const personName = generateRecordName(); + const personId = await createOneObject('Person', { + name: { + firstName: personName, + }, + }); + + await expectSuccessfullGraphqlAPIRequest({ + query: updatePersonMutation, + variables: { + personId, + data: { + companyId, + }, + }, + }); + + const findCompanyResponse = await expectSuccessfullGraphqlAPIRequest({ + query: findCompanyWithPeopleRelationQuery, + variables: { + filter: { + id: { eq: companyId }, + }, + }, + }); + + const findPersonResponse = await expectSuccessfullGraphqlAPIRequest({ + query: findPersonWithCompanyRelationQuery, + variables: { + filter: { + id: { eq: personId }, + }, + }, + }); + + expect(findCompanyResponse.body.data.company).toEqual( + expect.objectContaining({ + people: { + edges: [ + { + node: { + id: personId, + companyId, + name: { + firstName: personName, + }, + }, + }, + ], + }, + }), + ); + + expect(findPersonResponse.body.data.person).toEqual( + expect.objectContaining({ + company: { + id: companyId, + name: companyName, + }, + }), + ); + }); + }); + + describe('updateCompaniesResolver (integration)', () => { + it('should update companies and persist the changes', async () => { + const companiesIds = await createManyObjects('Company', [ + { name: generateRecordName() }, + { name: generateRecordName() }, + ]); + + const filter = { + id: { + in: companiesIds, + }, + }; + + const newName = generateRecordName(); + const updateCompaniesQueryData = { + query: updateCompaniesMutation, + variables: { + data: { + name: newName, + }, + filter, + }, + }; + + const updateCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + updateCompaniesQueryData, + ); + + expect(updateCompaniesResponse.body.data.updateCompanies).toHaveLength( + companiesIds.length, + ); + + const findCompaniesQueryData = { + query: findCompaniesWithFilterQuery, + variables: { + filter, + }, + }; + + const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( + findCompaniesQueryData, + ); + + const edges = findCompaniesResponse.body.data.companies.edges; + + expect(edges).toHaveLength(companiesIds.length); + + edges.forEach((edge) => { + expect(edge.node.name).toEqual(newName); + expect(companiesIds).toContain(edge.node.id); + }); + }); + }); + + describe('updateCompanyResolver (integration)', () => { + it('should update and persist the company update', async () => { + const companyName = generateRecordName(); + const createdCompanyId = await createOneObject('Company', { + name: companyName, + }); + const updateCompanyQueryData = { + query: updateCompaniesMutation, + variables: { + companyId: createdCompanyId, + data: { + name: companyName, + }, + }, + }; + + expectSuccessfullGraphqlAPIRequest(updateCompanyQueryData).expect( + (res) => { + const updatedCompany = res.body.data.updateCompany; + + expect(updatedCompany).toHaveProperty('name'); + expect(updatedCompany.name).toEqual(companyName); + }, + ); + + const findCompanyQueryData = { + query: findCompanyQuery, + variables: { + filter: { + id: { + eq: createdCompanyId, + }, + }, + }, + }; + + expectSuccessfullGraphqlAPIRequest(findCompanyQueryData).expect((res) => { + const company = res.body.data.company; + + expect(company).toHaveProperty('name'); + expect(company.name).toEqual(companyName); + }); + }); + }); +}); diff --git a/packages/twenty-server/test/connected-accounts.integration-spec.ts b/packages/twenty-server/test/integration/graphql/connected-accounts.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/connected-accounts.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/connected-accounts.integration-spec.ts diff --git a/packages/twenty-server/test/favorites.integration-spec.ts b/packages/twenty-server/test/integration/graphql/favorites.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/favorites.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/favorites.integration-spec.ts diff --git a/packages/twenty-server/test/message-channel-message-associations.integration-spec.ts b/packages/twenty-server/test/integration/graphql/message-channel-message-associations.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/message-channel-message-associations.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/message-channel-message-associations.integration-spec.ts diff --git a/packages/twenty-server/test/message-channels.integration-spec.ts b/packages/twenty-server/test/integration/graphql/message-channels.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/message-channels.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/message-channels.integration-spec.ts diff --git a/packages/twenty-server/test/message-participants.integration-spec.ts b/packages/twenty-server/test/integration/graphql/message-participants.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/message-participants.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/message-participants.integration-spec.ts diff --git a/packages/twenty-server/test/message-threads.integration-spec.ts b/packages/twenty-server/test/integration/graphql/message-threads.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/message-threads.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/message-threads.integration-spec.ts diff --git a/packages/twenty-server/test/note-targets.integration-spec.ts b/packages/twenty-server/test/integration/graphql/note-targets.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/note-targets.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/note-targets.integration-spec.ts diff --git a/packages/twenty-server/test/notes.integration-spec.ts b/packages/twenty-server/test/integration/graphql/notes.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/notes.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/notes.integration-spec.ts diff --git a/packages/twenty-server/test/objects.integration-spec.ts b/packages/twenty-server/test/integration/graphql/objects.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/objects.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/objects.integration-spec.ts diff --git a/packages/twenty-server/test/opportunities.integration-spec.ts b/packages/twenty-server/test/integration/graphql/opportunities.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/opportunities.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/opportunities.integration-spec.ts diff --git a/packages/twenty-server/test/people.integration-spec.ts b/packages/twenty-server/test/integration/graphql/people.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/people.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/people.integration-spec.ts diff --git a/packages/twenty-server/test/task-targets.integration-spec.ts b/packages/twenty-server/test/integration/graphql/task-targets.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/task-targets.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/task-targets.integration-spec.ts diff --git a/packages/twenty-server/test/tasks.integration-spec.ts b/packages/twenty-server/test/integration/graphql/tasks.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/tasks.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/tasks.integration-spec.ts diff --git a/packages/twenty-server/test/timeline-activities.integration-spec.ts b/packages/twenty-server/test/integration/graphql/timeline-activities.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/timeline-activities.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/timeline-activities.integration-spec.ts diff --git a/packages/twenty-server/test/view-fields.integration-spec.ts b/packages/twenty-server/test/integration/graphql/view-fields.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/view-fields.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/view-fields.integration-spec.ts diff --git a/packages/twenty-server/test/view-filters.integration-spec.ts b/packages/twenty-server/test/integration/graphql/view-filters.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/view-filters.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/view-filters.integration-spec.ts diff --git a/packages/twenty-server/test/view-sorts.integration-spec.ts b/packages/twenty-server/test/integration/graphql/view-sorts.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/view-sorts.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/view-sorts.integration-spec.ts diff --git a/packages/twenty-server/test/views.integration-spec.ts b/packages/twenty-server/test/integration/graphql/views.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/views.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/views.integration-spec.ts diff --git a/packages/twenty-server/test/webhooks.integration-spec.ts b/packages/twenty-server/test/integration/graphql/webhooks.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/webhooks.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/webhooks.integration-spec.ts diff --git a/packages/twenty-server/test/workspace-members.integration-spec.ts b/packages/twenty-server/test/integration/graphql/workspace-members.integration-spec.ts similarity index 100% rename from packages/twenty-server/test/workspace-members.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/workspace-members.integration-spec.ts diff --git a/packages/twenty-server/test/utils/create-app.ts b/packages/twenty-server/test/integration/utils/create-app.ts similarity index 100% rename from packages/twenty-server/test/utils/create-app.ts rename to packages/twenty-server/test/integration/utils/create-app.ts diff --git a/packages/twenty-server/test/integration/utils/generate-record-name.ts b/packages/twenty-server/test/integration/utils/generate-record-name.ts new file mode 100644 index 000000000000..123de9b6b17d --- /dev/null +++ b/packages/twenty-server/test/integration/utils/generate-record-name.ts @@ -0,0 +1,4 @@ +export const TEST_NAME_PREFIX = 'test_record_'; + +export const generateRecordName = (uuid: string) => + `${TEST_NAME_PREFIX}-${uuid}`; diff --git a/packages/twenty-server/test/integration/utils/make-graphql-api-request.ts b/packages/twenty-server/test/integration/utils/make-graphql-api-request.ts new file mode 100644 index 000000000000..21b3e889716c --- /dev/null +++ b/packages/twenty-server/test/integration/utils/make-graphql-api-request.ts @@ -0,0 +1,19 @@ +import { ASTNode, print } from 'graphql'; +import request from 'supertest'; + +type GraphqlOperation = { + query: ASTNode; + variables?: Record; +}; + +export const makeGraphqlAPIRequest = (graphqlOperation: GraphqlOperation) => { + const client = request(`http://localhost:${APP_PORT}`); + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send({ + query: print(graphqlOperation.query), + variables: graphqlOperation.variables || {}, + }); +}; diff --git a/packages/twenty-server/test/utils/setup-test.ts b/packages/twenty-server/test/integration/utils/setup-test.ts similarity index 100% rename from packages/twenty-server/test/utils/setup-test.ts rename to packages/twenty-server/test/integration/utils/setup-test.ts diff --git a/packages/twenty-server/test/integration/utils/teardown-test.ts b/packages/twenty-server/test/integration/utils/teardown-test.ts new file mode 100644 index 000000000000..8cc1946d5053 --- /dev/null +++ b/packages/twenty-server/test/integration/utils/teardown-test.ts @@ -0,0 +1,5 @@ +import 'tsconfig-paths/register'; + +export default async () => { + global.app.close(); +}; diff --git a/packages/twenty-server/test/utils/api-requests.ts b/packages/twenty-server/test/utils/api-requests.ts deleted file mode 100644 index 6c5d9fce54ca..000000000000 --- a/packages/twenty-server/test/utils/api-requests.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { ASTNode, print } from 'graphql'; -import gql from 'graphql-tag'; -import pluralize from 'pluralize'; -import request from 'supertest'; - -type QueryData = { - query: ASTNode; - variables?: Record; -}; - -type StandardObjectsSingularName = 'Company' | 'Person'; - -export const makeGraphqlAPIRequest = (data: QueryData) => { - const client = request(`http://localhost:${APP_PORT}`); - - return client - .post('/graphql') - .set('Authorization', `Bearer ${ACCESS_TOKEN}`) - .send({ query: print(data.query), variables: data.variables || {} }); -}; - -export const expectSuccessfullGraphqlAPIRequest = (data: QueryData) => { - return makeGraphqlAPIRequest(data).expect((res) => { - expect(res.body.errors).toBeUndefined(); - expect(res.body.data).toBeDefined(); - }); -}; - -export const createOneObject = async ( - ObjectSingularName: StandardObjectsSingularName, - data: object, -) => { - const mutationName = `create${ObjectSingularName}`; - - const query = gql` - mutation Create${ObjectSingularName}($data: ${ObjectSingularName}CreateInput) { - ${mutationName}(data: $data) { - id - } - } - `; - - const variables = { - data, - }; - - return await expectSuccessfullGraphqlAPIRequest({ query, variables }).then( - (res) => { - const createdObject = res.body.data[mutationName]; - - return createdObject.id as string; - }, - ); -}; - -export const createManyObjects = async ( - ObjectSingularName: StandardObjectsSingularName, - data: object[], -) => { - const objectPluralName = pluralize(ObjectSingularName); - const mutationName = `create${objectPluralName}`; - - const query = gql` - mutation Create${objectPluralName}($data: [${ObjectSingularName}CreateInput!]) { - ${mutationName}(data: $data) { - id - } - } - `; - - const variables = { - data, - }; - - return await expectSuccessfullGraphqlAPIRequest({ query, variables }).then( - (res) => { - const createdObjectsIds: string[] = res.body.data[mutationName].map( - (object) => object.id, - ); - - return createdObjectsIds; - }, - ); -}; diff --git a/packages/twenty-server/test/utils/generate-record-name.ts b/packages/twenty-server/test/utils/generate-record-name.ts deleted file mode 100644 index fc71362273b6..000000000000 --- a/packages/twenty-server/test/utils/generate-record-name.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const TEST_NAME_PREFIX = 'integration_test_record_'; - -export const generateRecordName = () => - `${TEST_NAME_PREFIX}${Math.floor(Math.random() * 1000)}`; diff --git a/packages/twenty-server/test/utils/teardown-test.ts b/packages/twenty-server/test/utils/teardown-test.ts deleted file mode 100644 index c5905dbf9d78..000000000000 --- a/packages/twenty-server/test/utils/teardown-test.ts +++ /dev/null @@ -1,51 +0,0 @@ -import gql from 'graphql-tag'; -import { makeGraphqlAPIRequest } from 'test/utils/api-requests'; -import { TEST_NAME_PREFIX } from 'test/utils/generate-record-name'; -import 'tsconfig-paths/register'; - -// eslint-disable-next-line no-restricted-imports -import jestConfig from '../../jest-integration.config'; - -const query = gql` - mutation DestroyObjects( - $nameFilter: CompanyFilterInput - $personFilter: PersonFilterInput - ) { - destroyCompanies(filter: $nameFilter) { - id - } - destroyPeople(filter: $personFilter) { - id - } - } -`; -const nameFilter = { - name: { - ilike: `%${TEST_NAME_PREFIX}%`, - }, -}; - -const personFilter = { - name: { - firstName: { - ilike: `%${TEST_NAME_PREFIX}%`, - }, - }, -}; - -export default async () => { - // @ts-expect-error in the teardown this env is not present in the global object anymore - global.APP_PORT = jestConfig.globals?.APP_PORT; - // @ts-expect-error in the teardown this env is not present in the global object anymore - global.ACCESS_TOKEN = jestConfig.globals?.ACCESS_TOKEN; - makeGraphqlAPIRequest({ - query, - variables: { - nameFilter, - personFilter, - }, - }).then((res) => { - if (res.body.errors) throw new Error(JSON.stringify(res.body.errors)); - global.app.close(); - }); -}; From 7efde6384bc6ed542b339c5652e00d922b2dfc96 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Thu, 17 Oct 2024 18:44:35 +0200 Subject: [PATCH 4/7] Improve tests --- packages/twenty-server/.env.test | 7 +- .../twenty-server/jest-integration.config.ts | 8 +- packages/twenty-server/project.json | 4 +- .../graphql/auth.integration-spec.ts | 80 --- .../integration/graphql/codegen}/index.ts | 2 +- .../graphql/codegen}/introspection-query.ts | 0 .../codegen}/introspection.interface.ts | 0 .../companies.integration-queries.ts | 141 ---- .../companies/companies.integration-spec.ts | 602 ------------------ .../suites/all-resolvers.integration-spec.ts | 352 ++++++++++ .../activities.integration-spec.ts | 2 +- .../activity-targets.integration-spec.ts | 4 +- .../api-keys.integration-spec.ts | 2 +- .../attachments.integration-spec.ts | 4 +- .../audit-logs.integration-spec.ts | 2 +- .../blocklists.integration-spec.ts | 2 +- ...nel-event-associations.integration-spec.ts | 16 +- .../calendar-channels.integration-spec.ts | 8 +- ...dar-event-participants.integration-spec.ts | 2 +- .../calendar-events.integration-spec.ts | 73 +++ .../comments.integration-spec.ts | 2 +- .../companies.integration-spec.ts | 69 ++ .../connected-accounts.integration-spec.ts | 4 +- .../favorites.integration-spec.ts | 10 +- .../index-metadatas.integration-spec.ts | 59 ++ ...l-message-associations.integration-spec.ts | 18 +- .../message-channels.integration-spec.ts | 10 +- .../message-participants.integration-spec.ts | 2 +- .../message-threads.integration-spec.ts | 2 +- .../messages.integration-spec.ts | 66 ++ .../note-targets.integration-spec.ts | 4 +- .../notes.integration-spec.ts | 2 +- .../objects.integration-spec.ts | 2 +- .../opportunities.integration-spec.ts | 4 +- .../people.integration-spec.ts | 14 +- .../rockets.integration-spec.ts | 57 ++ .../search-activities.integration-spec.ts | 67 ++ ...earch-activity-targets.integration-spec.ts | 61 ++ .../search-api-keys.integration-spec.ts | 57 ++ .../search-attachments.integration-spec.ts | 73 +++ .../search-audit-logs.integration-spec.ts | 65 ++ .../search-blocklists.integration-spec.ts | 55 ++ ...nel-event-associations.integration-spec.ts | 59 ++ ...arch-calendar-channels.integration-spec.ts | 75 +++ ...dar-event-participants.integration-spec.ts | 65 ++ ...search-calendar-events.integration-spec.ts | 73 +++ .../search-comments.integration-spec.ts | 57 ++ .../search-companies.integration-spec.ts | 69 ++ ...rch-connected-accounts.integration-spec.ts | 69 ++ .../search-favorites.integration-spec.ts | 75 +++ ...l-message-associations.integration-spec.ts | 61 ++ ...earch-message-channels.integration-spec.ts | 81 +++ ...h-message-participants.integration-spec.ts | 63 ++ ...search-message-threads.integration-spec.ts | 51 ++ .../search-messages.integration-spec.ts | 61 ++ .../search-note-targets.integration-spec.ts | 61 ++ .../search-notes.integration-spec.ts | 57 ++ .../search-opportunities.integration-spec.ts | 65 ++ .../search-people.integration-spec.ts | 69 ++ .../search-rockets.integration-spec.ts | 57 ++ .../search-task-targets.integration-spec.ts | 61 ++ .../search-tasks.integration-spec.ts | 63 ++ ...ch-timeline-activities.integration-spec.ts | 83 +++ .../search-view-fields.integration-spec.ts | 61 ++ .../search-view-filters.integration-spec.ts | 61 ++ .../search-view-sorts.integration-spec.ts | 57 ++ .../search-views.integration-spec.ts | 67 ++ .../search-webhooks.integration-spec.ts | 57 ++ ...rkflow-event-listeners.integration-spec.ts | 55 ++ .../search-workflow-runs.integration-spec.ts | 69 ++ ...arch-workflow-versions.integration-spec.ts | 63 ++ .../search-workflows.integration-spec.ts | 59 ++ ...arch-workspace-members.integration-spec.ts | 67 ++ .../serverless-functions.integration-spec.ts | 59 ++ .../task-targets.integration-spec.ts | 4 +- .../tasks.integration-spec.ts | 2 +- .../timeline-activities.integration-spec.ts | 10 +- .../view-fields.integration-spec.ts | 2 +- .../view-filters.integration-spec.ts | 2 +- .../view-sorts.integration-spec.ts | 2 +- .../views.integration-spec.ts | 6 +- .../webhooks.integration-spec.ts | 6 +- ...rkflow-event-listeners.integration-spec.ts | 55 ++ .../workflow-runs.integration-spec.ts | 69 ++ .../workflow-versions.integration-spec.ts | 63 ++ .../workflows.integration-spec.ts | 59 ++ .../workspace-members.integration-spec.ts | 2 +- .../create-many-operation-factory.util.ts | 28 + .../create-one-operation-factory.util.ts | 26 + .../delete-many-operation-factory.util.ts | 30 + .../delete-one-operation-factory.util.ts | 26 + .../destroy-many-operation-factory.util.ts | 30 + .../destroy-one-operation-factory.util.ts | 26 + .../utils/find-many-operation-factory.util.ts | 32 + .../utils/find-one-operation-factory.util.ts | 26 + .../utils/make-graphql-api-request.util.ts} | 0 .../update-many-operation-factory.util.ts | 31 + .../update-one-operation-factory.util.ts | 26 + 98 files changed, 3720 insertions(+), 907 deletions(-) delete mode 100644 packages/twenty-server/test/integration/graphql/auth.integration-spec.ts rename packages/twenty-server/{scripts/generate-integration-tests => test/integration/graphql/codegen}/index.ts (98%) rename packages/twenty-server/{scripts/generate-integration-tests => test/integration/graphql/codegen}/introspection-query.ts (100%) rename packages/twenty-server/{scripts/generate-integration-tests => test/integration/graphql/codegen}/introspection.interface.ts (100%) delete mode 100644 packages/twenty-server/test/integration/graphql/companies/companies.integration-queries.ts delete mode 100644 packages/twenty-server/test/integration/graphql/companies/companies.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/activities.integration-spec.ts (97%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/activity-targets.integration-spec.ts (92%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/api-keys.integration-spec.ts (96%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/attachments.integration-spec.ts (94%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/audit-logs.integration-spec.ts (97%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/blocklists.integration-spec.ts (96%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/calendar-channel-event-associations.integration-spec.ts (86%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/calendar-channels.integration-spec.ts (91%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/calendar-event-participants.integration-spec.ts (96%) create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-events.integration-spec.ts rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/comments.integration-spec.ts (96%) create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/companies.integration-spec.ts rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/connected-accounts.integration-spec.ts (93%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/favorites.integration-spec.ts (82%) create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/index-metadatas.integration-spec.ts rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/message-channel-message-associations.integration-spec.ts (89%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/message-channels.integration-spec.ts (90%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/message-participants.integration-spec.ts (96%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/message-threads.integration-spec.ts (95%) create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/messages.integration-spec.ts rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/note-targets.integration-spec.ts (92%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/notes.integration-spec.ts (96%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/objects.integration-spec.ts (97%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/opportunities.integration-spec.ts (92%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/people.integration-spec.ts (82%) create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/rockets.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-activities.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-activity-targets.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-api-keys.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-attachments.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-audit-logs.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-blocklists.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channel-event-associations.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channels.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-event-participants.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-events.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-comments.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-companies.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-connected-accounts.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-favorites.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channel-message-associations.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channels.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-participants.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-threads.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-messages.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-note-targets.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-notes.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-opportunities.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-people.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-rockets.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-task-targets.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-tasks.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-timeline-activities.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-fields.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-filters.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-sorts.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-views.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-webhooks.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-event-listeners.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-runs.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-versions.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflows.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/search-workspace-members.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/serverless-functions.integration-spec.ts rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/task-targets.integration-spec.ts (92%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/tasks.integration-spec.ts (97%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/timeline-activities.integration-spec.ts (84%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/view-fields.integration-spec.ts (96%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/view-filters.integration-spec.ts (96%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/view-sorts.integration-spec.ts (96%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/views.integration-spec.ts (97%) rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/webhooks.integration-spec.ts (96%) create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-event-listeners.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-runs.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-versions.integration-spec.ts create mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/workflows.integration-spec.ts rename packages/twenty-server/test/integration/graphql/{ => suites/object-generated}/workspace-members.integration-spec.ts (97%) create mode 100644 packages/twenty-server/test/integration/graphql/utils/create-many-operation-factory.util.ts create mode 100644 packages/twenty-server/test/integration/graphql/utils/create-one-operation-factory.util.ts create mode 100644 packages/twenty-server/test/integration/graphql/utils/delete-many-operation-factory.util.ts create mode 100644 packages/twenty-server/test/integration/graphql/utils/delete-one-operation-factory.util.ts create mode 100644 packages/twenty-server/test/integration/graphql/utils/destroy-many-operation-factory.util.ts create mode 100644 packages/twenty-server/test/integration/graphql/utils/destroy-one-operation-factory.util.ts create mode 100644 packages/twenty-server/test/integration/graphql/utils/find-many-operation-factory.util.ts create mode 100644 packages/twenty-server/test/integration/graphql/utils/find-one-operation-factory.util.ts rename packages/twenty-server/test/integration/{utils/make-graphql-api-request.ts => graphql/utils/make-graphql-api-request.util.ts} (100%) create mode 100644 packages/twenty-server/test/integration/graphql/utils/update-many-operation-factory.util.ts create mode 100644 packages/twenty-server/test/integration/graphql/utils/update-one-operation-factory.util.ts diff --git a/packages/twenty-server/.env.test b/packages/twenty-server/.env.test index ed0c63d78337..ca9af9171bfa 100644 --- a/packages/twenty-server/.env.test +++ b/packages/twenty-server/.env.test @@ -11,12 +11,9 @@ EXCEPTION_HANDLER_DRIVER=console SENTRY_DSN=https://ba869cb8fd72d5faeb6643560939cee0@o4505516959793152.ingest.sentry.io/4506660900306944 DEMO_WORKSPACE_IDS=63db4589-590f-42b3-bdf1-85268b3da02f,8de58f3f-7e86-4a0b-998d-b2cbe314ee3a,4d957b72-0b37-4bad-9468-8dc828ee082d,daa0b739-269e-49b6-9be5-5f0215941489,59c15f6a-909a-4495-9cf4-3ce1b0abbb6a,7202cc9d-92da-4b52-a323-d29d38cd3b4e,5f071b0d-646b-411a-94f1-5d9ba9d5c6ac,7bc10973-897b-4767-ab2f-35cdac3b2aec,4b3ba0be-2d29-4b1e-be66-8ac7eb65d000,edfb500d-cc4e-4f22-8e2b-f139a9758a68,eee459c9-9057-4459-ae0d-d51d14c01635,3dd2f505-0075-4217-ba33-fc4244aeaaa9,3d1a9165-3f3f-494e-a99d-f858eae95144,84db6ded-cfce-4aee-9160-6553b05c8143,96fb1540-269b-4d13-af21-2a8268eff8ca,b2463e69-d121-4ea5-80c9-bba82403e93e,5af30c15-867d-49ed-b939-d4856bed8514,b5677aa1-68fa-4818-aaaa-434a07ae2ed4,1ec7fa9a-d6bf-4fa2-a753-9a235d75ee3f,753a6fa2-df27-4c87-8c90-4da78fcb30dd,2138f2f2-bbe9-41df-b483-687a9075f94e,a885cfef-4636-4c3a-9788-1ff6e6b92df5,5458f7fb-9431-47a2-b7a0-32f31d115e23,6c09929f-11c3-4f92-9508-aa0e6b934d1e,57ae0a2c-7a4e-4c7d-8f43-68548e7f1206,cc7f0b85-6868-4c2d-85c5-3ce9977ea346,21871a7f-f067-45ea-989e-44339bb5ad07,c3efedab-84f5-4656-8297-55964b3d26cb,647dcdd1-4540-4003-9f58-fd84d4d759b7,fc5e6857-8d67-47b8-98f2-edeb0671e326,1ad8d72c-1826-40ed-8b44-d15a1d2aab70,eac6c90a-d25d-4c8c-a053-cfbc7cde0afb,023a70de-a85e-43fc-bbc6-757fbf6562f0,f3f0a7fb-1409-443b-8e39-4e58e628796e,62828804-97d4-40ec-82fa-2992a6ce4a81,af5441fe-b16f-4996-87f4-1a433ec53dd6,e8857860-f7b1-4478-9741-1eb9e7c11f2c,6bca9c44-c8c0-49f8-b0b5-1bb2ca7842b8,d50da092-09df-448f-84ea-3ebddfe1d9f6,9efd5d6d-db64-47d4-9ad3-5e4d8b65ff7f,6f089094-2dd2-4b0e-b5b7-8bb52b93ea8e,299b0822-68e9-4bfa-af35-da799012e80e,a3dd579c-93be-45a0-ad35-f518d8ed45dd,023b1b3e-4891-4061-aae0-f34368644f40,50174445-33c5-4482-bb8c-3ef6c511c8cd,9933c048-07a7-4735-9af2-940c2f9b6683,beadc568-3962-46bd-ad4d-06e23b37615b,0cdafc9f-d4c1-4576-837e-d7f6ec28643d,50bb24ce-1709-4928-a87b-d9d9e147a2ab,7690ed72-910d-4357-8e0e-17aa702b0b94,1ad0d69f-60fa-414f-bf79-4f94c2abba43,946d84a4-db4d-48cb-a5d3-03081b5c7e8e,1a080055-d2bf-4b14-8957-88a7d08769b8,ed343e38-e405-4fae-9486-27b09c98bdad,c8bdef75-a98c-4646-a372-3251340d2dea,87a8c6fa-f93e-4950-aff2-5f956ca1a6ba,604781ba-23c2-4220-a717-b5615431fcd9,31af6841-ad9f-4f28-a637-b5c5e6589447,cf067451-7b88-4ff2-a96d-3fc9c5d6fea0,26a8ad5e-29d9-4e7d-aa1f-e6221e8ea32a,fd14db29-e4df-44a7-9b3f-d00384458122,73b477a8-fcf4-4860-a685-65a0a79b8653,82e0f305-4c6c-4160-be1d-b0de834124e6,e38567ab-a6e2-4a94-99c5-a7db31c0aae8,faf3d6dc-66ff-4c1b-9658-f65a9cd9fcf1,6df6bb90-200e-4290-b73d-9bb374554229,2ff10cf4-a871-404a-9e7b-5ca7a232567e,06c614e2-0f36-4b72-8c82-59631680add2,5e508c81-3453-4185-ae8c-4c9b841f8c15,21b5c371-6010-4b1b-be67-7538eb877efb,54e61442-e291-4eea-8d49-7f11b5f85bd2,b6b7260a-4eea-40b0-9f7f-1dfd4c3cc7a8,e163fe76-30fb-44fb-b51a-50cc78745a21,4da672f2-29b4-4a98-b27c-b39a4aecc858,2fdb0601-c882-4aaf-ad49-ae17e530d47a,49525e1b-1b47-4545-a98c-0ba58778179f,f958ab32-b152-4004-9228-18148f7380f1,0ff5025a-62cd-4a10-a722-79f7cf360f01,642df445-e314-409a-a97d-64fc2aa2a15e,38b0dab5-d4fb-44f9-8cf9-bb35cf82e91d,62054133-f35a-4f64-a2ee-a31e48952835,536dbe8c-af33-4eab-a0a8-8d039a00db40,a04998ba-52c9-4538-b6d9-6d04408dbaf2,89016c7a-3d36-4619-a5c6-4f31795eebf7,7708b9a9-776c-46fc-94a4-dc28e7880958,5c92bc69-b328-4c66-a791-a05dbaf7a6f8,ad580a50-80b4-44be-9bc4-f2b57cd23207,36c0241c-891e-4b74-bd10-5e99df96bbc8,a96842ff-18be-4536-a23d-20d973d91621,0ea549b0-9558-4bdf-9944-5abc707c7660,0186c353-5ed2-4c94-b71a-fc0b48c90288,1508a165-2217-4911-b31c-1ea42a08f097,1731e392-dfdf-4fc4-863b-27ae62b0e374,0b245cea-96a6-4a3a-af6a-ef43496c239c,a844e208-7078-43a2-8bd0-86f31498cd3f,53d112b5-87f2-490b-a788-df1f4624f9ad,0d5794d4-3a52-482b-9a6a-f8185018bad1,df877aa6-231c-47fb-9be0-906e61677356,c56c6d1a-3418-49d2-82ce-bd9370668043,6e0b6f34-3cd0-4aa0-ae1f-25f5545dca68 MUTATION_MAXIMUM_RECORD_AFFECTED=100 -MESSAGE_QUEUE_TYPE=pg-boss +MESSAGE_QUEUE_TYPE=bull-mq CACHE_STORAGE_TYPE=redis -REDIS_HOST=127.0.0.1 -REDIS_PORT=6379 -REDIS_USERNAME=default -REDIS_PASSWORD= +REDIS_URL=redis://localhost:6378 AUTH_GOOGLE_ENABLED=false MESSAGING_PROVIDER_GMAIL_ENABLED=false diff --git a/packages/twenty-server/jest-integration.config.ts b/packages/twenty-server/jest-integration.config.ts index b629f01b60ce..deb2ba3ee5a1 100644 --- a/packages/twenty-server/jest-integration.config.ts +++ b/packages/twenty-server/jest-integration.config.ts @@ -11,11 +11,13 @@ const jestConfig: JestConfigWithTsJest = { testEnvironment: 'node', testRegex: '.integration-spec.ts$', modulePathIgnorePatterns: ['/dist'], - globalSetup: '/test/utils/setup-test.ts', - globalTeardown: '/test/utils/teardown-test.ts', + globalSetup: '/test/integration/utils/setup-test.ts', + globalTeardown: '/test/integration/utils/teardown-test.ts', testTimeout: 15000, moduleNameMapper: { - ...pathsToModuleNameMapper(tsConfig.compilerOptions.paths), + ...pathsToModuleNameMapper(tsConfig.compilerOptions.paths, { + prefix: '/../..', + }), '^test/(.*)$': '/test/$1', 'twenty-emails': '/../twenty-emails/dist/index.js', }, diff --git a/packages/twenty-server/project.json b/packages/twenty-server/project.json index ed8ad716b6e0..12f1fe5703ad 100644 --- a/packages/twenty-server/project.json +++ b/packages/twenty-server/project.json @@ -16,7 +16,7 @@ "options": { "cwd": "packages/twenty-server", "commands": [ - "NODE_ENV=test nx database:reset > reset-logs.log && NODE_ENV=test nx jest --config ./jest-integration.config.ts" + "NODE_ENV=test nx jest --config ./jest-integration.config.ts" ] }, "parallel": false @@ -162,7 +162,7 @@ "options": { "cwd": "packages/twenty-server", "commands": [ - "nx ts-node-no-deps -- ./scripts/generate-integration-tests/index.ts" + "nx ts-node-no-deps -- ./test/integration/graphql/codegen/index.ts" ], "parallel": false } diff --git a/packages/twenty-server/test/integration/graphql/auth.integration-spec.ts b/packages/twenty-server/test/integration/graphql/auth.integration-spec.ts deleted file mode 100644 index 64cdde13cd6b..000000000000 --- a/packages/twenty-server/test/integration/graphql/auth.integration-spec.ts +++ /dev/null @@ -1,80 +0,0 @@ -import request from 'supertest'; - -const client = request(`http://localhost:${APP_PORT}`); - -const auth = { - email: 'tim@apple.dev', - password: 'Applecar2025', -}; - -describe('AuthResolve (integration)', () => { - let loginToken: string; - - it('should challenge with email and password', () => { - const queryData = { - query: ` - mutation Challenge { - challenge(email: "${auth.email}", password: "${auth.password}") { - loginToken { - token - expiresAt - } - } - } - `, - }; - - return client - .post('/graphql') - .send(queryData) - .expect(200) - .expect((res) => { - expect(res.body.data).toBeDefined(); - expect(res.body.errors).toBeUndefined(); - }) - .expect((res) => { - const data = res.body.data.challenge; - - expect(data).toBeDefined(); - expect(data.loginToken).toBeDefined(); - - loginToken = data.loginToken.token; - }); - }); - - it('should verify with login token', () => { - const queryData = { - query: ` - mutation Verify { - verify(loginToken: "${loginToken}") { - tokens { - accessToken { - token - } - } - } - } - `, - }; - - return client - .post('/graphql') - .send(queryData) - .expect(200) - .expect((res) => { - expect(res.body.data).toBeDefined(); - expect(res.body.errors).toBeUndefined(); - }) - .expect((res) => { - const data = res.body.data.verify; - - expect(data).toBeDefined(); - expect(data.tokens).toBeDefined(); - - const accessToken = data.tokens.accessToken; - - expect(accessToken).toBeDefined(); - expect(accessToken.token).toBeDefined(); - }); - }); -}); diff --git a/packages/twenty-server/scripts/generate-integration-tests/index.ts b/packages/twenty-server/test/integration/graphql/codegen/index.ts similarity index 98% rename from packages/twenty-server/scripts/generate-integration-tests/index.ts rename to packages/twenty-server/test/integration/graphql/codegen/index.ts index 5b635d3bccd7..9f1937cae2b5 100644 --- a/packages/twenty-server/scripts/generate-integration-tests/index.ts +++ b/packages/twenty-server/test/integration/graphql/codegen/index.ts @@ -13,7 +13,7 @@ import { const GRAPHQL_URL = 'http://localhost:3000/graphql'; const BEARER_TOKEN = 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyMDIwMjAyMC05ZTNiLTQ2ZDQtYTU1Ni04OGI5ZGRjMmIwMzQiLCJ3b3Jrc3BhY2VJZCI6IjIwMjAyMDIwLTFjMjUtNGQwMi1iZjI1LTZhZWNjZjdlYTQxOSIsIndvcmtzcGFjZU1lbWJlcklkIjoiMjAyMDIwMjAtMDY4Ny00YzQxLWI3MDctZWQxYmZjYTk3MmE3IiwiaWF0IjoxNzI2NDkyNTAyLCJleHAiOjEzMjQ1MDE2NTAyfQ.zM6TbfeOqYVH5Sgryc2zf02hd9uqUOSL1-iJlMgwzsI'; -const TEST_OUTPUT_DIR = './test'; +const TEST_OUTPUT_DIR = './test/integration/graphql/suites/object-generated'; const fetchGraphQLSchema = async (): Promise => { const headers = { diff --git a/packages/twenty-server/scripts/generate-integration-tests/introspection-query.ts b/packages/twenty-server/test/integration/graphql/codegen/introspection-query.ts similarity index 100% rename from packages/twenty-server/scripts/generate-integration-tests/introspection-query.ts rename to packages/twenty-server/test/integration/graphql/codegen/introspection-query.ts diff --git a/packages/twenty-server/scripts/generate-integration-tests/introspection.interface.ts b/packages/twenty-server/test/integration/graphql/codegen/introspection.interface.ts similarity index 100% rename from packages/twenty-server/scripts/generate-integration-tests/introspection.interface.ts rename to packages/twenty-server/test/integration/graphql/codegen/introspection.interface.ts diff --git a/packages/twenty-server/test/integration/graphql/companies/companies.integration-queries.ts b/packages/twenty-server/test/integration/graphql/companies/companies.integration-queries.ts deleted file mode 100644 index 8ed88b26afa2..000000000000 --- a/packages/twenty-server/test/integration/graphql/companies/companies.integration-queries.ts +++ /dev/null @@ -1,141 +0,0 @@ -import gql from 'graphql-tag'; - -const companyProperties = ` - id - name - employees - idealCustomerProfile - position - createdAt - updatedAt - deletedAt - accountOwnerId - tagline - workPolicy - visaSponsorship -`; - -export const findCompanyQuery = gql` - query Company($filter: CompanyFilterInput) { - company(filter: $filter) { - ${companyProperties} - } - } -`; - -export const findCompaniesQuery = gql` - query Companies($filter: CompanyFilterInput) { - companies(filter: $filter) { - edges { - node { - ${companyProperties} - } - } - } - } -`; - -export const createCompanyMutation = gql` - mutation CreateCompany($data: CompanyCreateInput) { - createCompany(data: $data) { - ${companyProperties} - } - } -`; - -export const createCompaniesMutation = gql` - mutation CreateCompanies($data: [CompanyCreateInput!]!) { - createCompanies(data: $data) { - ${companyProperties} - } - } -`; - -export const updateCompanyMutation = gql` - mutation UpdateCompany($companyId: ID, $data: CompanyUpdateInput) { - updateCompany(id: $companyId, data: $data) { - name - } - } -`; - -export const updateCompaniesMutation = gql` - mutation UpdateCompanies( - $data: CompanyUpdateInput - $filter: CompanyFilterInput - ) { - updateCompanies(data: $data, filter: $filter) { - id - name - } - } -`; - -export const deleteCompanyMutation = gql` - mutation DeleteCompany($companyId: ID!) { - deleteCompany(id: $companyId) { - deletedAt - } - } -`; - -export const deleteCompaniesMutation = gql` - mutation DeleteCompanies($filter: CompanyFilterInput) { - deleteCompanies(filter: $filter) { - deletedAt - } - } -`; - -export const destroyCompanyMutation = gql` - mutation DestroyCompany($companyId: ID!) { - destroyCompany(id: $companyId) { - deletedAt - } - } -`; - -export const destroyCompaniesMutation = gql` - mutation DestroyCompanies($filter: CompanyFilterInput) { - destroyCompanies(filter: $filter) { - deletedAt - } - } -`; - -export const updatePersonMutation = gql` - mutation UpdatePerson($personId: ID!, $data: PersonUpdateInput!) { - updatePerson(id: $personId, data: $data) { - id - } - } -`; - -export const findCompanyWithPeopleRelationQuery = gql` - query Company($filter: CompanyFilterInput) { - company(filter: $filter) { - people { - edges { - node { - id - name { - firstName - } - companyId - } - } - } - } - } -`; - -export const findPersonWithCompanyRelationQuery = gql` - query Person($filter: PersonFilterInput) { - person(filter: $filter) { - company { - id - name - } - } - } -`; diff --git a/packages/twenty-server/test/integration/graphql/companies/companies.integration-spec.ts b/packages/twenty-server/test/integration/graphql/companies/companies.integration-spec.ts deleted file mode 100644 index 0e8d3e8ec2a7..000000000000 --- a/packages/twenty-server/test/integration/graphql/companies/companies.integration-spec.ts +++ /dev/null @@ -1,602 +0,0 @@ -import { - createCompaniesMutation, - createCompanyMutation, - deleteCompaniesMutation, - deleteCompanyMutation, - destroyCompaniesMutation, - destroyCompanyMutation, - findCompaniesQuery, - findCompanyQuery, - findCompanyWithPeopleRelationQuery, - findPersonWithCompanyRelationQuery, - updateCompaniesMutation, - updatePersonMutation, -} from 'test/integration/graphql/companies/companies.integration-queries'; -import { generateRecordName } from 'test/integration/utils/generate-record-name'; -import { makeGraphqlAPIRequest } from 'test/integration/utils/make-graphql-api-request'; - -const COMPANY_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987'; -const COMPANY_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988'; -const COMPANY_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989'; - -describe('companies resolvers (integration)', () => { - it('1. should create and return companies', async () => { - const companyName1 = generateRecordName(COMPANY_1_ID); - const companyName2 = generateRecordName(COMPANY_2_ID); - - const graphqlOperation = { - query: createCompaniesMutation, - variables: { - data: [ - { - id: COMPANY_1_ID, - name: companyName1, - }, - { - id: COMPANY_2_ID, - name: companyName2, - }, - ], - }, - }; - - const response = await makeGraphqlAPIRequest(graphqlOperation); - - expect(response.body.data.createCompanies).toHaveLength(2); - - response.body.data.createCompanies.forEach((company) => { - expect(company).toHaveProperty('name'); - expect([companyName1, companyName2]).toContain(company.name); - - expect(company).toHaveProperty('employees'); - expect(company).toHaveProperty('idealCustomerProfile'); - expect(company).toHaveProperty('position'); - expect(company).toHaveProperty('id'); - expect(company).toHaveProperty('createdAt'); - expect(company).toHaveProperty('updatedAt'); - expect(company).toHaveProperty('deletedAt'); - expect(company).toHaveProperty('accountOwnerId'); - expect(company).toHaveProperty('tagline'); - expect(company).toHaveProperty('workPolicy'); - expect(company).toHaveProperty('visaSponsorship'); - }); - }); - - describe('1b. should create and return one company', async () => { - const companyName = generateRecordName(COMPANY_3_ID); - - const graphqlOperation = { - query: createCompanyMutation, - variables: { - data: { - id: COMPANY_3_ID, - name: companyName, - }, - }, - }; - - const response = await makeGraphqlAPIRequest(graphqlOperation); - - const createdCompany = response.body.data.createCompany; - - expect(createdCompany).toHaveProperty('name'); - expect(createdCompany.name).toEqual(companyName); - - expect(createdCompany).toHaveProperty('employees'); - expect(createdCompany).toHaveProperty('idealCustomerProfile'); - expect(createdCompany).toHaveProperty('position'); - expect(createdCompany).toHaveProperty('id'); - expect(createdCompany).toHaveProperty('createdAt'); - expect(createdCompany).toHaveProperty('updatedAt'); - expect(createdCompany).toHaveProperty('deletedAt'); - expect(createdCompany).toHaveProperty('accountOwnerId'); - expect(createdCompany).toHaveProperty('tagline'); - expect(createdCompany).toHaveProperty('workPolicy'); - expect(createdCompany).toHaveProperty('visaSponsorship'); - }); - - it('2. should find many companies', async () => { - const findCompaniesQueryData = { - query: findCompaniesQuery, - }; - - const result = await makeGraphqlAPIRequest(findCompaniesQueryData); - - const data = result.body.data.companies; - - expect(data).toBeDefined(); - expect(Array.isArray(data.edges)).toBe(true); - - const edges = data.edges; - - if (edges.length > 0) { - const companies = edges[0].node; - - expect(companies).toHaveProperty('name'); - expect(companies).toHaveProperty('employees'); - expect(companies).toHaveProperty('idealCustomerProfile'); - expect(companies).toHaveProperty('position'); - expect(companies).toHaveProperty('id'); - expect(companies).toHaveProperty('createdAt'); - expect(companies).toHaveProperty('updatedAt'); - expect(companies).toHaveProperty('deletedAt'); - expect(companies).toHaveProperty('accountOwnerId'); - expect(companies).toHaveProperty('tagline'); - expect(companies).toHaveProperty('workPolicy'); - expect(companies).toHaveProperty('visaSponsorship'); - } - }); - - it('2b. should find one company', async () => { - const findOneCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: COMPANY_3_ID, - }, - }, - }, - }; - - expectSuccessfullGraphqlAPIRequest(findOneCompanyQueryData).expect( - (res) => { - const company = res.body.data.company; - - expect(company).toHaveProperty('name'); - - expect(company).toHaveProperty('employees'); - expect(company).toHaveProperty('idealCustomerProfile'); - expect(company).toHaveProperty('position'); - expect(company).toHaveProperty('id'); - expect(company).toHaveProperty('createdAt'); - expect(company).toHaveProperty('updatedAt'); - expect(company).toHaveProperty('deletedAt'); - expect(company).toHaveProperty('accountOwnerId'); - expect(company).toHaveProperty('tagline'); - expect(company).toHaveProperty('workPolicy'); - expect(company).toHaveProperty('visaSponsorship'); - }, - ); - }); - - it('3. should delete many companies', async () => { - const filter = { - id: { - in: [COMPANY_1_ID, COMPANY_2_ID], - }, - }; - - const deleteCompaniesQueryData = { - query: deleteCompaniesMutation, - variables: { - filter, - }, - }; - - const deleteCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - deleteCompaniesQueryData, - ); - - const deleteCompanies = deleteCompaniesResponse.body.data.deleteCompanies; - - expect(deleteCompanies).toHaveLength(2); - - deleteCompanies.forEach((company) => { - expect(company.deletedAt).toBeTruthy(); - }); - }); - - it('3b. should delete one company', async () => { - const deleteCompanyQueryData = { - query: deleteCompanyMutation, - variables: { - companyId: COMPANY_3_ID, - }, - }; - - const deleteCompanyResponse = await expectSuccessfullGraphqlAPIRequest( - deleteCompanyQueryData, - ); - - expect( - deleteCompanyResponse.body.data.deleteCompany.deletedAt, - ).toBeTruthy(); - }); - - it('4. should not find many companies anymore', async () => { - const filter = { - id: { - in: [COMPANY_1_ID, COMPANY_2_ID], - }, - }; - - const findCompaniesQueryData = { - query: findCompaniesQuery, - variables: { - filter, - }, - }; - - const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - findCompaniesQueryData, - ); - - expect(findCompaniesResponse.body.data.companies.edges).toHaveLength(0); - }); - - it('4b. should not find one company anymore', async () => { - const findCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: COMPANY_3_ID, - }, - }, - }, - }; - const findCompanyResponse = - await makeGraphqlAPIRequest(findCompanyQueryData); - - expect(findCompanyResponse.body.data.company).toBeNull(); - - expect( - findCompaniesResponse.body.data.companies.edges.filter( - (c) => c.node.id === COMPANY_3_ID, - ), - ).toHaveLength(0); - }); - - it('5. should find many deleted companies with deletedAt filter', async () => { - const findDeletedCompaniesQueryData = { - query: findCompaniesWithFilterQuery, - variables: { - filter: { - id: { - in: [COMPANY_1_ID, COMPANY_2_ID], - }, - not: { - deletedAt: { - is: 'NULL', - }, - }, - }, - }, - }; - - const findDeletedCompaniesResponse = - await expectSuccessfullGraphqlAPIRequest(findDeletedCompaniesQueryData); - - expect(findDeletedCompaniesResponse.body.data.companies.edges).toHaveLength( - 2, - ); - }); - - it('should find the deleted company with deletedAt filter', async () => { - const findDeletedCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: COMPANY_3_ID, - }, - not: { - deletedAt: { - is: 'NULL', - }, - }, - }, - }, - }; - - const findDeletedCompanyResponse = await makeGraphqlAPIRequest( - findDeletedCompanyQueryData, - ); - - expect(findDeletedCompanyResponse.body.data.company.id).toEqual( - COMPANY_3_ID, - ); - }); - - describe('destroyCompaniesResolver (integration)', () => { - it('should destroy companies and hide them from simple queries', async () => { - const filter = { - id: { - in: [COMPANY_1_ID, COMPANY_2_ID], - }, - }; - - const destroyCompaniesQueryData = { - query: destroyCompaniesMutation, - variables: { - filter, - }, - }; - - const destroyCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - destroyCompaniesQueryData, - ); - - expect(destroyCompaniesResponse.body.data.destroyCompanies).toHaveLength( - 2, - ); - - const findCompaniesQueryData = { - query: findCompaniesWithFilterQuery, - variables: { - filter, - }, - }; - - const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - findCompaniesQueryData, - ); - - expect( - findCompaniesResponse.body.data.companies.edges.filter((c) => - [COMPANY_1_ID, COMPANY_2_ID].includes(c.node.id), - ), - ).toHaveLength(0); - - const findDeletedCompaniesQueryData = { - query: findCompaniesWithFilterQuery, - variables: { - filter: { - id: { - in: [COMPANY_1_ID, COMPANY_2_ID], - }, - not: { - deletedAt: { - is: 'NULL', - }, - }, - }, - }, - }; - - const findDeletedCompaniesResponse = await makeGraphqlAPIRequest( - findDeletedCompaniesQueryData, - ); - - expect( - findDeletedCompaniesResponse.body.data.companies.edges, - ).toHaveLength(0); - }); - }); - - describe('destroyCompanyResolver (integration)', () => { - it('should destroy a company and hide it from simple queries', async () => { - const destroyCompanyQueryData = { - query: destroyCompanyMutation, - variables: { - companyId: COMPANY_3_ID, - }, - }; - - const destroyCompanyResponse = await expectSuccessfullGraphqlAPIRequest( - destroyCompanyQueryData, - ); - - expect(destroyCompanyResponse.body.data.destroyCompany).toBeTruthy(); - - const findCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: COMPANY_3_ID, - }, - }, - }, - }; - - const findCompanyResponse = - await makeGraphqlAPIRequest(findCompanyQueryData); - - expect(findCompanyResponse.body.data.company).toBeNull(); - - const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest({ - query: findCompaniesWithFilterQuery, - }); - - expect( - findCompaniesResponse.body.data.companies.edges.filter( - (c) => c.node.id === COMPANY_3_ID, - ), - ).toHaveLength(0); - - const findDeletedCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: COMPANY_3_ID, - }, - not: { - deletedAt: { - is: 'NULL', - }, - }, - }, - }, - }; - - const findDeletedCompanyResponse = await makeGraphqlAPIRequest( - findDeletedCompanyQueryData, - ); - - expect(findDeletedCompanyResponse.body.data.company).toBeNull(); - }); - }); - - describe('personCompanyRelationResolver (integration)', () => { - it('should create a company and a person and then update the person with companyId and query the company with person data', async () => { - const companyName = generateRecordName(); - const companyId = await createOneObject('Company', { - name: companyName, - }); - - const personName = generateRecordName(); - const personId = await createOneObject('Person', { - name: { - firstName: personName, - }, - }); - - await expectSuccessfullGraphqlAPIRequest({ - query: updatePersonMutation, - variables: { - personId, - data: { - companyId, - }, - }, - }); - - const findCompanyResponse = await expectSuccessfullGraphqlAPIRequest({ - query: findCompanyWithPeopleRelationQuery, - variables: { - filter: { - id: { eq: companyId }, - }, - }, - }); - - const findPersonResponse = await expectSuccessfullGraphqlAPIRequest({ - query: findPersonWithCompanyRelationQuery, - variables: { - filter: { - id: { eq: personId }, - }, - }, - }); - - expect(findCompanyResponse.body.data.company).toEqual( - expect.objectContaining({ - people: { - edges: [ - { - node: { - id: personId, - companyId, - name: { - firstName: personName, - }, - }, - }, - ], - }, - }), - ); - - expect(findPersonResponse.body.data.person).toEqual( - expect.objectContaining({ - company: { - id: companyId, - name: companyName, - }, - }), - ); - }); - }); - - describe('updateCompaniesResolver (integration)', () => { - it('should update companies and persist the changes', async () => { - const companiesIds = await createManyObjects('Company', [ - { name: generateRecordName() }, - { name: generateRecordName() }, - ]); - - const filter = { - id: { - in: companiesIds, - }, - }; - - const newName = generateRecordName(); - const updateCompaniesQueryData = { - query: updateCompaniesMutation, - variables: { - data: { - name: newName, - }, - filter, - }, - }; - - const updateCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - updateCompaniesQueryData, - ); - - expect(updateCompaniesResponse.body.data.updateCompanies).toHaveLength( - companiesIds.length, - ); - - const findCompaniesQueryData = { - query: findCompaniesWithFilterQuery, - variables: { - filter, - }, - }; - - const findCompaniesResponse = await expectSuccessfullGraphqlAPIRequest( - findCompaniesQueryData, - ); - - const edges = findCompaniesResponse.body.data.companies.edges; - - expect(edges).toHaveLength(companiesIds.length); - - edges.forEach((edge) => { - expect(edge.node.name).toEqual(newName); - expect(companiesIds).toContain(edge.node.id); - }); - }); - }); - - describe('updateCompanyResolver (integration)', () => { - it('should update and persist the company update', async () => { - const companyName = generateRecordName(); - const createdCompanyId = await createOneObject('Company', { - name: companyName, - }); - const updateCompanyQueryData = { - query: updateCompaniesMutation, - variables: { - companyId: createdCompanyId, - data: { - name: companyName, - }, - }, - }; - - expectSuccessfullGraphqlAPIRequest(updateCompanyQueryData).expect( - (res) => { - const updatedCompany = res.body.data.updateCompany; - - expect(updatedCompany).toHaveProperty('name'); - expect(updatedCompany.name).toEqual(companyName); - }, - ); - - const findCompanyQueryData = { - query: findCompanyQuery, - variables: { - filter: { - id: { - eq: createdCompanyId, - }, - }, - }, - }; - - expectSuccessfullGraphqlAPIRequest(findCompanyQueryData).expect((res) => { - const company = res.body.data.company; - - expect(company).toHaveProperty('name'); - expect(company.name).toEqual(companyName); - }); - }); - }); -}); diff --git a/packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts new file mode 100644 index 000000000000..e102fe9422d6 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts @@ -0,0 +1,352 @@ +import { createManyOperationFactory } from 'test/integration/graphql/utils/create-many-operation-factory.util'; +import { createOneOperationFactory } from 'test/integration/graphql/utils/create-one-operation-factory.util'; +import { deleteManyOperationFactory } from 'test/integration/graphql/utils/delete-many-operation-factory.util'; +import { deleteOneOperationFactory } from 'test/integration/graphql/utils/delete-one-operation-factory.util'; +import { destroyManyOperationFactory } from 'test/integration/graphql/utils/destroy-many-operation-factory.util'; +import { destroyOneOperationFactory } from 'test/integration/graphql/utils/destroy-one-operation-factory.util'; +import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util'; +import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util'; +import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util'; +import { generateRecordName } from 'test/integration/utils/generate-record-name'; + +const COMPANY_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987'; +const COMPANY_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988'; +const COMPANY_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989'; +const COMPANY_GQL_FIELDS = ` + id + name + employees + idealCustomerProfile + position + createdAt + updatedAt + deletedAt + accountOwnerId + tagline + workPolicy + visaSponsorship +`; + +describe('companies resolvers (integration)', () => { + it('1. should create and return companies', async () => { + const companyName1 = generateRecordName(COMPANY_1_ID); + const companyName2 = generateRecordName(COMPANY_2_ID); + + const graphqlOperation = createManyOperationFactory({ + objectMetadataSingularName: 'company', + objectMetadataPluralName: 'companies', + gqlFields: COMPANY_GQL_FIELDS, + data: [ + { + id: COMPANY_1_ID, + name: companyName1, + }, + { + id: COMPANY_2_ID, + name: companyName2, + }, + ], + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + expect(response.body.data.createCompanies).toHaveLength(2); + + response.body.data.createCompanies.forEach((company) => { + expect(company).toHaveProperty('name'); + expect([companyName1, companyName2]).toContain(company.name); + + expect(company).toHaveProperty('employees'); + expect(company).toHaveProperty('idealCustomerProfile'); + expect(company).toHaveProperty('position'); + expect(company).toHaveProperty('id'); + expect(company).toHaveProperty('createdAt'); + expect(company).toHaveProperty('updatedAt'); + expect(company).toHaveProperty('deletedAt'); + expect(company).toHaveProperty('accountOwnerId'); + expect(company).toHaveProperty('tagline'); + expect(company).toHaveProperty('workPolicy'); + expect(company).toHaveProperty('visaSponsorship'); + }); + }); + + it('1b. should create and return one company', async () => { + const companyName = generateRecordName(COMPANY_3_ID); + + const graphqlOperation = createOneOperationFactory({ + objectMetadataSingularName: 'company', + gqlFields: COMPANY_GQL_FIELDS, + data: { + id: COMPANY_3_ID, + name: companyName, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + const createdCompany = response.body.data.createCompany; + + expect(createdCompany).toHaveProperty('name'); + expect(createdCompany.name).toEqual(companyName); + + expect(createdCompany).toHaveProperty('employees'); + expect(createdCompany).toHaveProperty('idealCustomerProfile'); + expect(createdCompany).toHaveProperty('position'); + expect(createdCompany).toHaveProperty('id'); + expect(createdCompany).toHaveProperty('createdAt'); + expect(createdCompany).toHaveProperty('updatedAt'); + expect(createdCompany).toHaveProperty('deletedAt'); + expect(createdCompany).toHaveProperty('accountOwnerId'); + expect(createdCompany).toHaveProperty('tagline'); + expect(createdCompany).toHaveProperty('workPolicy'); + expect(createdCompany).toHaveProperty('visaSponsorship'); + }); + + it('2. should find many companies', async () => { + const graphqlOperation = findManyOperationFactory({ + objectMetadataSingularName: 'company', + objectMetadataPluralName: 'companies', + gqlFields: COMPANY_GQL_FIELDS, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + const data = response.body.data.companies; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const companies = edges[0].node; + + expect(companies).toHaveProperty('name'); + expect(companies).toHaveProperty('employees'); + expect(companies).toHaveProperty('idealCustomerProfile'); + expect(companies).toHaveProperty('position'); + expect(companies).toHaveProperty('id'); + expect(companies).toHaveProperty('createdAt'); + expect(companies).toHaveProperty('updatedAt'); + expect(companies).toHaveProperty('deletedAt'); + expect(companies).toHaveProperty('accountOwnerId'); + expect(companies).toHaveProperty('tagline'); + expect(companies).toHaveProperty('workPolicy'); + expect(companies).toHaveProperty('visaSponsorship'); + } + }); + + it('2b. should find one company', async () => { + const graphqlOperation = findOneOperationFactory({ + objectMetadataSingularName: 'company', + gqlFields: COMPANY_GQL_FIELDS, + filter: { + id: { + eq: COMPANY_3_ID, + }, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + const company = response.body.data.company; + + expect(company).toHaveProperty('name'); + + expect(company).toHaveProperty('employees'); + expect(company).toHaveProperty('idealCustomerProfile'); + expect(company).toHaveProperty('position'); + expect(company).toHaveProperty('id'); + expect(company).toHaveProperty('createdAt'); + expect(company).toHaveProperty('updatedAt'); + expect(company).toHaveProperty('deletedAt'); + expect(company).toHaveProperty('accountOwnerId'); + expect(company).toHaveProperty('tagline'); + expect(company).toHaveProperty('workPolicy'); + expect(company).toHaveProperty('visaSponsorship'); + }); + + it('3. should delete many companies', async () => { + const graphqlOperation = deleteManyOperationFactory({ + objectMetadataSingularName: 'company', + objectMetadataPluralName: 'companies', + gqlFields: COMPANY_GQL_FIELDS, + filter: { + id: { + in: [COMPANY_1_ID, COMPANY_2_ID], + }, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + const deleteCompanies = response.body.data.deleteCompanies; + + expect(deleteCompanies).toHaveLength(2); + + deleteCompanies.forEach((company) => { + expect(company.deletedAt).toBeTruthy(); + }); + }); + + it('3b. should delete one company', async () => { + const graphqlOperation = deleteOneOperationFactory({ + objectMetadataSingularName: 'company', + gqlFields: COMPANY_GQL_FIELDS, + recordId: COMPANY_3_ID, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + expect(response.body.data.deleteCompany.deletedAt).toBeTruthy(); + }); + + it('4. should not find many companies anymore', async () => { + const graphqlOperation = findManyOperationFactory({ + objectMetadataSingularName: 'company', + objectMetadataPluralName: 'companies', + gqlFields: COMPANY_GQL_FIELDS, + filter: { + id: { + in: [COMPANY_1_ID, COMPANY_2_ID], + }, + }, + }); + + const findCompaniesResponse = await makeGraphqlAPIRequest(graphqlOperation); + + expect(findCompaniesResponse.body.data.companies.edges).toHaveLength(0); + }); + + it('4b. should not find one company anymore', async () => { + const graphqlOperation = findOneOperationFactory({ + objectMetadataSingularName: 'company', + gqlFields: COMPANY_GQL_FIELDS, + filter: { + id: { + eq: COMPANY_3_ID, + }, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + expect(response.body.data.company).toBeNull(); + }); + + it('5. should find many deleted companies with deletedAt filter', async () => { + const graphqlOperation = findManyOperationFactory({ + objectMetadataSingularName: 'company', + objectMetadataPluralName: 'companies', + gqlFields: COMPANY_GQL_FIELDS, + filter: { + id: { + in: [COMPANY_1_ID, COMPANY_2_ID], + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + expect(response.body.data.companies.edges).toHaveLength(2); + }); + + it('5b. should find one deleted company with deletedAt filter', async () => { + const graphqlOperation = findOneOperationFactory({ + objectMetadataSingularName: 'company', + gqlFields: COMPANY_GQL_FIELDS, + filter: { + id: { + eq: COMPANY_3_ID, + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + expect(response.body.data.company.id).toEqual(COMPANY_3_ID); + }); + + it('6. should destroy many companies', async () => { + const graphqlOperation = destroyManyOperationFactory({ + objectMetadataSingularName: 'company', + objectMetadataPluralName: 'companies', + gqlFields: COMPANY_GQL_FIELDS, + filter: { + id: { + in: [COMPANY_1_ID, COMPANY_2_ID], + }, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + expect(response.body.data.destroyCompanies).toHaveLength(2); + }); + + it('6b. should destroy one company', async () => { + const graphqlOperation = destroyOneOperationFactory({ + objectMetadataSingularName: 'company', + gqlFields: COMPANY_GQL_FIELDS, + recordId: COMPANY_3_ID, + }); + + const destroyCompanyResponse = + await makeGraphqlAPIRequest(graphqlOperation); + + expect(destroyCompanyResponse.body.data.destroyCompany).toBeTruthy(); + }); + + it('7. should not find many companies anymore', async () => { + const graphqlOperation = findManyOperationFactory({ + objectMetadataSingularName: 'company', + objectMetadataPluralName: 'companies', + gqlFields: COMPANY_GQL_FIELDS, + filter: { + id: { + in: [COMPANY_1_ID, COMPANY_2_ID], + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + expect(response.body.data.companies.edges).toHaveLength(0); + }); + + it('7b. should not find one company anymore', async () => { + const graphqlOperation = findOneOperationFactory({ + objectMetadataSingularName: 'company', + gqlFields: COMPANY_GQL_FIELDS, + filter: { + id: { + eq: COMPANY_3_ID, + }, + not: { + deletedAt: { + is: 'NULL', + }, + }, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + expect(response.body.data.company).toBeNull(); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/activities.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/activities.integration-spec.ts similarity index 97% rename from packages/twenty-server/test/integration/graphql/activities.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/activities.integration-spec.ts index 01f262c8f295..0e0134578e44 100644 --- a/packages/twenty-server/test/integration/graphql/activities.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/activities.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('activitiesResolver (integration)', () => { +describe('activitiesResolver (e2e)', () => { it('should find many activities', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/activity-targets.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/activity-targets.integration-spec.ts similarity index 92% rename from packages/twenty-server/test/integration/graphql/activity-targets.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/activity-targets.integration-spec.ts index cbbeb216f0aa..99b4f0b1e10f 100644 --- a/packages/twenty-server/test/integration/graphql/activity-targets.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/activity-targets.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('activityTargetsResolver (integration)', () => { +describe('activityTargetsResolver (e2e)', () => { it('should find many activityTargets', () => { const queryData = { query: ` @@ -18,6 +18,7 @@ describe('activityTargetsResolver (integration)', () => { personId companyId opportunityId + rocketId } } } @@ -53,6 +54,7 @@ describe('activityTargetsResolver (integration)', () => { expect(activityTargets).toHaveProperty('personId'); expect(activityTargets).toHaveProperty('companyId'); expect(activityTargets).toHaveProperty('opportunityId'); + expect(activityTargets).toHaveProperty('rocketId'); } }); }); diff --git a/packages/twenty-server/test/integration/graphql/api-keys.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/api-keys.integration-spec.ts similarity index 96% rename from packages/twenty-server/test/integration/graphql/api-keys.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/api-keys.integration-spec.ts index a196db0861c4..5515abb9a620 100644 --- a/packages/twenty-server/test/integration/graphql/api-keys.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/api-keys.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('apiKeysResolver (integration)', () => { +describe('apiKeysResolver (e2e)', () => { it('should find many apiKeys', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/attachments.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/attachments.integration-spec.ts similarity index 94% rename from packages/twenty-server/test/integration/graphql/attachments.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/attachments.integration-spec.ts index 440a6484e6b1..fc9637963342 100644 --- a/packages/twenty-server/test/integration/graphql/attachments.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/attachments.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('attachmentsResolver (integration)', () => { +describe('attachmentsResolver (e2e)', () => { it('should find many attachments', () => { const queryData = { query: ` @@ -24,6 +24,7 @@ describe('attachmentsResolver (integration)', () => { personId companyId opportunityId + rocketId } } } @@ -65,6 +66,7 @@ describe('attachmentsResolver (integration)', () => { expect(attachments).toHaveProperty('personId'); expect(attachments).toHaveProperty('companyId'); expect(attachments).toHaveProperty('opportunityId'); + expect(attachments).toHaveProperty('rocketId'); } }); }); diff --git a/packages/twenty-server/test/integration/graphql/audit-logs.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/audit-logs.integration-spec.ts similarity index 97% rename from packages/twenty-server/test/integration/graphql/audit-logs.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/audit-logs.integration-spec.ts index 99a573235cda..77a4507188f8 100644 --- a/packages/twenty-server/test/integration/graphql/audit-logs.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/audit-logs.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('auditLogsResolver (integration)', () => { +describe('auditLogsResolver (e2e)', () => { it('should find many auditLogs', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/blocklists.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/blocklists.integration-spec.ts similarity index 96% rename from packages/twenty-server/test/integration/graphql/blocklists.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/blocklists.integration-spec.ts index d8080b3cd570..60da5e4673fd 100644 --- a/packages/twenty-server/test/integration/graphql/blocklists.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/blocklists.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('blocklistsResolver (integration)', () => { +describe('blocklistsResolver (e2e)', () => { it('should find many blocklists', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/calendar-channel-event-associations.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channel-event-associations.integration-spec.ts similarity index 86% rename from packages/twenty-server/test/integration/graphql/calendar-channel-event-associations.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channel-event-associations.integration-spec.ts index 5d03268b840d..ee1c1378af63 100644 --- a/packages/twenty-server/test/integration/graphql/calendar-channel-event-associations.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channel-event-associations.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('calendarChannelEventAssociationsResolver (integration)', () => { +describe('calendarChannelEventAssociationsResolver (e2e)', () => { it('should find many calendarChannelEventAssociations', () => { const queryData = { query: ` @@ -11,6 +11,7 @@ describe('calendarChannelEventAssociationsResolver (integration)', () => { edges { node { eventExternalId + recurringEventExternalId id createdAt updatedAt @@ -44,19 +45,14 @@ describe('calendarChannelEventAssociationsResolver (integration)', () => { if (edges.length > 0) { const calendarChannelEventAssociations = edges[0].node; - expect(calendarChannelEventAssociations).toHaveProperty( - 'eventExternalId', - ); + expect(calendarChannelEventAssociations).toHaveProperty('eventExternalId'); + expect(calendarChannelEventAssociations).toHaveProperty('recurringEventExternalId'); expect(calendarChannelEventAssociations).toHaveProperty('id'); expect(calendarChannelEventAssociations).toHaveProperty('createdAt'); expect(calendarChannelEventAssociations).toHaveProperty('updatedAt'); expect(calendarChannelEventAssociations).toHaveProperty('deletedAt'); - expect(calendarChannelEventAssociations).toHaveProperty( - 'calendarChannelId', - ); - expect(calendarChannelEventAssociations).toHaveProperty( - 'calendarEventId', - ); + expect(calendarChannelEventAssociations).toHaveProperty('calendarChannelId'); + expect(calendarChannelEventAssociations).toHaveProperty('calendarEventId'); } }); }); diff --git a/packages/twenty-server/test/integration/graphql/calendar-channels.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channels.integration-spec.ts similarity index 91% rename from packages/twenty-server/test/integration/graphql/calendar-channels.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channels.integration-spec.ts index 6056af6ac616..675eb29260d5 100644 --- a/packages/twenty-server/test/integration/graphql/calendar-channels.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channels.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('calendarChannelsResolver (integration)', () => { +describe('calendarChannelsResolver (e2e)', () => { it('should find many calendarChannels', () => { const queryData = { query: ` @@ -18,6 +18,7 @@ describe('calendarChannelsResolver (integration)', () => { contactAutoCreationPolicy isSyncEnabled syncCursor + syncedAt syncStageStartedAt throttleFailureCount id @@ -56,12 +57,11 @@ describe('calendarChannelsResolver (integration)', () => { expect(calendarChannels).toHaveProperty('syncStatus'); expect(calendarChannels).toHaveProperty('syncStage'); expect(calendarChannels).toHaveProperty('visibility'); - expect(calendarChannels).toHaveProperty( - 'isContactAutoCreationEnabled', - ); + expect(calendarChannels).toHaveProperty('isContactAutoCreationEnabled'); expect(calendarChannels).toHaveProperty('contactAutoCreationPolicy'); expect(calendarChannels).toHaveProperty('isSyncEnabled'); expect(calendarChannels).toHaveProperty('syncCursor'); + expect(calendarChannels).toHaveProperty('syncedAt'); expect(calendarChannels).toHaveProperty('syncStageStartedAt'); expect(calendarChannels).toHaveProperty('throttleFailureCount'); expect(calendarChannels).toHaveProperty('id'); diff --git a/packages/twenty-server/test/integration/graphql/calendar-event-participants.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-event-participants.integration-spec.ts similarity index 96% rename from packages/twenty-server/test/integration/graphql/calendar-event-participants.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-event-participants.integration-spec.ts index 50e65547e406..45a8c87a8471 100644 --- a/packages/twenty-server/test/integration/graphql/calendar-event-participants.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-event-participants.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('calendarEventParticipantsResolver (integration)', () => { +describe('calendarEventParticipantsResolver (e2e)', () => { it('should find many calendarEventParticipants', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-events.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-events.integration-spec.ts new file mode 100644 index 000000000000..38ff727a1ee0 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-events.integration-spec.ts @@ -0,0 +1,73 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('calendarEventsResolver (e2e)', () => { + it('should find many calendarEvents', () => { + const queryData = { + query: ` + query calendarEvents { + calendarEvents { + edges { + node { + title + isCanceled + isFullDay + startsAt + endsAt + externalCreatedAt + externalUpdatedAt + description + location + iCalUID + conferenceSolution + id + createdAt + updatedAt + deletedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.calendarEvents; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const calendarEvents = edges[0].node; + + expect(calendarEvents).toHaveProperty('title'); + expect(calendarEvents).toHaveProperty('isCanceled'); + expect(calendarEvents).toHaveProperty('isFullDay'); + expect(calendarEvents).toHaveProperty('startsAt'); + expect(calendarEvents).toHaveProperty('endsAt'); + expect(calendarEvents).toHaveProperty('externalCreatedAt'); + expect(calendarEvents).toHaveProperty('externalUpdatedAt'); + expect(calendarEvents).toHaveProperty('description'); + expect(calendarEvents).toHaveProperty('location'); + expect(calendarEvents).toHaveProperty('iCalUID'); + expect(calendarEvents).toHaveProperty('conferenceSolution'); + expect(calendarEvents).toHaveProperty('id'); + expect(calendarEvents).toHaveProperty('createdAt'); + expect(calendarEvents).toHaveProperty('updatedAt'); + expect(calendarEvents).toHaveProperty('deletedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/comments.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/comments.integration-spec.ts similarity index 96% rename from packages/twenty-server/test/integration/graphql/comments.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/comments.integration-spec.ts index 0f89ba5491e6..2508ff628acd 100644 --- a/packages/twenty-server/test/integration/graphql/comments.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/comments.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('commentsResolver (integration)', () => { +describe('commentsResolver (e2e)', () => { it('should find many comments', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/companies.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/companies.integration-spec.ts new file mode 100644 index 000000000000..1273e624b0ac --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/companies.integration-spec.ts @@ -0,0 +1,69 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('companiesResolver (e2e)', () => { + it('should find many companies', () => { + const queryData = { + query: ` + query companies { + companies { + edges { + node { + name + employees + idealCustomerProfile + position + searchVector + id + createdAt + updatedAt + deletedAt + accountOwnerId + tagline + workPolicy + visaSponsorship + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.companies; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const companies = edges[0].node; + + expect(companies).toHaveProperty('name'); + expect(companies).toHaveProperty('employees'); + expect(companies).toHaveProperty('idealCustomerProfile'); + expect(companies).toHaveProperty('position'); + expect(companies).toHaveProperty('searchVector'); + expect(companies).toHaveProperty('id'); + expect(companies).toHaveProperty('createdAt'); + expect(companies).toHaveProperty('updatedAt'); + expect(companies).toHaveProperty('deletedAt'); + expect(companies).toHaveProperty('accountOwnerId'); + expect(companies).toHaveProperty('tagline'); + expect(companies).toHaveProperty('workPolicy'); + expect(companies).toHaveProperty('visaSponsorship'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/connected-accounts.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/connected-accounts.integration-spec.ts similarity index 93% rename from packages/twenty-server/test/integration/graphql/connected-accounts.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/connected-accounts.integration-spec.ts index e17fd5b28504..0a6858940c6a 100644 --- a/packages/twenty-server/test/integration/graphql/connected-accounts.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/connected-accounts.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('connectedAccountsResolver (integration)', () => { +describe('connectedAccountsResolver (e2e)', () => { it('should find many connectedAccounts', () => { const queryData = { query: ` @@ -17,6 +17,7 @@ describe('connectedAccountsResolver (integration)', () => { lastSyncHistoryId authFailedAt handleAliases + scopes id createdAt updatedAt @@ -56,6 +57,7 @@ describe('connectedAccountsResolver (integration)', () => { expect(connectedAccounts).toHaveProperty('lastSyncHistoryId'); expect(connectedAccounts).toHaveProperty('authFailedAt'); expect(connectedAccounts).toHaveProperty('handleAliases'); + expect(connectedAccounts).toHaveProperty('scopes'); expect(connectedAccounts).toHaveProperty('id'); expect(connectedAccounts).toHaveProperty('createdAt'); expect(connectedAccounts).toHaveProperty('updatedAt'); diff --git a/packages/twenty-server/test/integration/graphql/favorites.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/favorites.integration-spec.ts similarity index 82% rename from packages/twenty-server/test/integration/graphql/favorites.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/favorites.integration-spec.ts index f58e702e5517..ea410fabc912 100644 --- a/packages/twenty-server/test/integration/graphql/favorites.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/favorites.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('favoritesResolver (integration)', () => { +describe('favoritesResolver (e2e)', () => { it('should find many favorites', () => { const queryData = { query: ` @@ -19,9 +19,13 @@ describe('favoritesResolver (integration)', () => { personId companyId opportunityId + workflowId + workflowVersionId + workflowRunId taskId noteId viewId + rocketId } } } @@ -58,9 +62,13 @@ describe('favoritesResolver (integration)', () => { expect(favorites).toHaveProperty('personId'); expect(favorites).toHaveProperty('companyId'); expect(favorites).toHaveProperty('opportunityId'); + expect(favorites).toHaveProperty('workflowId'); + expect(favorites).toHaveProperty('workflowVersionId'); + expect(favorites).toHaveProperty('workflowRunId'); expect(favorites).toHaveProperty('taskId'); expect(favorites).toHaveProperty('noteId'); expect(favorites).toHaveProperty('viewId'); + expect(favorites).toHaveProperty('rocketId'); } }); }); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/index-metadatas.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/index-metadatas.integration-spec.ts new file mode 100644 index 000000000000..02d3d54b0562 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/index-metadatas.integration-spec.ts @@ -0,0 +1,59 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('indexMetadatasResolver (e2e)', () => { + it('should find many indexMetadatas', () => { + const queryData = { + query: ` + query indexMetadatas { + indexMetadatas { + edges { + node { + id + name + isCustom + isUnique + indexWhereClause + indexType + createdAt + updatedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.indexMetadatas; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const indexMetadatas = edges[0].node; + + expect(indexMetadatas).toHaveProperty('id'); + expect(indexMetadatas).toHaveProperty('name'); + expect(indexMetadatas).toHaveProperty('isCustom'); + expect(indexMetadatas).toHaveProperty('isUnique'); + expect(indexMetadatas).toHaveProperty('indexWhereClause'); + expect(indexMetadatas).toHaveProperty('indexType'); + expect(indexMetadatas).toHaveProperty('createdAt'); + expect(indexMetadatas).toHaveProperty('updatedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/message-channel-message-associations.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channel-message-associations.integration-spec.ts similarity index 89% rename from packages/twenty-server/test/integration/graphql/message-channel-message-associations.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/message-channel-message-associations.integration-spec.ts index a250550f4b88..0d9980eb1f9b 100644 --- a/packages/twenty-server/test/integration/graphql/message-channel-message-associations.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channel-message-associations.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('messageChannelMessageAssociationsResolver (integration)', () => { +describe('messageChannelMessageAssociationsResolver (e2e)', () => { it('should find many messageChannelMessageAssociations', () => { const queryData = { query: ` @@ -10,11 +10,11 @@ describe('messageChannelMessageAssociationsResolver (integration)', () => { messageChannelMessageAssociations { edges { node { - createdAt messageExternalId messageThreadExternalId direction id + createdAt updatedAt deletedAt messageChannelId @@ -46,20 +46,14 @@ describe('messageChannelMessageAssociationsResolver (integration)', () => { if (edges.length > 0) { const messageChannelMessageAssociations = edges[0].node; - expect(messageChannelMessageAssociations).toHaveProperty('createdAt'); - expect(messageChannelMessageAssociations).toHaveProperty( - 'messageExternalId', - ); - expect(messageChannelMessageAssociations).toHaveProperty( - 'messageThreadExternalId', - ); + expect(messageChannelMessageAssociations).toHaveProperty('messageExternalId'); + expect(messageChannelMessageAssociations).toHaveProperty('messageThreadExternalId'); expect(messageChannelMessageAssociations).toHaveProperty('direction'); expect(messageChannelMessageAssociations).toHaveProperty('id'); + expect(messageChannelMessageAssociations).toHaveProperty('createdAt'); expect(messageChannelMessageAssociations).toHaveProperty('updatedAt'); expect(messageChannelMessageAssociations).toHaveProperty('deletedAt'); - expect(messageChannelMessageAssociations).toHaveProperty( - 'messageChannelId', - ); + expect(messageChannelMessageAssociations).toHaveProperty('messageChannelId'); expect(messageChannelMessageAssociations).toHaveProperty('messageId'); } }); diff --git a/packages/twenty-server/test/integration/graphql/message-channels.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channels.integration-spec.ts similarity index 90% rename from packages/twenty-server/test/integration/graphql/message-channels.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/message-channels.integration-spec.ts index 8100a885d89c..af932aa2c24f 100644 --- a/packages/twenty-server/test/integration/graphql/message-channels.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channels.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('messageChannelsResolver (integration)', () => { +describe('messageChannelsResolver (e2e)', () => { it('should find many messageChannels', () => { const queryData = { query: ` @@ -59,13 +59,9 @@ describe('messageChannelsResolver (integration)', () => { expect(messageChannels).toHaveProperty('visibility'); expect(messageChannels).toHaveProperty('handle'); expect(messageChannels).toHaveProperty('type'); - expect(messageChannels).toHaveProperty( - 'isContactAutoCreationEnabled', - ); + expect(messageChannels).toHaveProperty('isContactAutoCreationEnabled'); expect(messageChannels).toHaveProperty('contactAutoCreationPolicy'); - expect(messageChannels).toHaveProperty( - 'excludeNonProfessionalEmails', - ); + expect(messageChannels).toHaveProperty('excludeNonProfessionalEmails'); expect(messageChannels).toHaveProperty('excludeGroupEmails'); expect(messageChannels).toHaveProperty('isSyncEnabled'); expect(messageChannels).toHaveProperty('syncCursor'); diff --git a/packages/twenty-server/test/integration/graphql/message-participants.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-participants.integration-spec.ts similarity index 96% rename from packages/twenty-server/test/integration/graphql/message-participants.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/message-participants.integration-spec.ts index 45c190c536ec..1271455c0c42 100644 --- a/packages/twenty-server/test/integration/graphql/message-participants.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-participants.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('messageParticipantsResolver (integration)', () => { +describe('messageParticipantsResolver (e2e)', () => { it('should find many messageParticipants', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/message-threads.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-threads.integration-spec.ts similarity index 95% rename from packages/twenty-server/test/integration/graphql/message-threads.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/message-threads.integration-spec.ts index 714bf06bb65a..85ec6e2a5046 100644 --- a/packages/twenty-server/test/integration/graphql/message-threads.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-threads.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('messageThreadsResolver (integration)', () => { +describe('messageThreadsResolver (e2e)', () => { it('should find many messageThreads', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/messages.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/messages.integration-spec.ts new file mode 100644 index 000000000000..c90cfeb2f8a7 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/messages.integration-spec.ts @@ -0,0 +1,66 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('messagesResolver (e2e)', () => { + it('should find many messages', () => { + const queryData = { + query: ` + query messages($filter: MessageFilterInput) { + messages(filter: $filter) { + edges { + node { + headerMessageId + subject + text + receivedAt + id + createdAt + updatedAt + deletedAt + messageThreadId + } + } + } + } + `, + variables: { + filter: { + id: 'b1305b29-f5d6-4388-b7f6-2c136d543563', + }, + }, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.messages; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const messages = edges[0].node; + + expect(messages).toHaveProperty('headerMessageId'); + expect(messages).toHaveProperty('subject'); + expect(messages).toHaveProperty('text'); + expect(messages).toHaveProperty('receivedAt'); + expect(messages).toHaveProperty('id'); + expect(messages).toHaveProperty('createdAt'); + expect(messages).toHaveProperty('updatedAt'); + expect(messages).toHaveProperty('deletedAt'); + expect(messages).toHaveProperty('messageThreadId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/note-targets.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/note-targets.integration-spec.ts similarity index 92% rename from packages/twenty-server/test/integration/graphql/note-targets.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/note-targets.integration-spec.ts index 30d309dc32f5..8cd6b76a34d2 100644 --- a/packages/twenty-server/test/integration/graphql/note-targets.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/note-targets.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('noteTargetsResolver (integration)', () => { +describe('noteTargetsResolver (e2e)', () => { it('should find many noteTargets', () => { const queryData = { query: ` @@ -18,6 +18,7 @@ describe('noteTargetsResolver (integration)', () => { personId companyId opportunityId + rocketId } } } @@ -53,6 +54,7 @@ describe('noteTargetsResolver (integration)', () => { expect(noteTargets).toHaveProperty('personId'); expect(noteTargets).toHaveProperty('companyId'); expect(noteTargets).toHaveProperty('opportunityId'); + expect(noteTargets).toHaveProperty('rocketId'); } }); }); diff --git a/packages/twenty-server/test/integration/graphql/notes.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/notes.integration-spec.ts similarity index 96% rename from packages/twenty-server/test/integration/graphql/notes.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/notes.integration-spec.ts index eb13fedbac42..5f25d3ffa1d1 100644 --- a/packages/twenty-server/test/integration/graphql/notes.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/notes.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('notesResolver (integration)', () => { +describe('notesResolver (e2e)', () => { it('should find many notes', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/objects.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/objects.integration-spec.ts similarity index 97% rename from packages/twenty-server/test/integration/graphql/objects.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/objects.integration-spec.ts index 80d1458ab668..afeb568c4c5b 100644 --- a/packages/twenty-server/test/integration/graphql/objects.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/objects.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('objectsResolver (integration)', () => { +describe('objectsResolver (e2e)', () => { it('should find many objects', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/opportunities.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/opportunities.integration-spec.ts similarity index 92% rename from packages/twenty-server/test/integration/graphql/opportunities.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/opportunities.integration-spec.ts index 9eebe96a0da7..82099405c9c7 100644 --- a/packages/twenty-server/test/integration/graphql/opportunities.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/opportunities.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('opportunitiesResolver (integration)', () => { +describe('opportunitiesResolver (e2e)', () => { it('should find many opportunities', () => { const queryData = { query: ` @@ -14,6 +14,7 @@ describe('opportunitiesResolver (integration)', () => { closeDate stage position + searchVector id createdAt updatedAt @@ -51,6 +52,7 @@ describe('opportunitiesResolver (integration)', () => { expect(opportunities).toHaveProperty('closeDate'); expect(opportunities).toHaveProperty('stage'); expect(opportunities).toHaveProperty('position'); + expect(opportunities).toHaveProperty('searchVector'); expect(opportunities).toHaveProperty('id'); expect(opportunities).toHaveProperty('createdAt'); expect(opportunities).toHaveProperty('updatedAt'); diff --git a/packages/twenty-server/test/integration/graphql/people.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/people.integration-spec.ts similarity index 82% rename from packages/twenty-server/test/integration/graphql/people.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/people.integration-spec.ts index 28b981e22dbe..7a8454a12f8a 100644 --- a/packages/twenty-server/test/integration/graphql/people.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/people.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('peopleResolver (integration)', () => { +describe('peopleResolver (e2e)', () => { it('should find many people', () => { const queryData = { query: ` @@ -11,22 +11,16 @@ describe('peopleResolver (integration)', () => { edges { node { jobTitle - phones { - primaryPhoneNumber - primaryPhoneCountryCode - } city avatarUrl position + searchVector id createdAt updatedAt deletedAt companyId intro - whatsapp { - primaryPhoneNumber - } workPreference performanceRating } @@ -42,7 +36,6 @@ describe('peopleResolver (integration)', () => { .send(queryData) .expect(200) .expect((res) => { - console.log(res.body); expect(res.body.data).toBeDefined(); expect(res.body.errors).toBeUndefined(); }) @@ -58,17 +51,16 @@ describe('peopleResolver (integration)', () => { const people = edges[0].node; expect(people).toHaveProperty('jobTitle'); - expect(people).toHaveProperty('phones'); expect(people).toHaveProperty('city'); expect(people).toHaveProperty('avatarUrl'); expect(people).toHaveProperty('position'); + expect(people).toHaveProperty('searchVector'); expect(people).toHaveProperty('id'); expect(people).toHaveProperty('createdAt'); expect(people).toHaveProperty('updatedAt'); expect(people).toHaveProperty('deletedAt'); expect(people).toHaveProperty('companyId'); expect(people).toHaveProperty('intro'); - expect(people).toHaveProperty('whatsapp'); expect(people).toHaveProperty('workPreference'); expect(people).toHaveProperty('performanceRating'); } diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/rockets.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/rockets.integration-spec.ts new file mode 100644 index 000000000000..a9fa0f88f432 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/rockets.integration-spec.ts @@ -0,0 +1,57 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('rocketsResolver (e2e)', () => { + it('should find many rockets', () => { + const queryData = { + query: ` + query rockets { + rockets { + edges { + node { + id + name + createdAt + updatedAt + deletedAt + position + searchVector + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.rockets; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const rockets = edges[0].node; + + expect(rockets).toHaveProperty('id'); + expect(rockets).toHaveProperty('name'); + expect(rockets).toHaveProperty('createdAt'); + expect(rockets).toHaveProperty('updatedAt'); + expect(rockets).toHaveProperty('deletedAt'); + expect(rockets).toHaveProperty('position'); + expect(rockets).toHaveProperty('searchVector'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-activities.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-activities.integration-spec.ts new file mode 100644 index 000000000000..7d9be3362461 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-activities.integration-spec.ts @@ -0,0 +1,67 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchActivitiesResolver (e2e)', () => { + it('should find many searchActivities', () => { + const queryData = { + query: ` + query searchActivities { + searchActivities { + edges { + node { + title + body + type + reminderAt + dueAt + completedAt + id + createdAt + updatedAt + deletedAt + authorId + assigneeId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchActivities; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchActivities = edges[0].node; + + expect(searchActivities).toHaveProperty('title'); + expect(searchActivities).toHaveProperty('body'); + expect(searchActivities).toHaveProperty('type'); + expect(searchActivities).toHaveProperty('reminderAt'); + expect(searchActivities).toHaveProperty('dueAt'); + expect(searchActivities).toHaveProperty('completedAt'); + expect(searchActivities).toHaveProperty('id'); + expect(searchActivities).toHaveProperty('createdAt'); + expect(searchActivities).toHaveProperty('updatedAt'); + expect(searchActivities).toHaveProperty('deletedAt'); + expect(searchActivities).toHaveProperty('authorId'); + expect(searchActivities).toHaveProperty('assigneeId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-activity-targets.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-activity-targets.integration-spec.ts new file mode 100644 index 000000000000..64b5fa8c2f1a --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-activity-targets.integration-spec.ts @@ -0,0 +1,61 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchActivityTargetsResolver (e2e)', () => { + it('should find many searchActivityTargets', () => { + const queryData = { + query: ` + query searchActivityTargets { + searchActivityTargets { + edges { + node { + id + createdAt + updatedAt + deletedAt + activityId + personId + companyId + opportunityId + rocketId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchActivityTargets; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchActivityTargets = edges[0].node; + + expect(searchActivityTargets).toHaveProperty('id'); + expect(searchActivityTargets).toHaveProperty('createdAt'); + expect(searchActivityTargets).toHaveProperty('updatedAt'); + expect(searchActivityTargets).toHaveProperty('deletedAt'); + expect(searchActivityTargets).toHaveProperty('activityId'); + expect(searchActivityTargets).toHaveProperty('personId'); + expect(searchActivityTargets).toHaveProperty('companyId'); + expect(searchActivityTargets).toHaveProperty('opportunityId'); + expect(searchActivityTargets).toHaveProperty('rocketId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-api-keys.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-api-keys.integration-spec.ts new file mode 100644 index 000000000000..6d403e20d238 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-api-keys.integration-spec.ts @@ -0,0 +1,57 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchApiKeysResolver (e2e)', () => { + it('should find many searchApiKeys', () => { + const queryData = { + query: ` + query searchApiKeys { + searchApiKeys { + edges { + node { + name + expiresAt + revokedAt + id + createdAt + updatedAt + deletedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchApiKeys; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchApiKeys = edges[0].node; + + expect(searchApiKeys).toHaveProperty('name'); + expect(searchApiKeys).toHaveProperty('expiresAt'); + expect(searchApiKeys).toHaveProperty('revokedAt'); + expect(searchApiKeys).toHaveProperty('id'); + expect(searchApiKeys).toHaveProperty('createdAt'); + expect(searchApiKeys).toHaveProperty('updatedAt'); + expect(searchApiKeys).toHaveProperty('deletedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-attachments.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-attachments.integration-spec.ts new file mode 100644 index 000000000000..1debda9ff470 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-attachments.integration-spec.ts @@ -0,0 +1,73 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchAttachmentsResolver (e2e)', () => { + it('should find many searchAttachments', () => { + const queryData = { + query: ` + query searchAttachments { + searchAttachments { + edges { + node { + name + fullPath + type + id + createdAt + updatedAt + deletedAt + authorId + activityId + taskId + noteId + personId + companyId + opportunityId + rocketId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchAttachments; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchAttachments = edges[0].node; + + expect(searchAttachments).toHaveProperty('name'); + expect(searchAttachments).toHaveProperty('fullPath'); + expect(searchAttachments).toHaveProperty('type'); + expect(searchAttachments).toHaveProperty('id'); + expect(searchAttachments).toHaveProperty('createdAt'); + expect(searchAttachments).toHaveProperty('updatedAt'); + expect(searchAttachments).toHaveProperty('deletedAt'); + expect(searchAttachments).toHaveProperty('authorId'); + expect(searchAttachments).toHaveProperty('activityId'); + expect(searchAttachments).toHaveProperty('taskId'); + expect(searchAttachments).toHaveProperty('noteId'); + expect(searchAttachments).toHaveProperty('personId'); + expect(searchAttachments).toHaveProperty('companyId'); + expect(searchAttachments).toHaveProperty('opportunityId'); + expect(searchAttachments).toHaveProperty('rocketId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-audit-logs.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-audit-logs.integration-spec.ts new file mode 100644 index 000000000000..0a7ecd6f8f06 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-audit-logs.integration-spec.ts @@ -0,0 +1,65 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchAuditLogsResolver (e2e)', () => { + it('should find many searchAuditLogs', () => { + const queryData = { + query: ` + query searchAuditLogs { + searchAuditLogs { + edges { + node { + name + properties + context + objectName + objectMetadataId + recordId + id + createdAt + updatedAt + deletedAt + workspaceMemberId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchAuditLogs; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchAuditLogs = edges[0].node; + + expect(searchAuditLogs).toHaveProperty('name'); + expect(searchAuditLogs).toHaveProperty('properties'); + expect(searchAuditLogs).toHaveProperty('context'); + expect(searchAuditLogs).toHaveProperty('objectName'); + expect(searchAuditLogs).toHaveProperty('objectMetadataId'); + expect(searchAuditLogs).toHaveProperty('recordId'); + expect(searchAuditLogs).toHaveProperty('id'); + expect(searchAuditLogs).toHaveProperty('createdAt'); + expect(searchAuditLogs).toHaveProperty('updatedAt'); + expect(searchAuditLogs).toHaveProperty('deletedAt'); + expect(searchAuditLogs).toHaveProperty('workspaceMemberId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-blocklists.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-blocklists.integration-spec.ts new file mode 100644 index 000000000000..f864a62857f6 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-blocklists.integration-spec.ts @@ -0,0 +1,55 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchBlocklistsResolver (e2e)', () => { + it('should find many searchBlocklists', () => { + const queryData = { + query: ` + query searchBlocklists { + searchBlocklists { + edges { + node { + handle + id + createdAt + updatedAt + deletedAt + workspaceMemberId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchBlocklists; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchBlocklists = edges[0].node; + + expect(searchBlocklists).toHaveProperty('handle'); + expect(searchBlocklists).toHaveProperty('id'); + expect(searchBlocklists).toHaveProperty('createdAt'); + expect(searchBlocklists).toHaveProperty('updatedAt'); + expect(searchBlocklists).toHaveProperty('deletedAt'); + expect(searchBlocklists).toHaveProperty('workspaceMemberId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channel-event-associations.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channel-event-associations.integration-spec.ts new file mode 100644 index 000000000000..214e66b612a5 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channel-event-associations.integration-spec.ts @@ -0,0 +1,59 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchCalendarChannelEventAssociationsResolver (e2e)', () => { + it('should find many searchCalendarChannelEventAssociations', () => { + const queryData = { + query: ` + query searchCalendarChannelEventAssociations { + searchCalendarChannelEventAssociations { + edges { + node { + eventExternalId + recurringEventExternalId + id + createdAt + updatedAt + deletedAt + calendarChannelId + calendarEventId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchCalendarChannelEventAssociations; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchCalendarChannelEventAssociations = edges[0].node; + + expect(searchCalendarChannelEventAssociations).toHaveProperty('eventExternalId'); + expect(searchCalendarChannelEventAssociations).toHaveProperty('recurringEventExternalId'); + expect(searchCalendarChannelEventAssociations).toHaveProperty('id'); + expect(searchCalendarChannelEventAssociations).toHaveProperty('createdAt'); + expect(searchCalendarChannelEventAssociations).toHaveProperty('updatedAt'); + expect(searchCalendarChannelEventAssociations).toHaveProperty('deletedAt'); + expect(searchCalendarChannelEventAssociations).toHaveProperty('calendarChannelId'); + expect(searchCalendarChannelEventAssociations).toHaveProperty('calendarEventId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channels.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channels.integration-spec.ts new file mode 100644 index 000000000000..4e984c76398f --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channels.integration-spec.ts @@ -0,0 +1,75 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchCalendarChannelsResolver (e2e)', () => { + it('should find many searchCalendarChannels', () => { + const queryData = { + query: ` + query searchCalendarChannels { + searchCalendarChannels { + edges { + node { + handle + syncStatus + syncStage + visibility + isContactAutoCreationEnabled + contactAutoCreationPolicy + isSyncEnabled + syncCursor + syncedAt + syncStageStartedAt + throttleFailureCount + id + createdAt + updatedAt + deletedAt + connectedAccountId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchCalendarChannels; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchCalendarChannels = edges[0].node; + + expect(searchCalendarChannels).toHaveProperty('handle'); + expect(searchCalendarChannels).toHaveProperty('syncStatus'); + expect(searchCalendarChannels).toHaveProperty('syncStage'); + expect(searchCalendarChannels).toHaveProperty('visibility'); + expect(searchCalendarChannels).toHaveProperty('isContactAutoCreationEnabled'); + expect(searchCalendarChannels).toHaveProperty('contactAutoCreationPolicy'); + expect(searchCalendarChannels).toHaveProperty('isSyncEnabled'); + expect(searchCalendarChannels).toHaveProperty('syncCursor'); + expect(searchCalendarChannels).toHaveProperty('syncedAt'); + expect(searchCalendarChannels).toHaveProperty('syncStageStartedAt'); + expect(searchCalendarChannels).toHaveProperty('throttleFailureCount'); + expect(searchCalendarChannels).toHaveProperty('id'); + expect(searchCalendarChannels).toHaveProperty('createdAt'); + expect(searchCalendarChannels).toHaveProperty('updatedAt'); + expect(searchCalendarChannels).toHaveProperty('deletedAt'); + expect(searchCalendarChannels).toHaveProperty('connectedAccountId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-event-participants.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-event-participants.integration-spec.ts new file mode 100644 index 000000000000..de0f60f7bb77 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-event-participants.integration-spec.ts @@ -0,0 +1,65 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchCalendarEventParticipantsResolver (e2e)', () => { + it('should find many searchCalendarEventParticipants', () => { + const queryData = { + query: ` + query searchCalendarEventParticipants { + searchCalendarEventParticipants { + edges { + node { + handle + displayName + isOrganizer + responseStatus + id + createdAt + updatedAt + deletedAt + calendarEventId + personId + workspaceMemberId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchCalendarEventParticipants; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchCalendarEventParticipants = edges[0].node; + + expect(searchCalendarEventParticipants).toHaveProperty('handle'); + expect(searchCalendarEventParticipants).toHaveProperty('displayName'); + expect(searchCalendarEventParticipants).toHaveProperty('isOrganizer'); + expect(searchCalendarEventParticipants).toHaveProperty('responseStatus'); + expect(searchCalendarEventParticipants).toHaveProperty('id'); + expect(searchCalendarEventParticipants).toHaveProperty('createdAt'); + expect(searchCalendarEventParticipants).toHaveProperty('updatedAt'); + expect(searchCalendarEventParticipants).toHaveProperty('deletedAt'); + expect(searchCalendarEventParticipants).toHaveProperty('calendarEventId'); + expect(searchCalendarEventParticipants).toHaveProperty('personId'); + expect(searchCalendarEventParticipants).toHaveProperty('workspaceMemberId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-events.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-events.integration-spec.ts new file mode 100644 index 000000000000..76ef636a0d4a --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-events.integration-spec.ts @@ -0,0 +1,73 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchCalendarEventsResolver (e2e)', () => { + it('should find many searchCalendarEvents', () => { + const queryData = { + query: ` + query searchCalendarEvents { + searchCalendarEvents { + edges { + node { + title + isCanceled + isFullDay + startsAt + endsAt + externalCreatedAt + externalUpdatedAt + description + location + iCalUID + conferenceSolution + id + createdAt + updatedAt + deletedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchCalendarEvents; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchCalendarEvents = edges[0].node; + + expect(searchCalendarEvents).toHaveProperty('title'); + expect(searchCalendarEvents).toHaveProperty('isCanceled'); + expect(searchCalendarEvents).toHaveProperty('isFullDay'); + expect(searchCalendarEvents).toHaveProperty('startsAt'); + expect(searchCalendarEvents).toHaveProperty('endsAt'); + expect(searchCalendarEvents).toHaveProperty('externalCreatedAt'); + expect(searchCalendarEvents).toHaveProperty('externalUpdatedAt'); + expect(searchCalendarEvents).toHaveProperty('description'); + expect(searchCalendarEvents).toHaveProperty('location'); + expect(searchCalendarEvents).toHaveProperty('iCalUID'); + expect(searchCalendarEvents).toHaveProperty('conferenceSolution'); + expect(searchCalendarEvents).toHaveProperty('id'); + expect(searchCalendarEvents).toHaveProperty('createdAt'); + expect(searchCalendarEvents).toHaveProperty('updatedAt'); + expect(searchCalendarEvents).toHaveProperty('deletedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-comments.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-comments.integration-spec.ts new file mode 100644 index 000000000000..549f1d3011d1 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-comments.integration-spec.ts @@ -0,0 +1,57 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchCommentsResolver (e2e)', () => { + it('should find many searchComments', () => { + const queryData = { + query: ` + query searchComments { + searchComments { + edges { + node { + body + id + createdAt + updatedAt + deletedAt + authorId + activityId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchComments; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchComments = edges[0].node; + + expect(searchComments).toHaveProperty('body'); + expect(searchComments).toHaveProperty('id'); + expect(searchComments).toHaveProperty('createdAt'); + expect(searchComments).toHaveProperty('updatedAt'); + expect(searchComments).toHaveProperty('deletedAt'); + expect(searchComments).toHaveProperty('authorId'); + expect(searchComments).toHaveProperty('activityId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-companies.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-companies.integration-spec.ts new file mode 100644 index 000000000000..da309385f76f --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-companies.integration-spec.ts @@ -0,0 +1,69 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchCompaniesResolver (e2e)', () => { + it('should find many searchCompanies', () => { + const queryData = { + query: ` + query searchCompanies { + searchCompanies { + edges { + node { + name + employees + idealCustomerProfile + position + searchVector + id + createdAt + updatedAt + deletedAt + accountOwnerId + tagline + workPolicy + visaSponsorship + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchCompanies; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchCompanies = edges[0].node; + + expect(searchCompanies).toHaveProperty('name'); + expect(searchCompanies).toHaveProperty('employees'); + expect(searchCompanies).toHaveProperty('idealCustomerProfile'); + expect(searchCompanies).toHaveProperty('position'); + expect(searchCompanies).toHaveProperty('searchVector'); + expect(searchCompanies).toHaveProperty('id'); + expect(searchCompanies).toHaveProperty('createdAt'); + expect(searchCompanies).toHaveProperty('updatedAt'); + expect(searchCompanies).toHaveProperty('deletedAt'); + expect(searchCompanies).toHaveProperty('accountOwnerId'); + expect(searchCompanies).toHaveProperty('tagline'); + expect(searchCompanies).toHaveProperty('workPolicy'); + expect(searchCompanies).toHaveProperty('visaSponsorship'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-connected-accounts.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-connected-accounts.integration-spec.ts new file mode 100644 index 000000000000..d00c81ecb1a9 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-connected-accounts.integration-spec.ts @@ -0,0 +1,69 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchConnectedAccountsResolver (e2e)', () => { + it('should find many searchConnectedAccounts', () => { + const queryData = { + query: ` + query searchConnectedAccounts { + searchConnectedAccounts { + edges { + node { + handle + provider + accessToken + refreshToken + lastSyncHistoryId + authFailedAt + handleAliases + scopes + id + createdAt + updatedAt + deletedAt + accountOwnerId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchConnectedAccounts; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchConnectedAccounts = edges[0].node; + + expect(searchConnectedAccounts).toHaveProperty('handle'); + expect(searchConnectedAccounts).toHaveProperty('provider'); + expect(searchConnectedAccounts).toHaveProperty('accessToken'); + expect(searchConnectedAccounts).toHaveProperty('refreshToken'); + expect(searchConnectedAccounts).toHaveProperty('lastSyncHistoryId'); + expect(searchConnectedAccounts).toHaveProperty('authFailedAt'); + expect(searchConnectedAccounts).toHaveProperty('handleAliases'); + expect(searchConnectedAccounts).toHaveProperty('scopes'); + expect(searchConnectedAccounts).toHaveProperty('id'); + expect(searchConnectedAccounts).toHaveProperty('createdAt'); + expect(searchConnectedAccounts).toHaveProperty('updatedAt'); + expect(searchConnectedAccounts).toHaveProperty('deletedAt'); + expect(searchConnectedAccounts).toHaveProperty('accountOwnerId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-favorites.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-favorites.integration-spec.ts new file mode 100644 index 000000000000..982aff72675a --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-favorites.integration-spec.ts @@ -0,0 +1,75 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchFavoritesResolver (e2e)', () => { + it('should find many searchFavorites', () => { + const queryData = { + query: ` + query searchFavorites { + searchFavorites { + edges { + node { + position + id + createdAt + updatedAt + deletedAt + workspaceMemberId + personId + companyId + opportunityId + workflowId + workflowVersionId + workflowRunId + taskId + noteId + viewId + rocketId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchFavorites; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchFavorites = edges[0].node; + + expect(searchFavorites).toHaveProperty('position'); + expect(searchFavorites).toHaveProperty('id'); + expect(searchFavorites).toHaveProperty('createdAt'); + expect(searchFavorites).toHaveProperty('updatedAt'); + expect(searchFavorites).toHaveProperty('deletedAt'); + expect(searchFavorites).toHaveProperty('workspaceMemberId'); + expect(searchFavorites).toHaveProperty('personId'); + expect(searchFavorites).toHaveProperty('companyId'); + expect(searchFavorites).toHaveProperty('opportunityId'); + expect(searchFavorites).toHaveProperty('workflowId'); + expect(searchFavorites).toHaveProperty('workflowVersionId'); + expect(searchFavorites).toHaveProperty('workflowRunId'); + expect(searchFavorites).toHaveProperty('taskId'); + expect(searchFavorites).toHaveProperty('noteId'); + expect(searchFavorites).toHaveProperty('viewId'); + expect(searchFavorites).toHaveProperty('rocketId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channel-message-associations.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channel-message-associations.integration-spec.ts new file mode 100644 index 000000000000..9cfd06fa9ac4 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channel-message-associations.integration-spec.ts @@ -0,0 +1,61 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchMessageChannelMessageAssociationsResolver (e2e)', () => { + it('should find many searchMessageChannelMessageAssociations', () => { + const queryData = { + query: ` + query searchMessageChannelMessageAssociations { + searchMessageChannelMessageAssociations { + edges { + node { + messageExternalId + messageThreadExternalId + direction + id + createdAt + updatedAt + deletedAt + messageChannelId + messageId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchMessageChannelMessageAssociations; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchMessageChannelMessageAssociations = edges[0].node; + + expect(searchMessageChannelMessageAssociations).toHaveProperty('messageExternalId'); + expect(searchMessageChannelMessageAssociations).toHaveProperty('messageThreadExternalId'); + expect(searchMessageChannelMessageAssociations).toHaveProperty('direction'); + expect(searchMessageChannelMessageAssociations).toHaveProperty('id'); + expect(searchMessageChannelMessageAssociations).toHaveProperty('createdAt'); + expect(searchMessageChannelMessageAssociations).toHaveProperty('updatedAt'); + expect(searchMessageChannelMessageAssociations).toHaveProperty('deletedAt'); + expect(searchMessageChannelMessageAssociations).toHaveProperty('messageChannelId'); + expect(searchMessageChannelMessageAssociations).toHaveProperty('messageId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channels.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channels.integration-spec.ts new file mode 100644 index 000000000000..981aae89e9cd --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channels.integration-spec.ts @@ -0,0 +1,81 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchMessageChannelsResolver (e2e)', () => { + it('should find many searchMessageChannels', () => { + const queryData = { + query: ` + query searchMessageChannels { + searchMessageChannels { + edges { + node { + visibility + handle + type + isContactAutoCreationEnabled + contactAutoCreationPolicy + excludeNonProfessionalEmails + excludeGroupEmails + isSyncEnabled + syncCursor + syncedAt + syncStatus + syncStage + syncStageStartedAt + throttleFailureCount + id + createdAt + updatedAt + deletedAt + connectedAccountId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchMessageChannels; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchMessageChannels = edges[0].node; + + expect(searchMessageChannels).toHaveProperty('visibility'); + expect(searchMessageChannels).toHaveProperty('handle'); + expect(searchMessageChannels).toHaveProperty('type'); + expect(searchMessageChannels).toHaveProperty('isContactAutoCreationEnabled'); + expect(searchMessageChannels).toHaveProperty('contactAutoCreationPolicy'); + expect(searchMessageChannels).toHaveProperty('excludeNonProfessionalEmails'); + expect(searchMessageChannels).toHaveProperty('excludeGroupEmails'); + expect(searchMessageChannels).toHaveProperty('isSyncEnabled'); + expect(searchMessageChannels).toHaveProperty('syncCursor'); + expect(searchMessageChannels).toHaveProperty('syncedAt'); + expect(searchMessageChannels).toHaveProperty('syncStatus'); + expect(searchMessageChannels).toHaveProperty('syncStage'); + expect(searchMessageChannels).toHaveProperty('syncStageStartedAt'); + expect(searchMessageChannels).toHaveProperty('throttleFailureCount'); + expect(searchMessageChannels).toHaveProperty('id'); + expect(searchMessageChannels).toHaveProperty('createdAt'); + expect(searchMessageChannels).toHaveProperty('updatedAt'); + expect(searchMessageChannels).toHaveProperty('deletedAt'); + expect(searchMessageChannels).toHaveProperty('connectedAccountId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-participants.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-participants.integration-spec.ts new file mode 100644 index 000000000000..71b9ee486251 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-participants.integration-spec.ts @@ -0,0 +1,63 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchMessageParticipantsResolver (e2e)', () => { + it('should find many searchMessageParticipants', () => { + const queryData = { + query: ` + query searchMessageParticipants { + searchMessageParticipants { + edges { + node { + role + handle + displayName + id + createdAt + updatedAt + deletedAt + messageId + personId + workspaceMemberId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchMessageParticipants; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchMessageParticipants = edges[0].node; + + expect(searchMessageParticipants).toHaveProperty('role'); + expect(searchMessageParticipants).toHaveProperty('handle'); + expect(searchMessageParticipants).toHaveProperty('displayName'); + expect(searchMessageParticipants).toHaveProperty('id'); + expect(searchMessageParticipants).toHaveProperty('createdAt'); + expect(searchMessageParticipants).toHaveProperty('updatedAt'); + expect(searchMessageParticipants).toHaveProperty('deletedAt'); + expect(searchMessageParticipants).toHaveProperty('messageId'); + expect(searchMessageParticipants).toHaveProperty('personId'); + expect(searchMessageParticipants).toHaveProperty('workspaceMemberId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-threads.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-threads.integration-spec.ts new file mode 100644 index 000000000000..5c38ebfeb441 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-threads.integration-spec.ts @@ -0,0 +1,51 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchMessageThreadsResolver (e2e)', () => { + it('should find many searchMessageThreads', () => { + const queryData = { + query: ` + query searchMessageThreads { + searchMessageThreads { + edges { + node { + id + createdAt + updatedAt + deletedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchMessageThreads; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchMessageThreads = edges[0].node; + + expect(searchMessageThreads).toHaveProperty('id'); + expect(searchMessageThreads).toHaveProperty('createdAt'); + expect(searchMessageThreads).toHaveProperty('updatedAt'); + expect(searchMessageThreads).toHaveProperty('deletedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-messages.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-messages.integration-spec.ts new file mode 100644 index 000000000000..4865fb8d312b --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-messages.integration-spec.ts @@ -0,0 +1,61 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchMessagesResolver (e2e)', () => { + it('should find many searchMessages', () => { + const queryData = { + query: ` + query searchMessages { + searchMessages { + edges { + node { + headerMessageId + subject + text + receivedAt + id + createdAt + updatedAt + deletedAt + messageThreadId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchMessages; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchMessages = edges[0].node; + + expect(searchMessages).toHaveProperty('headerMessageId'); + expect(searchMessages).toHaveProperty('subject'); + expect(searchMessages).toHaveProperty('text'); + expect(searchMessages).toHaveProperty('receivedAt'); + expect(searchMessages).toHaveProperty('id'); + expect(searchMessages).toHaveProperty('createdAt'); + expect(searchMessages).toHaveProperty('updatedAt'); + expect(searchMessages).toHaveProperty('deletedAt'); + expect(searchMessages).toHaveProperty('messageThreadId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-note-targets.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-note-targets.integration-spec.ts new file mode 100644 index 000000000000..45188e8aca7c --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-note-targets.integration-spec.ts @@ -0,0 +1,61 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchNoteTargetsResolver (e2e)', () => { + it('should find many searchNoteTargets', () => { + const queryData = { + query: ` + query searchNoteTargets { + searchNoteTargets { + edges { + node { + id + createdAt + updatedAt + deletedAt + noteId + personId + companyId + opportunityId + rocketId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchNoteTargets; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchNoteTargets = edges[0].node; + + expect(searchNoteTargets).toHaveProperty('id'); + expect(searchNoteTargets).toHaveProperty('createdAt'); + expect(searchNoteTargets).toHaveProperty('updatedAt'); + expect(searchNoteTargets).toHaveProperty('deletedAt'); + expect(searchNoteTargets).toHaveProperty('noteId'); + expect(searchNoteTargets).toHaveProperty('personId'); + expect(searchNoteTargets).toHaveProperty('companyId'); + expect(searchNoteTargets).toHaveProperty('opportunityId'); + expect(searchNoteTargets).toHaveProperty('rocketId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-notes.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-notes.integration-spec.ts new file mode 100644 index 000000000000..8965c5006f26 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-notes.integration-spec.ts @@ -0,0 +1,57 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchNotesResolver (e2e)', () => { + it('should find many searchNotes', () => { + const queryData = { + query: ` + query searchNotes { + searchNotes { + edges { + node { + position + title + body + id + createdAt + updatedAt + deletedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchNotes; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchNotes = edges[0].node; + + expect(searchNotes).toHaveProperty('position'); + expect(searchNotes).toHaveProperty('title'); + expect(searchNotes).toHaveProperty('body'); + expect(searchNotes).toHaveProperty('id'); + expect(searchNotes).toHaveProperty('createdAt'); + expect(searchNotes).toHaveProperty('updatedAt'); + expect(searchNotes).toHaveProperty('deletedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-opportunities.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-opportunities.integration-spec.ts new file mode 100644 index 000000000000..0f63d73d7175 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-opportunities.integration-spec.ts @@ -0,0 +1,65 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchOpportunitiesResolver (e2e)', () => { + it('should find many searchOpportunities', () => { + const queryData = { + query: ` + query searchOpportunities { + searchOpportunities { + edges { + node { + name + closeDate + stage + position + searchVector + id + createdAt + updatedAt + deletedAt + pointOfContactId + companyId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchOpportunities; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchOpportunities = edges[0].node; + + expect(searchOpportunities).toHaveProperty('name'); + expect(searchOpportunities).toHaveProperty('closeDate'); + expect(searchOpportunities).toHaveProperty('stage'); + expect(searchOpportunities).toHaveProperty('position'); + expect(searchOpportunities).toHaveProperty('searchVector'); + expect(searchOpportunities).toHaveProperty('id'); + expect(searchOpportunities).toHaveProperty('createdAt'); + expect(searchOpportunities).toHaveProperty('updatedAt'); + expect(searchOpportunities).toHaveProperty('deletedAt'); + expect(searchOpportunities).toHaveProperty('pointOfContactId'); + expect(searchOpportunities).toHaveProperty('companyId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-people.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-people.integration-spec.ts new file mode 100644 index 000000000000..8c45c0c7e29b --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-people.integration-spec.ts @@ -0,0 +1,69 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchPeopleResolver (e2e)', () => { + it('should find many searchPeople', () => { + const queryData = { + query: ` + query searchPeople { + searchPeople { + edges { + node { + jobTitle + city + avatarUrl + position + searchVector + id + createdAt + updatedAt + deletedAt + companyId + intro + workPreference + performanceRating + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchPeople; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchPeople = edges[0].node; + + expect(searchPeople).toHaveProperty('jobTitle'); + expect(searchPeople).toHaveProperty('city'); + expect(searchPeople).toHaveProperty('avatarUrl'); + expect(searchPeople).toHaveProperty('position'); + expect(searchPeople).toHaveProperty('searchVector'); + expect(searchPeople).toHaveProperty('id'); + expect(searchPeople).toHaveProperty('createdAt'); + expect(searchPeople).toHaveProperty('updatedAt'); + expect(searchPeople).toHaveProperty('deletedAt'); + expect(searchPeople).toHaveProperty('companyId'); + expect(searchPeople).toHaveProperty('intro'); + expect(searchPeople).toHaveProperty('workPreference'); + expect(searchPeople).toHaveProperty('performanceRating'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-rockets.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-rockets.integration-spec.ts new file mode 100644 index 000000000000..1bf738515746 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-rockets.integration-spec.ts @@ -0,0 +1,57 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchRocketsResolver (e2e)', () => { + it('should find many searchRockets', () => { + const queryData = { + query: ` + query searchRockets { + searchRockets { + edges { + node { + id + name + createdAt + updatedAt + deletedAt + position + searchVector + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchRockets; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchRockets = edges[0].node; + + expect(searchRockets).toHaveProperty('id'); + expect(searchRockets).toHaveProperty('name'); + expect(searchRockets).toHaveProperty('createdAt'); + expect(searchRockets).toHaveProperty('updatedAt'); + expect(searchRockets).toHaveProperty('deletedAt'); + expect(searchRockets).toHaveProperty('position'); + expect(searchRockets).toHaveProperty('searchVector'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-task-targets.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-task-targets.integration-spec.ts new file mode 100644 index 000000000000..76f9d7b1ec92 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-task-targets.integration-spec.ts @@ -0,0 +1,61 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchTaskTargetsResolver (e2e)', () => { + it('should find many searchTaskTargets', () => { + const queryData = { + query: ` + query searchTaskTargets { + searchTaskTargets { + edges { + node { + id + createdAt + updatedAt + deletedAt + taskId + personId + companyId + opportunityId + rocketId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchTaskTargets; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchTaskTargets = edges[0].node; + + expect(searchTaskTargets).toHaveProperty('id'); + expect(searchTaskTargets).toHaveProperty('createdAt'); + expect(searchTaskTargets).toHaveProperty('updatedAt'); + expect(searchTaskTargets).toHaveProperty('deletedAt'); + expect(searchTaskTargets).toHaveProperty('taskId'); + expect(searchTaskTargets).toHaveProperty('personId'); + expect(searchTaskTargets).toHaveProperty('companyId'); + expect(searchTaskTargets).toHaveProperty('opportunityId'); + expect(searchTaskTargets).toHaveProperty('rocketId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-tasks.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-tasks.integration-spec.ts new file mode 100644 index 000000000000..d9af7a1c6a42 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-tasks.integration-spec.ts @@ -0,0 +1,63 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchTasksResolver (e2e)', () => { + it('should find many searchTasks', () => { + const queryData = { + query: ` + query searchTasks { + searchTasks { + edges { + node { + position + title + body + dueAt + status + id + createdAt + updatedAt + deletedAt + assigneeId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchTasks; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchTasks = edges[0].node; + + expect(searchTasks).toHaveProperty('position'); + expect(searchTasks).toHaveProperty('title'); + expect(searchTasks).toHaveProperty('body'); + expect(searchTasks).toHaveProperty('dueAt'); + expect(searchTasks).toHaveProperty('status'); + expect(searchTasks).toHaveProperty('id'); + expect(searchTasks).toHaveProperty('createdAt'); + expect(searchTasks).toHaveProperty('updatedAt'); + expect(searchTasks).toHaveProperty('deletedAt'); + expect(searchTasks).toHaveProperty('assigneeId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-timeline-activities.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-timeline-activities.integration-spec.ts new file mode 100644 index 000000000000..d73bcb5f9694 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-timeline-activities.integration-spec.ts @@ -0,0 +1,83 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchTimelineActivitiesResolver (e2e)', () => { + it('should find many searchTimelineActivities', () => { + const queryData = { + query: ` + query searchTimelineActivities { + searchTimelineActivities { + edges { + node { + happensAt + name + properties + linkedRecordCachedName + linkedRecordId + linkedObjectMetadataId + id + createdAt + updatedAt + deletedAt + workspaceMemberId + personId + companyId + opportunityId + noteId + taskId + workflowId + workflowVersionId + workflowRunId + rocketId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchTimelineActivities; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchTimelineActivities = edges[0].node; + + expect(searchTimelineActivities).toHaveProperty('happensAt'); + expect(searchTimelineActivities).toHaveProperty('name'); + expect(searchTimelineActivities).toHaveProperty('properties'); + expect(searchTimelineActivities).toHaveProperty('linkedRecordCachedName'); + expect(searchTimelineActivities).toHaveProperty('linkedRecordId'); + expect(searchTimelineActivities).toHaveProperty('linkedObjectMetadataId'); + expect(searchTimelineActivities).toHaveProperty('id'); + expect(searchTimelineActivities).toHaveProperty('createdAt'); + expect(searchTimelineActivities).toHaveProperty('updatedAt'); + expect(searchTimelineActivities).toHaveProperty('deletedAt'); + expect(searchTimelineActivities).toHaveProperty('workspaceMemberId'); + expect(searchTimelineActivities).toHaveProperty('personId'); + expect(searchTimelineActivities).toHaveProperty('companyId'); + expect(searchTimelineActivities).toHaveProperty('opportunityId'); + expect(searchTimelineActivities).toHaveProperty('noteId'); + expect(searchTimelineActivities).toHaveProperty('taskId'); + expect(searchTimelineActivities).toHaveProperty('workflowId'); + expect(searchTimelineActivities).toHaveProperty('workflowVersionId'); + expect(searchTimelineActivities).toHaveProperty('workflowRunId'); + expect(searchTimelineActivities).toHaveProperty('rocketId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-fields.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-fields.integration-spec.ts new file mode 100644 index 000000000000..b84def1a813c --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-fields.integration-spec.ts @@ -0,0 +1,61 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchViewFieldsResolver (e2e)', () => { + it('should find many searchViewFields', () => { + const queryData = { + query: ` + query searchViewFields { + searchViewFields { + edges { + node { + fieldMetadataId + isVisible + size + position + id + createdAt + updatedAt + deletedAt + viewId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchViewFields; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchViewFields = edges[0].node; + + expect(searchViewFields).toHaveProperty('fieldMetadataId'); + expect(searchViewFields).toHaveProperty('isVisible'); + expect(searchViewFields).toHaveProperty('size'); + expect(searchViewFields).toHaveProperty('position'); + expect(searchViewFields).toHaveProperty('id'); + expect(searchViewFields).toHaveProperty('createdAt'); + expect(searchViewFields).toHaveProperty('updatedAt'); + expect(searchViewFields).toHaveProperty('deletedAt'); + expect(searchViewFields).toHaveProperty('viewId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-filters.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-filters.integration-spec.ts new file mode 100644 index 000000000000..fe1e96c4b63c --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-filters.integration-spec.ts @@ -0,0 +1,61 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchViewFiltersResolver (e2e)', () => { + it('should find many searchViewFilters', () => { + const queryData = { + query: ` + query searchViewFilters { + searchViewFilters { + edges { + node { + fieldMetadataId + operand + value + displayValue + id + createdAt + updatedAt + deletedAt + viewId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchViewFilters; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchViewFilters = edges[0].node; + + expect(searchViewFilters).toHaveProperty('fieldMetadataId'); + expect(searchViewFilters).toHaveProperty('operand'); + expect(searchViewFilters).toHaveProperty('value'); + expect(searchViewFilters).toHaveProperty('displayValue'); + expect(searchViewFilters).toHaveProperty('id'); + expect(searchViewFilters).toHaveProperty('createdAt'); + expect(searchViewFilters).toHaveProperty('updatedAt'); + expect(searchViewFilters).toHaveProperty('deletedAt'); + expect(searchViewFilters).toHaveProperty('viewId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-sorts.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-sorts.integration-spec.ts new file mode 100644 index 000000000000..7f5b2e6f6a91 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-view-sorts.integration-spec.ts @@ -0,0 +1,57 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchViewSortsResolver (e2e)', () => { + it('should find many searchViewSorts', () => { + const queryData = { + query: ` + query searchViewSorts { + searchViewSorts { + edges { + node { + fieldMetadataId + direction + id + createdAt + updatedAt + deletedAt + viewId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchViewSorts; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchViewSorts = edges[0].node; + + expect(searchViewSorts).toHaveProperty('fieldMetadataId'); + expect(searchViewSorts).toHaveProperty('direction'); + expect(searchViewSorts).toHaveProperty('id'); + expect(searchViewSorts).toHaveProperty('createdAt'); + expect(searchViewSorts).toHaveProperty('updatedAt'); + expect(searchViewSorts).toHaveProperty('deletedAt'); + expect(searchViewSorts).toHaveProperty('viewId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-views.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-views.integration-spec.ts new file mode 100644 index 000000000000..716c4a843301 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-views.integration-spec.ts @@ -0,0 +1,67 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchViewsResolver (e2e)', () => { + it('should find many searchViews', () => { + const queryData = { + query: ` + query searchViews { + searchViews { + edges { + node { + name + objectMetadataId + type + key + icon + kanbanFieldMetadataId + position + isCompact + id + createdAt + updatedAt + deletedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchViews; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchViews = edges[0].node; + + expect(searchViews).toHaveProperty('name'); + expect(searchViews).toHaveProperty('objectMetadataId'); + expect(searchViews).toHaveProperty('type'); + expect(searchViews).toHaveProperty('key'); + expect(searchViews).toHaveProperty('icon'); + expect(searchViews).toHaveProperty('kanbanFieldMetadataId'); + expect(searchViews).toHaveProperty('position'); + expect(searchViews).toHaveProperty('isCompact'); + expect(searchViews).toHaveProperty('id'); + expect(searchViews).toHaveProperty('createdAt'); + expect(searchViews).toHaveProperty('updatedAt'); + expect(searchViews).toHaveProperty('deletedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-webhooks.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-webhooks.integration-spec.ts new file mode 100644 index 000000000000..d5a93db25ec0 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-webhooks.integration-spec.ts @@ -0,0 +1,57 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchWebhooksResolver (e2e)', () => { + it('should find many searchWebhooks', () => { + const queryData = { + query: ` + query searchWebhooks { + searchWebhooks { + edges { + node { + id + targetUrl + operation + description + createdAt + updatedAt + deletedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchWebhooks; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchWebhooks = edges[0].node; + + expect(searchWebhooks).toHaveProperty('id'); + expect(searchWebhooks).toHaveProperty('targetUrl'); + expect(searchWebhooks).toHaveProperty('operation'); + expect(searchWebhooks).toHaveProperty('description'); + expect(searchWebhooks).toHaveProperty('createdAt'); + expect(searchWebhooks).toHaveProperty('updatedAt'); + expect(searchWebhooks).toHaveProperty('deletedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-event-listeners.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-event-listeners.integration-spec.ts new file mode 100644 index 000000000000..ddf55a1a493c --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-event-listeners.integration-spec.ts @@ -0,0 +1,55 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchWorkflowEventListenersResolver (e2e)', () => { + it('should find many searchWorkflowEventListeners', () => { + const queryData = { + query: ` + query searchWorkflowEventListeners { + searchWorkflowEventListeners { + edges { + node { + eventName + id + createdAt + updatedAt + deletedAt + workflowId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchWorkflowEventListeners; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchWorkflowEventListeners = edges[0].node; + + expect(searchWorkflowEventListeners).toHaveProperty('eventName'); + expect(searchWorkflowEventListeners).toHaveProperty('id'); + expect(searchWorkflowEventListeners).toHaveProperty('createdAt'); + expect(searchWorkflowEventListeners).toHaveProperty('updatedAt'); + expect(searchWorkflowEventListeners).toHaveProperty('deletedAt'); + expect(searchWorkflowEventListeners).toHaveProperty('workflowId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-runs.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-runs.integration-spec.ts new file mode 100644 index 000000000000..6307d8ae6bbd --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-runs.integration-spec.ts @@ -0,0 +1,69 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchWorkflowRunsResolver (e2e)', () => { + it('should find many searchWorkflowRuns', () => { + const queryData = { + query: ` + query searchWorkflowRuns { + searchWorkflowRuns { + edges { + node { + workflowRunId + name + startedAt + endedAt + status + output + position + id + createdAt + updatedAt + deletedAt + workflowVersionId + workflowId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchWorkflowRuns; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchWorkflowRuns = edges[0].node; + + expect(searchWorkflowRuns).toHaveProperty('workflowRunId'); + expect(searchWorkflowRuns).toHaveProperty('name'); + expect(searchWorkflowRuns).toHaveProperty('startedAt'); + expect(searchWorkflowRuns).toHaveProperty('endedAt'); + expect(searchWorkflowRuns).toHaveProperty('status'); + expect(searchWorkflowRuns).toHaveProperty('output'); + expect(searchWorkflowRuns).toHaveProperty('position'); + expect(searchWorkflowRuns).toHaveProperty('id'); + expect(searchWorkflowRuns).toHaveProperty('createdAt'); + expect(searchWorkflowRuns).toHaveProperty('updatedAt'); + expect(searchWorkflowRuns).toHaveProperty('deletedAt'); + expect(searchWorkflowRuns).toHaveProperty('workflowVersionId'); + expect(searchWorkflowRuns).toHaveProperty('workflowId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-versions.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-versions.integration-spec.ts new file mode 100644 index 000000000000..86bd6df8099c --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflow-versions.integration-spec.ts @@ -0,0 +1,63 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchWorkflowVersionsResolver (e2e)', () => { + it('should find many searchWorkflowVersions', () => { + const queryData = { + query: ` + query searchWorkflowVersions { + searchWorkflowVersions { + edges { + node { + name + trigger + steps + status + position + id + createdAt + updatedAt + deletedAt + workflowId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchWorkflowVersions; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchWorkflowVersions = edges[0].node; + + expect(searchWorkflowVersions).toHaveProperty('name'); + expect(searchWorkflowVersions).toHaveProperty('trigger'); + expect(searchWorkflowVersions).toHaveProperty('steps'); + expect(searchWorkflowVersions).toHaveProperty('status'); + expect(searchWorkflowVersions).toHaveProperty('position'); + expect(searchWorkflowVersions).toHaveProperty('id'); + expect(searchWorkflowVersions).toHaveProperty('createdAt'); + expect(searchWorkflowVersions).toHaveProperty('updatedAt'); + expect(searchWorkflowVersions).toHaveProperty('deletedAt'); + expect(searchWorkflowVersions).toHaveProperty('workflowId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflows.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflows.integration-spec.ts new file mode 100644 index 000000000000..b12d780dfeb5 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workflows.integration-spec.ts @@ -0,0 +1,59 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchWorkflowsResolver (e2e)', () => { + it('should find many searchWorkflows', () => { + const queryData = { + query: ` + query searchWorkflows { + searchWorkflows { + edges { + node { + name + lastPublishedVersionId + statuses + position + id + createdAt + updatedAt + deletedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchWorkflows; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchWorkflows = edges[0].node; + + expect(searchWorkflows).toHaveProperty('name'); + expect(searchWorkflows).toHaveProperty('lastPublishedVersionId'); + expect(searchWorkflows).toHaveProperty('statuses'); + expect(searchWorkflows).toHaveProperty('position'); + expect(searchWorkflows).toHaveProperty('id'); + expect(searchWorkflows).toHaveProperty('createdAt'); + expect(searchWorkflows).toHaveProperty('updatedAt'); + expect(searchWorkflows).toHaveProperty('deletedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workspace-members.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workspace-members.integration-spec.ts new file mode 100644 index 000000000000..efc76b40438a --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-workspace-members.integration-spec.ts @@ -0,0 +1,67 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('searchWorkspaceMembersResolver (e2e)', () => { + it('should find many searchWorkspaceMembers', () => { + const queryData = { + query: ` + query searchWorkspaceMembers { + searchWorkspaceMembers { + edges { + node { + id + colorScheme + avatarUrl + locale + timeZone + dateFormat + timeFormat + userEmail + userId + createdAt + updatedAt + deletedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.searchWorkspaceMembers; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const searchWorkspaceMembers = edges[0].node; + + expect(searchWorkspaceMembers).toHaveProperty('id'); + expect(searchWorkspaceMembers).toHaveProperty('colorScheme'); + expect(searchWorkspaceMembers).toHaveProperty('avatarUrl'); + expect(searchWorkspaceMembers).toHaveProperty('locale'); + expect(searchWorkspaceMembers).toHaveProperty('timeZone'); + expect(searchWorkspaceMembers).toHaveProperty('dateFormat'); + expect(searchWorkspaceMembers).toHaveProperty('timeFormat'); + expect(searchWorkspaceMembers).toHaveProperty('userEmail'); + expect(searchWorkspaceMembers).toHaveProperty('userId'); + expect(searchWorkspaceMembers).toHaveProperty('createdAt'); + expect(searchWorkspaceMembers).toHaveProperty('updatedAt'); + expect(searchWorkspaceMembers).toHaveProperty('deletedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/serverless-functions.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/serverless-functions.integration-spec.ts new file mode 100644 index 000000000000..9e8d50619e0d --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/serverless-functions.integration-spec.ts @@ -0,0 +1,59 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('serverlessFunctionsResolver (e2e)', () => { + it('should find many serverlessFunctions', () => { + const queryData = { + query: ` + query serverlessFunctions { + serverlessFunctions { + edges { + node { + id + name + description + runtime + latestVersion + syncStatus + createdAt + updatedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.serverlessFunctions; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const serverlessFunctions = edges[0].node; + + expect(serverlessFunctions).toHaveProperty('id'); + expect(serverlessFunctions).toHaveProperty('name'); + expect(serverlessFunctions).toHaveProperty('description'); + expect(serverlessFunctions).toHaveProperty('runtime'); + expect(serverlessFunctions).toHaveProperty('latestVersion'); + expect(serverlessFunctions).toHaveProperty('syncStatus'); + expect(serverlessFunctions).toHaveProperty('createdAt'); + expect(serverlessFunctions).toHaveProperty('updatedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/task-targets.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/task-targets.integration-spec.ts similarity index 92% rename from packages/twenty-server/test/integration/graphql/task-targets.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/task-targets.integration-spec.ts index e54e855d31e5..b9d5cb493093 100644 --- a/packages/twenty-server/test/integration/graphql/task-targets.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/task-targets.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('taskTargetsResolver (integration)', () => { +describe('taskTargetsResolver (e2e)', () => { it('should find many taskTargets', () => { const queryData = { query: ` @@ -18,6 +18,7 @@ describe('taskTargetsResolver (integration)', () => { personId companyId opportunityId + rocketId } } } @@ -53,6 +54,7 @@ describe('taskTargetsResolver (integration)', () => { expect(taskTargets).toHaveProperty('personId'); expect(taskTargets).toHaveProperty('companyId'); expect(taskTargets).toHaveProperty('opportunityId'); + expect(taskTargets).toHaveProperty('rocketId'); } }); }); diff --git a/packages/twenty-server/test/integration/graphql/tasks.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/tasks.integration-spec.ts similarity index 97% rename from packages/twenty-server/test/integration/graphql/tasks.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/tasks.integration-spec.ts index 900fd3de5ce1..016341966bd0 100644 --- a/packages/twenty-server/test/integration/graphql/tasks.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/tasks.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('tasksResolver (integration)', () => { +describe('tasksResolver (e2e)', () => { it('should find many tasks', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/timeline-activities.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/timeline-activities.integration-spec.ts similarity index 84% rename from packages/twenty-server/test/integration/graphql/timeline-activities.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/timeline-activities.integration-spec.ts index a5ef6a5f9662..3e5c72fec0ac 100644 --- a/packages/twenty-server/test/integration/graphql/timeline-activities.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/timeline-activities.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('timelineActivitiesResolver (integration)', () => { +describe('timelineActivitiesResolver (e2e)', () => { it('should find many timelineActivities', () => { const queryData = { query: ` @@ -26,6 +26,10 @@ describe('timelineActivitiesResolver (integration)', () => { opportunityId noteId taskId + workflowId + workflowVersionId + workflowRunId + rocketId } } } @@ -69,6 +73,10 @@ describe('timelineActivitiesResolver (integration)', () => { expect(timelineActivities).toHaveProperty('opportunityId'); expect(timelineActivities).toHaveProperty('noteId'); expect(timelineActivities).toHaveProperty('taskId'); + expect(timelineActivities).toHaveProperty('workflowId'); + expect(timelineActivities).toHaveProperty('workflowVersionId'); + expect(timelineActivities).toHaveProperty('workflowRunId'); + expect(timelineActivities).toHaveProperty('rocketId'); } }); }); diff --git a/packages/twenty-server/test/integration/graphql/view-fields.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/view-fields.integration-spec.ts similarity index 96% rename from packages/twenty-server/test/integration/graphql/view-fields.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/view-fields.integration-spec.ts index 058568763900..24b28bc5b6d9 100644 --- a/packages/twenty-server/test/integration/graphql/view-fields.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/view-fields.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('viewFieldsResolver (integration)', () => { +describe('viewFieldsResolver (e2e)', () => { it('should find many viewFields', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/view-filters.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/view-filters.integration-spec.ts similarity index 96% rename from packages/twenty-server/test/integration/graphql/view-filters.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/view-filters.integration-spec.ts index 8caa942b2b61..e76c2f12fd08 100644 --- a/packages/twenty-server/test/integration/graphql/view-filters.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/view-filters.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('viewFiltersResolver (integration)', () => { +describe('viewFiltersResolver (e2e)', () => { it('should find many viewFilters', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/view-sorts.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/view-sorts.integration-spec.ts similarity index 96% rename from packages/twenty-server/test/integration/graphql/view-sorts.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/view-sorts.integration-spec.ts index fc29b1d4c293..850d24cf8795 100644 --- a/packages/twenty-server/test/integration/graphql/view-sorts.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/view-sorts.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('viewSortsResolver (integration)', () => { +describe('viewSortsResolver (e2e)', () => { it('should find many viewSorts', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/views.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/views.integration-spec.ts similarity index 97% rename from packages/twenty-server/test/integration/graphql/views.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/views.integration-spec.ts index 122a8c398fcc..29cf849985f0 100644 --- a/packages/twenty-server/test/integration/graphql/views.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/views.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('viewsResolver (integration)', () => { +describe('viewsResolver (e2e)', () => { it('should find many views', () => { const queryData = { query: ` @@ -10,13 +10,13 @@ describe('viewsResolver (integration)', () => { views { edges { node { - position name objectMetadataId type key icon kanbanFieldMetadataId + position isCompact id createdAt @@ -49,13 +49,13 @@ describe('viewsResolver (integration)', () => { if (edges.length > 0) { const views = edges[0].node; - expect(views).toHaveProperty('position'); expect(views).toHaveProperty('name'); expect(views).toHaveProperty('objectMetadataId'); expect(views).toHaveProperty('type'); expect(views).toHaveProperty('key'); expect(views).toHaveProperty('icon'); expect(views).toHaveProperty('kanbanFieldMetadataId'); + expect(views).toHaveProperty('position'); expect(views).toHaveProperty('isCompact'); expect(views).toHaveProperty('id'); expect(views).toHaveProperty('createdAt'); diff --git a/packages/twenty-server/test/integration/graphql/webhooks.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/webhooks.integration-spec.ts similarity index 96% rename from packages/twenty-server/test/integration/graphql/webhooks.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/webhooks.integration-spec.ts index 7c4224b69aa6..aaf181bf3849 100644 --- a/packages/twenty-server/test/integration/graphql/webhooks.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/webhooks.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('webhooksResolver (integration)', () => { +describe('webhooksResolver (e2e)', () => { it('should find many webhooks', () => { const queryData = { query: ` @@ -10,10 +10,10 @@ describe('webhooksResolver (integration)', () => { webhooks { edges { node { + id targetUrl operation description - id createdAt updatedAt deletedAt @@ -44,10 +44,10 @@ describe('webhooksResolver (integration)', () => { if (edges.length > 0) { const webhooks = edges[0].node; + expect(webhooks).toHaveProperty('id'); expect(webhooks).toHaveProperty('targetUrl'); expect(webhooks).toHaveProperty('operation'); expect(webhooks).toHaveProperty('description'); - expect(webhooks).toHaveProperty('id'); expect(webhooks).toHaveProperty('createdAt'); expect(webhooks).toHaveProperty('updatedAt'); expect(webhooks).toHaveProperty('deletedAt'); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-event-listeners.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-event-listeners.integration-spec.ts new file mode 100644 index 000000000000..6859b52abe29 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-event-listeners.integration-spec.ts @@ -0,0 +1,55 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('workflowEventListenersResolver (e2e)', () => { + it('should find many workflowEventListeners', () => { + const queryData = { + query: ` + query workflowEventListeners { + workflowEventListeners { + edges { + node { + eventName + id + createdAt + updatedAt + deletedAt + workflowId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.workflowEventListeners; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const workflowEventListeners = edges[0].node; + + expect(workflowEventListeners).toHaveProperty('eventName'); + expect(workflowEventListeners).toHaveProperty('id'); + expect(workflowEventListeners).toHaveProperty('createdAt'); + expect(workflowEventListeners).toHaveProperty('updatedAt'); + expect(workflowEventListeners).toHaveProperty('deletedAt'); + expect(workflowEventListeners).toHaveProperty('workflowId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-runs.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-runs.integration-spec.ts new file mode 100644 index 000000000000..c37004e4b910 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-runs.integration-spec.ts @@ -0,0 +1,69 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('workflowRunsResolver (e2e)', () => { + it('should find many workflowRuns', () => { + const queryData = { + query: ` + query workflowRuns { + workflowRuns { + edges { + node { + workflowRunId + name + startedAt + endedAt + status + output + position + id + createdAt + updatedAt + deletedAt + workflowVersionId + workflowId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.workflowRuns; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const workflowRuns = edges[0].node; + + expect(workflowRuns).toHaveProperty('workflowRunId'); + expect(workflowRuns).toHaveProperty('name'); + expect(workflowRuns).toHaveProperty('startedAt'); + expect(workflowRuns).toHaveProperty('endedAt'); + expect(workflowRuns).toHaveProperty('status'); + expect(workflowRuns).toHaveProperty('output'); + expect(workflowRuns).toHaveProperty('position'); + expect(workflowRuns).toHaveProperty('id'); + expect(workflowRuns).toHaveProperty('createdAt'); + expect(workflowRuns).toHaveProperty('updatedAt'); + expect(workflowRuns).toHaveProperty('deletedAt'); + expect(workflowRuns).toHaveProperty('workflowVersionId'); + expect(workflowRuns).toHaveProperty('workflowId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-versions.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-versions.integration-spec.ts new file mode 100644 index 000000000000..cf3a7d113e8d --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-versions.integration-spec.ts @@ -0,0 +1,63 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('workflowVersionsResolver (e2e)', () => { + it('should find many workflowVersions', () => { + const queryData = { + query: ` + query workflowVersions { + workflowVersions { + edges { + node { + name + trigger + steps + status + position + id + createdAt + updatedAt + deletedAt + workflowId + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.workflowVersions; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const workflowVersions = edges[0].node; + + expect(workflowVersions).toHaveProperty('name'); + expect(workflowVersions).toHaveProperty('trigger'); + expect(workflowVersions).toHaveProperty('steps'); + expect(workflowVersions).toHaveProperty('status'); + expect(workflowVersions).toHaveProperty('position'); + expect(workflowVersions).toHaveProperty('id'); + expect(workflowVersions).toHaveProperty('createdAt'); + expect(workflowVersions).toHaveProperty('updatedAt'); + expect(workflowVersions).toHaveProperty('deletedAt'); + expect(workflowVersions).toHaveProperty('workflowId'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/workflows.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/workflows.integration-spec.ts new file mode 100644 index 000000000000..a1c0450f02bc --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/workflows.integration-spec.ts @@ -0,0 +1,59 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +describe('workflowsResolver (e2e)', () => { + it('should find many workflows', () => { + const queryData = { + query: ` + query workflows { + workflows { + edges { + node { + name + lastPublishedVersionId + statuses + position + id + createdAt + updatedAt + deletedAt + } + } + } + } + `, + }; + + return client + .post('/graphql') + .set('Authorization', `Bearer ${ACCESS_TOKEN}`) + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.workflows; + + expect(data).toBeDefined(); + expect(Array.isArray(data.edges)).toBe(true); + + const edges = data.edges; + + if (edges.length > 0) { + const workflows = edges[0].node; + + expect(workflows).toHaveProperty('name'); + expect(workflows).toHaveProperty('lastPublishedVersionId'); + expect(workflows).toHaveProperty('statuses'); + expect(workflows).toHaveProperty('position'); + expect(workflows).toHaveProperty('id'); + expect(workflows).toHaveProperty('createdAt'); + expect(workflows).toHaveProperty('updatedAt'); + expect(workflows).toHaveProperty('deletedAt'); + } + }); + }); +}); diff --git a/packages/twenty-server/test/integration/graphql/workspace-members.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/workspace-members.integration-spec.ts similarity index 97% rename from packages/twenty-server/test/integration/graphql/workspace-members.integration-spec.ts rename to packages/twenty-server/test/integration/graphql/suites/object-generated/workspace-members.integration-spec.ts index 5ef7a415d886..63fd94d81baa 100644 --- a/packages/twenty-server/test/integration/graphql/workspace-members.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/workspace-members.integration-spec.ts @@ -2,7 +2,7 @@ import request from 'supertest'; const client = request(`http://localhost:${APP_PORT}`); -describe('workspaceMembersResolver (integration)', () => { +describe('workspaceMembersResolver (e2e)', () => { it('should find many workspaceMembers', () => { const queryData = { query: ` diff --git a/packages/twenty-server/test/integration/graphql/utils/create-many-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/create-many-operation-factory.util.ts new file mode 100644 index 000000000000..70604c009399 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/utils/create-many-operation-factory.util.ts @@ -0,0 +1,28 @@ +import gql from 'graphql-tag'; + +import { capitalize } from 'src/utils/capitalize'; + +type CreateManyOperationFactoryParams = { + objectMetadataSingularName: string; + objectMetadataPluralName: string; + gqlFields: string; + data?: object; +}; + +export const createManyOperationFactory = ({ + objectMetadataSingularName, + objectMetadataPluralName, + gqlFields, + data = {}, +}: CreateManyOperationFactoryParams) => ({ + query: gql` + mutation Create${capitalize(objectMetadataSingularName)}($data: [${capitalize(objectMetadataSingularName)}CreateInput!]!) { + create${capitalize(objectMetadataPluralName)}(data: $data) { + ${gqlFields} + } + } + `, + variables: { + data, + }, +}); diff --git a/packages/twenty-server/test/integration/graphql/utils/create-one-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/create-one-operation-factory.util.ts new file mode 100644 index 000000000000..ed477b1a7792 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/utils/create-one-operation-factory.util.ts @@ -0,0 +1,26 @@ +import gql from 'graphql-tag'; + +import { capitalize } from 'src/utils/capitalize'; + +type CreateOneOperationFactoryParams = { + objectMetadataSingularName: string; + gqlFields: string; + data?: object; +}; + +export const createOneOperationFactory = ({ + objectMetadataSingularName, + gqlFields, + data = {}, +}: CreateOneOperationFactoryParams) => ({ + query: gql` + mutation Create${capitalize(objectMetadataSingularName)}($data: ${capitalize(objectMetadataSingularName)}CreateInput) { + create${capitalize(objectMetadataSingularName)}(data: $data) { + ${gqlFields} + } + } + `, + variables: { + data, + }, +}); diff --git a/packages/twenty-server/test/integration/graphql/utils/delete-many-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/delete-many-operation-factory.util.ts new file mode 100644 index 000000000000..2bfe3c158e7a --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/utils/delete-many-operation-factory.util.ts @@ -0,0 +1,30 @@ +import gql from 'graphql-tag'; + +import { capitalize } from 'src/utils/capitalize'; + +type DeleteManyOperationFactoryParams = { + objectMetadataSingularName: string; + objectMetadataPluralName: string; + gqlFields: string; + filter?: object; +}; + +export const deleteManyOperationFactory = ({ + objectMetadataSingularName, + objectMetadataPluralName, + gqlFields, + filter = {}, +}: DeleteManyOperationFactoryParams) => ({ + query: gql` + mutation Delete${capitalize(objectMetadataPluralName)}( + $filter: ${capitalize(objectMetadataSingularName)}FilterInput + ) { + delete${capitalize(objectMetadataPluralName)}(filter: $filter) { + ${gqlFields} + } + } + `, + variables: { + filter, + }, +}); diff --git a/packages/twenty-server/test/integration/graphql/utils/delete-one-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/delete-one-operation-factory.util.ts new file mode 100644 index 000000000000..f3cfd765b25a --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/utils/delete-one-operation-factory.util.ts @@ -0,0 +1,26 @@ +import gql from 'graphql-tag'; + +import { capitalize } from 'src/utils/capitalize'; + +type DeleteOneOperationFactoryParams = { + objectMetadataSingularName: string; + gqlFields: string; + recordId: string; +}; + +export const deleteOneOperationFactory = ({ + objectMetadataSingularName, + gqlFields, + recordId, +}: DeleteOneOperationFactoryParams) => ({ + query: gql` + mutation Delete${capitalize(objectMetadataSingularName)}($${objectMetadataSingularName}Id: ID!) { + delete${capitalize(objectMetadataSingularName)}(id: $${objectMetadataSingularName}Id) { + ${gqlFields} + } + } + `, + variables: { + [`${objectMetadataSingularName}Id`]: recordId, + }, +}); diff --git a/packages/twenty-server/test/integration/graphql/utils/destroy-many-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/destroy-many-operation-factory.util.ts new file mode 100644 index 000000000000..f664a4088268 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/utils/destroy-many-operation-factory.util.ts @@ -0,0 +1,30 @@ +import gql from 'graphql-tag'; + +import { capitalize } from 'src/utils/capitalize'; + +type DestroyManyOperationFactoryParams = { + objectMetadataSingularName: string; + objectMetadataPluralName: string; + gqlFields: string; + filter?: object; +}; + +export const destroyManyOperationFactory = ({ + objectMetadataSingularName, + objectMetadataPluralName, + gqlFields, + filter = {}, +}: DestroyManyOperationFactoryParams) => ({ + query: gql` + mutation Destroy${capitalize(objectMetadataPluralName)}( + $filter: ${capitalize(objectMetadataSingularName)}FilterInput + ) { + destroy${capitalize(objectMetadataPluralName)}(filter: $filter) { + ${gqlFields} + } + } + `, + variables: { + filter, + }, +}); diff --git a/packages/twenty-server/test/integration/graphql/utils/destroy-one-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/destroy-one-operation-factory.util.ts new file mode 100644 index 000000000000..4062e9319f5a --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/utils/destroy-one-operation-factory.util.ts @@ -0,0 +1,26 @@ +import gql from 'graphql-tag'; + +import { capitalize } from 'src/utils/capitalize'; + +type DestroyOneOperationFactoryParams = { + objectMetadataSingularName: string; + gqlFields: string; + recordId: string; +}; + +export const destroyOneOperationFactory = ({ + objectMetadataSingularName, + gqlFields, + recordId, +}: DestroyOneOperationFactoryParams) => ({ + query: gql` + mutation Destroy${capitalize(objectMetadataSingularName)}($${objectMetadataSingularName}Id: ID!) { + destroy${capitalize(objectMetadataSingularName)}(id: $${objectMetadataSingularName}Id) { + ${gqlFields} + } + } + `, + variables: { + [`${objectMetadataSingularName}Id`]: recordId, + }, +}); diff --git a/packages/twenty-server/test/integration/graphql/utils/find-many-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/find-many-operation-factory.util.ts new file mode 100644 index 000000000000..752e9aca0c20 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/utils/find-many-operation-factory.util.ts @@ -0,0 +1,32 @@ +import gql from 'graphql-tag'; + +import { capitalize } from 'src/utils/capitalize'; + +type FindManyOperationFactoryParams = { + objectMetadataSingularName: string; + objectMetadataPluralName: string; + gqlFields: string; + filter?: object; +}; + +export const findManyOperationFactory = ({ + objectMetadataSingularName, + objectMetadataPluralName, + gqlFields, + filter = {}, +}: FindManyOperationFactoryParams) => ({ + query: gql` + query ${capitalize(objectMetadataPluralName)}($filter: ${capitalize(objectMetadataSingularName)}FilterInput) { + ${objectMetadataPluralName}(filter: $filter) { + edges { + node { + ${gqlFields} + } + } + } + } + `, + variables: { + filter, + }, +}); diff --git a/packages/twenty-server/test/integration/graphql/utils/find-one-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/find-one-operation-factory.util.ts new file mode 100644 index 000000000000..1a6972a841a9 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/utils/find-one-operation-factory.util.ts @@ -0,0 +1,26 @@ +import gql from 'graphql-tag'; + +import { capitalize } from 'src/utils/capitalize'; + +type FindOneOperationFactoryParams = { + objectMetadataSingularName: string; + gqlFields: string; + filter?: object; +}; + +export const findOneOperationFactory = ({ + objectMetadataSingularName, + gqlFields, + filter = {}, +}: FindOneOperationFactoryParams) => ({ + query: gql` + query ${capitalize(objectMetadataSingularName)}($filter: ${capitalize(objectMetadataSingularName)}FilterInput) { + ${objectMetadataSingularName}(filter: $filter) { + ${gqlFields} + } + } + `, + variables: { + filter, + }, +}); diff --git a/packages/twenty-server/test/integration/utils/make-graphql-api-request.ts b/packages/twenty-server/test/integration/graphql/utils/make-graphql-api-request.util.ts similarity index 100% rename from packages/twenty-server/test/integration/utils/make-graphql-api-request.ts rename to packages/twenty-server/test/integration/graphql/utils/make-graphql-api-request.util.ts diff --git a/packages/twenty-server/test/integration/graphql/utils/update-many-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/update-many-operation-factory.util.ts new file mode 100644 index 000000000000..ba6507a89bb0 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/utils/update-many-operation-factory.util.ts @@ -0,0 +1,31 @@ +import gql from 'graphql-tag'; + +import { capitalize } from 'src/utils/capitalize'; + +type UpdateManyOperationFactoryParams = { + objectMetadataSingularName: string; + objectMetadataPluralName: string; + gqlFields: string; + data?: object; +}; + +export const updateManyOperationFactory = ({ + objectMetadataSingularName, + objectMetadataPluralName, + gqlFields, + data = {}, +}: UpdateManyOperationFactoryParams) => ({ + query: gql` + mutation Update${capitalize(objectMetadataPluralName)}( + $data: ${objectMetadataSingularName}UpdateInput + $filter: ${objectMetadataSingularName}FilterInput + ) { + update${capitalize(objectMetadataPluralName)}(data: $data, filter: $filter) { + ${gqlFields} + } + } + `, + variables: { + data, + }, +}); diff --git a/packages/twenty-server/test/integration/graphql/utils/update-one-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/update-one-operation-factory.util.ts new file mode 100644 index 000000000000..9a5332a53de6 --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/utils/update-one-operation-factory.util.ts @@ -0,0 +1,26 @@ +import gql from 'graphql-tag'; + +import { capitalize } from 'src/utils/capitalize'; + +type UpdateOneOperationFactoryParams = { + objectMetadataSingularName: string; + gqlFields: string; + data?: object; +}; + +export const updateOneOperationFactory = ({ + objectMetadataSingularName, + gqlFields, + data = {}, +}: UpdateOneOperationFactoryParams) => ({ + query: gql` + mutation Update${capitalize(objectMetadataSingularName)}($${objectMetadataSingularName}Id: ID, $data: ${objectMetadataSingularName}UpdateInput) { + update${capitalize(objectMetadataSingularName)}(id: $${objectMetadataSingularName}Id, data: $data) { + ${gqlFields} + } + } + `, + variables: { + data, + }, +}); From 66396cecfee5756874f429bd3a4677ec115e48ef Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Thu, 17 Oct 2024 18:56:10 +0200 Subject: [PATCH 5/7] Fix tests --- .../suites/all-resolvers.integration-spec.ts | 100 ++++++++++++++++-- .../calendar-events.integration-spec.ts | 73 ------------- .../messages.integration-spec.ts | 66 ------------ .../workflow-runs.integration-spec.ts | 69 ------------ .../update-many-operation-factory.util.ts | 7 +- .../update-one-operation-factory.util.ts | 5 +- 6 files changed, 99 insertions(+), 221 deletions(-) delete mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-events.integration-spec.ts delete mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/messages.integration-spec.ts delete mode 100644 packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-runs.integration-spec.ts diff --git a/packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts index e102fe9422d6..a81d9fceef81 100644 --- a/packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts @@ -7,6 +7,8 @@ import { destroyOneOperationFactory } from 'test/integration/graphql/utils/destr import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util'; import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util'; import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util'; +import { updateManyOperationFactory } from 'test/integration/graphql/utils/update-many-operation-factory.util'; +import { updateOneOperationFactory } from 'test/integration/graphql/utils/update-one-operation-factory.util'; import { generateRecordName } from 'test/integration/utils/generate-record-name'; const COMPANY_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987'; @@ -166,7 +168,85 @@ describe('companies resolvers (integration)', () => { expect(company).toHaveProperty('visaSponsorship'); }); - it('3. should delete many companies', async () => { + it('3. should update many companies', async () => { + const graphqlOperation = updateManyOperationFactory({ + objectMetadataSingularName: 'company', + objectMetadataPluralName: 'companies', + gqlFields: COMPANY_GQL_FIELDS, + data: { + employees: 123, + }, + filter: { + id: { + in: [COMPANY_1_ID, COMPANY_2_ID], + }, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + console.log(response); + + const updatedCompanies = response.body.data.updateCompanies; + + expect(updatedCompanies).toHaveLength(2); + + updatedCompanies.forEach((company) => { + expect(company.employees).toEqual(123); + }); + }); + + it('3b. should update one company', async () => { + const graphqlOperation = updateOneOperationFactory({ + objectMetadataSingularName: 'company', + gqlFields: COMPANY_GQL_FIELDS, + data: { + employees: 122, + }, + recordId: COMPANY_3_ID, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + const updatedCompany = response.body.data.updateCompany; + + expect(updatedCompany.employees).toEqual(122); + }); + + it('4. should find many companies with updated employees', async () => { + const graphqlOperation = findManyOperationFactory({ + objectMetadataSingularName: 'company', + objectMetadataPluralName: 'companies', + gqlFields: COMPANY_GQL_FIELDS, + filter: { + employees: { + eq: 123, + }, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + expect(response.body.data.companies.edges).toHaveLength(2); + }); + + it('4b. should find one company with updated employees', async () => { + const graphqlOperation = findOneOperationFactory({ + objectMetadataSingularName: 'company', + gqlFields: COMPANY_GQL_FIELDS, + filter: { + employees: { + eq: 122, + }, + }, + }); + + const response = await makeGraphqlAPIRequest(graphqlOperation); + + expect(response.body.data.company.employees).toEqual(122); + }); + + it('5. should delete many companies', async () => { const graphqlOperation = deleteManyOperationFactory({ objectMetadataSingularName: 'company', objectMetadataPluralName: 'companies', @@ -189,7 +269,7 @@ describe('companies resolvers (integration)', () => { }); }); - it('3b. should delete one company', async () => { + it('5b. should delete one company', async () => { const graphqlOperation = deleteOneOperationFactory({ objectMetadataSingularName: 'company', gqlFields: COMPANY_GQL_FIELDS, @@ -201,7 +281,7 @@ describe('companies resolvers (integration)', () => { expect(response.body.data.deleteCompany.deletedAt).toBeTruthy(); }); - it('4. should not find many companies anymore', async () => { + it('6. should not find many companies anymore', async () => { const graphqlOperation = findManyOperationFactory({ objectMetadataSingularName: 'company', objectMetadataPluralName: 'companies', @@ -218,7 +298,7 @@ describe('companies resolvers (integration)', () => { expect(findCompaniesResponse.body.data.companies.edges).toHaveLength(0); }); - it('4b. should not find one company anymore', async () => { + it('6b. should not find one company anymore', async () => { const graphqlOperation = findOneOperationFactory({ objectMetadataSingularName: 'company', gqlFields: COMPANY_GQL_FIELDS, @@ -234,7 +314,7 @@ describe('companies resolvers (integration)', () => { expect(response.body.data.company).toBeNull(); }); - it('5. should find many deleted companies with deletedAt filter', async () => { + it('7. should find many deleted companies with deletedAt filter', async () => { const graphqlOperation = findManyOperationFactory({ objectMetadataSingularName: 'company', objectMetadataPluralName: 'companies', @@ -256,7 +336,7 @@ describe('companies resolvers (integration)', () => { expect(response.body.data.companies.edges).toHaveLength(2); }); - it('5b. should find one deleted company with deletedAt filter', async () => { + it('7b. should find one deleted company with deletedAt filter', async () => { const graphqlOperation = findOneOperationFactory({ objectMetadataSingularName: 'company', gqlFields: COMPANY_GQL_FIELDS, @@ -277,7 +357,7 @@ describe('companies resolvers (integration)', () => { expect(response.body.data.company.id).toEqual(COMPANY_3_ID); }); - it('6. should destroy many companies', async () => { + it('8. should destroy many companies', async () => { const graphqlOperation = destroyManyOperationFactory({ objectMetadataSingularName: 'company', objectMetadataPluralName: 'companies', @@ -294,7 +374,7 @@ describe('companies resolvers (integration)', () => { expect(response.body.data.destroyCompanies).toHaveLength(2); }); - it('6b. should destroy one company', async () => { + it('8b. should destroy one company', async () => { const graphqlOperation = destroyOneOperationFactory({ objectMetadataSingularName: 'company', gqlFields: COMPANY_GQL_FIELDS, @@ -307,7 +387,7 @@ describe('companies resolvers (integration)', () => { expect(destroyCompanyResponse.body.data.destroyCompany).toBeTruthy(); }); - it('7. should not find many companies anymore', async () => { + it('9. should not find many companies anymore', async () => { const graphqlOperation = findManyOperationFactory({ objectMetadataSingularName: 'company', objectMetadataPluralName: 'companies', @@ -329,7 +409,7 @@ describe('companies resolvers (integration)', () => { expect(response.body.data.companies.edges).toHaveLength(0); }); - it('7b. should not find one company anymore', async () => { + it('9b. should not find one company anymore', async () => { const graphqlOperation = findOneOperationFactory({ objectMetadataSingularName: 'company', gqlFields: COMPANY_GQL_FIELDS, diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-events.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-events.integration-spec.ts deleted file mode 100644 index 38ff727a1ee0..000000000000 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-events.integration-spec.ts +++ /dev/null @@ -1,73 +0,0 @@ -import request from 'supertest'; - -const client = request(`http://localhost:${APP_PORT}`); - -describe('calendarEventsResolver (e2e)', () => { - it('should find many calendarEvents', () => { - const queryData = { - query: ` - query calendarEvents { - calendarEvents { - edges { - node { - title - isCanceled - isFullDay - startsAt - endsAt - externalCreatedAt - externalUpdatedAt - description - location - iCalUID - conferenceSolution - id - createdAt - updatedAt - deletedAt - } - } - } - } - `, - }; - - return client - .post('/graphql') - .set('Authorization', `Bearer ${ACCESS_TOKEN}`) - .send(queryData) - .expect(200) - .expect((res) => { - expect(res.body.data).toBeDefined(); - expect(res.body.errors).toBeUndefined(); - }) - .expect((res) => { - const data = res.body.data.calendarEvents; - - expect(data).toBeDefined(); - expect(Array.isArray(data.edges)).toBe(true); - - const edges = data.edges; - - if (edges.length > 0) { - const calendarEvents = edges[0].node; - - expect(calendarEvents).toHaveProperty('title'); - expect(calendarEvents).toHaveProperty('isCanceled'); - expect(calendarEvents).toHaveProperty('isFullDay'); - expect(calendarEvents).toHaveProperty('startsAt'); - expect(calendarEvents).toHaveProperty('endsAt'); - expect(calendarEvents).toHaveProperty('externalCreatedAt'); - expect(calendarEvents).toHaveProperty('externalUpdatedAt'); - expect(calendarEvents).toHaveProperty('description'); - expect(calendarEvents).toHaveProperty('location'); - expect(calendarEvents).toHaveProperty('iCalUID'); - expect(calendarEvents).toHaveProperty('conferenceSolution'); - expect(calendarEvents).toHaveProperty('id'); - expect(calendarEvents).toHaveProperty('createdAt'); - expect(calendarEvents).toHaveProperty('updatedAt'); - expect(calendarEvents).toHaveProperty('deletedAt'); - } - }); - }); -}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/messages.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/messages.integration-spec.ts deleted file mode 100644 index c90cfeb2f8a7..000000000000 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/messages.integration-spec.ts +++ /dev/null @@ -1,66 +0,0 @@ -import request from 'supertest'; - -const client = request(`http://localhost:${APP_PORT}`); - -describe('messagesResolver (e2e)', () => { - it('should find many messages', () => { - const queryData = { - query: ` - query messages($filter: MessageFilterInput) { - messages(filter: $filter) { - edges { - node { - headerMessageId - subject - text - receivedAt - id - createdAt - updatedAt - deletedAt - messageThreadId - } - } - } - } - `, - variables: { - filter: { - id: 'b1305b29-f5d6-4388-b7f6-2c136d543563', - }, - }, - }; - - return client - .post('/graphql') - .set('Authorization', `Bearer ${ACCESS_TOKEN}`) - .send(queryData) - .expect(200) - .expect((res) => { - expect(res.body.data).toBeDefined(); - expect(res.body.errors).toBeUndefined(); - }) - .expect((res) => { - const data = res.body.data.messages; - - expect(data).toBeDefined(); - expect(Array.isArray(data.edges)).toBe(true); - - const edges = data.edges; - - if (edges.length > 0) { - const messages = edges[0].node; - - expect(messages).toHaveProperty('headerMessageId'); - expect(messages).toHaveProperty('subject'); - expect(messages).toHaveProperty('text'); - expect(messages).toHaveProperty('receivedAt'); - expect(messages).toHaveProperty('id'); - expect(messages).toHaveProperty('createdAt'); - expect(messages).toHaveProperty('updatedAt'); - expect(messages).toHaveProperty('deletedAt'); - expect(messages).toHaveProperty('messageThreadId'); - } - }); - }); -}); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-runs.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-runs.integration-spec.ts deleted file mode 100644 index c37004e4b910..000000000000 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/workflow-runs.integration-spec.ts +++ /dev/null @@ -1,69 +0,0 @@ -import request from 'supertest'; - -const client = request(`http://localhost:${APP_PORT}`); - -describe('workflowRunsResolver (e2e)', () => { - it('should find many workflowRuns', () => { - const queryData = { - query: ` - query workflowRuns { - workflowRuns { - edges { - node { - workflowRunId - name - startedAt - endedAt - status - output - position - id - createdAt - updatedAt - deletedAt - workflowVersionId - workflowId - } - } - } - } - `, - }; - - return client - .post('/graphql') - .set('Authorization', `Bearer ${ACCESS_TOKEN}`) - .send(queryData) - .expect(200) - .expect((res) => { - expect(res.body.data).toBeDefined(); - expect(res.body.errors).toBeUndefined(); - }) - .expect((res) => { - const data = res.body.data.workflowRuns; - - expect(data).toBeDefined(); - expect(Array.isArray(data.edges)).toBe(true); - - const edges = data.edges; - - if (edges.length > 0) { - const workflowRuns = edges[0].node; - - expect(workflowRuns).toHaveProperty('workflowRunId'); - expect(workflowRuns).toHaveProperty('name'); - expect(workflowRuns).toHaveProperty('startedAt'); - expect(workflowRuns).toHaveProperty('endedAt'); - expect(workflowRuns).toHaveProperty('status'); - expect(workflowRuns).toHaveProperty('output'); - expect(workflowRuns).toHaveProperty('position'); - expect(workflowRuns).toHaveProperty('id'); - expect(workflowRuns).toHaveProperty('createdAt'); - expect(workflowRuns).toHaveProperty('updatedAt'); - expect(workflowRuns).toHaveProperty('deletedAt'); - expect(workflowRuns).toHaveProperty('workflowVersionId'); - expect(workflowRuns).toHaveProperty('workflowId'); - } - }); - }); -}); diff --git a/packages/twenty-server/test/integration/graphql/utils/update-many-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/update-many-operation-factory.util.ts index ba6507a89bb0..688ae9199950 100644 --- a/packages/twenty-server/test/integration/graphql/utils/update-many-operation-factory.util.ts +++ b/packages/twenty-server/test/integration/graphql/utils/update-many-operation-factory.util.ts @@ -7,6 +7,7 @@ type UpdateManyOperationFactoryParams = { objectMetadataPluralName: string; gqlFields: string; data?: object; + filter?: object; }; export const updateManyOperationFactory = ({ @@ -14,11 +15,12 @@ export const updateManyOperationFactory = ({ objectMetadataPluralName, gqlFields, data = {}, + filter = {}, }: UpdateManyOperationFactoryParams) => ({ query: gql` mutation Update${capitalize(objectMetadataPluralName)}( - $data: ${objectMetadataSingularName}UpdateInput - $filter: ${objectMetadataSingularName}FilterInput + $data: ${capitalize(objectMetadataSingularName)}UpdateInput + $filter: ${capitalize(objectMetadataSingularName)}FilterInput ) { update${capitalize(objectMetadataPluralName)}(data: $data, filter: $filter) { ${gqlFields} @@ -27,5 +29,6 @@ export const updateManyOperationFactory = ({ `, variables: { data, + filter, }, }); diff --git a/packages/twenty-server/test/integration/graphql/utils/update-one-operation-factory.util.ts b/packages/twenty-server/test/integration/graphql/utils/update-one-operation-factory.util.ts index 9a5332a53de6..cf7827241292 100644 --- a/packages/twenty-server/test/integration/graphql/utils/update-one-operation-factory.util.ts +++ b/packages/twenty-server/test/integration/graphql/utils/update-one-operation-factory.util.ts @@ -6,15 +6,17 @@ type UpdateOneOperationFactoryParams = { objectMetadataSingularName: string; gqlFields: string; data?: object; + recordId: string; }; export const updateOneOperationFactory = ({ objectMetadataSingularName, gqlFields, data = {}, + recordId, }: UpdateOneOperationFactoryParams) => ({ query: gql` - mutation Update${capitalize(objectMetadataSingularName)}($${objectMetadataSingularName}Id: ID, $data: ${objectMetadataSingularName}UpdateInput) { + mutation Update${capitalize(objectMetadataSingularName)}($${objectMetadataSingularName}Id: ID, $data: ${capitalize(objectMetadataSingularName)}UpdateInput) { update${capitalize(objectMetadataSingularName)}(id: $${objectMetadataSingularName}Id, data: $data) { ${gqlFields} } @@ -22,5 +24,6 @@ export const updateOneOperationFactory = ({ `, variables: { data, + [`${objectMetadataSingularName}Id`]: recordId, }, }); From 83931410fe49d4afd0b51e7537b98804e6808948 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Thu, 17 Oct 2024 19:01:51 +0200 Subject: [PATCH 6/7] Fix --- packages/twenty-server/project.json | 2 +- .../graphql/suites/auth.integration-spec.ts | 80 +++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 packages/twenty-server/test/integration/graphql/suites/auth.integration-spec.ts diff --git a/packages/twenty-server/project.json b/packages/twenty-server/project.json index 12f1fe5703ad..de8dec76a92d 100644 --- a/packages/twenty-server/project.json +++ b/packages/twenty-server/project.json @@ -16,7 +16,7 @@ "options": { "cwd": "packages/twenty-server", "commands": [ - "NODE_ENV=test nx jest --config ./jest-integration.config.ts" + "NODE_ENV=test nx database:reset > reset-logs.log && NODE_ENV=test nx jest --config ./jest-integration.config.ts" ] }, "parallel": false diff --git a/packages/twenty-server/test/integration/graphql/suites/auth.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/auth.integration-spec.ts new file mode 100644 index 000000000000..64cdde13cd6b --- /dev/null +++ b/packages/twenty-server/test/integration/graphql/suites/auth.integration-spec.ts @@ -0,0 +1,80 @@ +import request from 'supertest'; + +const client = request(`http://localhost:${APP_PORT}`); + +const auth = { + email: 'tim@apple.dev', + password: 'Applecar2025', +}; + +describe('AuthResolve (integration)', () => { + let loginToken: string; + + it('should challenge with email and password', () => { + const queryData = { + query: ` + mutation Challenge { + challenge(email: "${auth.email}", password: "${auth.password}") { + loginToken { + token + expiresAt + } + } + } + `, + }; + + return client + .post('/graphql') + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.challenge; + + expect(data).toBeDefined(); + expect(data.loginToken).toBeDefined(); + + loginToken = data.loginToken.token; + }); + }); + + it('should verify with login token', () => { + const queryData = { + query: ` + mutation Verify { + verify(loginToken: "${loginToken}") { + tokens { + accessToken { + token + } + } + } + } + `, + }; + + return client + .post('/graphql') + .send(queryData) + .expect(200) + .expect((res) => { + expect(res.body.data).toBeDefined(); + expect(res.body.errors).toBeUndefined(); + }) + .expect((res) => { + const data = res.body.data.verify; + + expect(data).toBeDefined(); + expect(data.tokens).toBeDefined(); + + const accessToken = data.tokens.accessToken; + + expect(accessToken).toBeDefined(); + expect(accessToken.token).toBeDefined(); + }); + }); +}); From 0228e1ed2534a4e07bfcdd70319ff30eb6e91208 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Thu, 17 Oct 2024 19:07:30 +0200 Subject: [PATCH 7/7] Fix linter --- .../suites/all-resolvers.integration-spec.ts | 2 -- ...nel-event-associations.integration-spec.ts | 16 +++++++--- .../calendar-channels.integration-spec.ts | 4 ++- ...l-message-associations.integration-spec.ts | 12 +++++-- .../message-channels.integration-spec.ts | 8 +++-- ...nel-event-associations.integration-spec.ts | 28 ++++++++++++---- ...arch-calendar-channels.integration-spec.ts | 8 +++-- ...dar-event-participants.integration-spec.ts | 12 +++++-- ...l-message-associations.integration-spec.ts | 32 ++++++++++++++----- ...earch-message-channels.integration-spec.ts | 12 +++++-- ...ch-timeline-activities.integration-spec.ts | 8 +++-- 11 files changed, 105 insertions(+), 37 deletions(-) diff --git a/packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts index a81d9fceef81..3b1a46f89a44 100644 --- a/packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/all-resolvers.integration-spec.ts @@ -185,8 +185,6 @@ describe('companies resolvers (integration)', () => { const response = await makeGraphqlAPIRequest(graphqlOperation); - console.log(response); - const updatedCompanies = response.body.data.updateCompanies; expect(updatedCompanies).toHaveLength(2); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channel-event-associations.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channel-event-associations.integration-spec.ts index ee1c1378af63..023b0876915d 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channel-event-associations.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channel-event-associations.integration-spec.ts @@ -45,14 +45,22 @@ describe('calendarChannelEventAssociationsResolver (e2e)', () => { if (edges.length > 0) { const calendarChannelEventAssociations = edges[0].node; - expect(calendarChannelEventAssociations).toHaveProperty('eventExternalId'); - expect(calendarChannelEventAssociations).toHaveProperty('recurringEventExternalId'); + expect(calendarChannelEventAssociations).toHaveProperty( + 'eventExternalId', + ); + expect(calendarChannelEventAssociations).toHaveProperty( + 'recurringEventExternalId', + ); expect(calendarChannelEventAssociations).toHaveProperty('id'); expect(calendarChannelEventAssociations).toHaveProperty('createdAt'); expect(calendarChannelEventAssociations).toHaveProperty('updatedAt'); expect(calendarChannelEventAssociations).toHaveProperty('deletedAt'); - expect(calendarChannelEventAssociations).toHaveProperty('calendarChannelId'); - expect(calendarChannelEventAssociations).toHaveProperty('calendarEventId'); + expect(calendarChannelEventAssociations).toHaveProperty( + 'calendarChannelId', + ); + expect(calendarChannelEventAssociations).toHaveProperty( + 'calendarEventId', + ); } }); }); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channels.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channels.integration-spec.ts index 675eb29260d5..baab9d5003d3 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channels.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/calendar-channels.integration-spec.ts @@ -57,7 +57,9 @@ describe('calendarChannelsResolver (e2e)', () => { expect(calendarChannels).toHaveProperty('syncStatus'); expect(calendarChannels).toHaveProperty('syncStage'); expect(calendarChannels).toHaveProperty('visibility'); - expect(calendarChannels).toHaveProperty('isContactAutoCreationEnabled'); + expect(calendarChannels).toHaveProperty( + 'isContactAutoCreationEnabled', + ); expect(calendarChannels).toHaveProperty('contactAutoCreationPolicy'); expect(calendarChannels).toHaveProperty('isSyncEnabled'); expect(calendarChannels).toHaveProperty('syncCursor'); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channel-message-associations.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channel-message-associations.integration-spec.ts index 0d9980eb1f9b..db17b067bb18 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channel-message-associations.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channel-message-associations.integration-spec.ts @@ -46,14 +46,20 @@ describe('messageChannelMessageAssociationsResolver (e2e)', () => { if (edges.length > 0) { const messageChannelMessageAssociations = edges[0].node; - expect(messageChannelMessageAssociations).toHaveProperty('messageExternalId'); - expect(messageChannelMessageAssociations).toHaveProperty('messageThreadExternalId'); + expect(messageChannelMessageAssociations).toHaveProperty( + 'messageExternalId', + ); + expect(messageChannelMessageAssociations).toHaveProperty( + 'messageThreadExternalId', + ); expect(messageChannelMessageAssociations).toHaveProperty('direction'); expect(messageChannelMessageAssociations).toHaveProperty('id'); expect(messageChannelMessageAssociations).toHaveProperty('createdAt'); expect(messageChannelMessageAssociations).toHaveProperty('updatedAt'); expect(messageChannelMessageAssociations).toHaveProperty('deletedAt'); - expect(messageChannelMessageAssociations).toHaveProperty('messageChannelId'); + expect(messageChannelMessageAssociations).toHaveProperty( + 'messageChannelId', + ); expect(messageChannelMessageAssociations).toHaveProperty('messageId'); } }); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channels.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channels.integration-spec.ts index af932aa2c24f..58f9b3ea8016 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channels.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/message-channels.integration-spec.ts @@ -59,9 +59,13 @@ describe('messageChannelsResolver (e2e)', () => { expect(messageChannels).toHaveProperty('visibility'); expect(messageChannels).toHaveProperty('handle'); expect(messageChannels).toHaveProperty('type'); - expect(messageChannels).toHaveProperty('isContactAutoCreationEnabled'); + expect(messageChannels).toHaveProperty( + 'isContactAutoCreationEnabled', + ); expect(messageChannels).toHaveProperty('contactAutoCreationPolicy'); - expect(messageChannels).toHaveProperty('excludeNonProfessionalEmails'); + expect(messageChannels).toHaveProperty( + 'excludeNonProfessionalEmails', + ); expect(messageChannels).toHaveProperty('excludeGroupEmails'); expect(messageChannels).toHaveProperty('isSyncEnabled'); expect(messageChannels).toHaveProperty('syncCursor'); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channel-event-associations.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channel-event-associations.integration-spec.ts index 214e66b612a5..749ed8c12df1 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channel-event-associations.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channel-event-associations.integration-spec.ts @@ -45,14 +45,28 @@ describe('searchCalendarChannelEventAssociationsResolver (e2e)', () => { if (edges.length > 0) { const searchCalendarChannelEventAssociations = edges[0].node; - expect(searchCalendarChannelEventAssociations).toHaveProperty('eventExternalId'); - expect(searchCalendarChannelEventAssociations).toHaveProperty('recurringEventExternalId'); + expect(searchCalendarChannelEventAssociations).toHaveProperty( + 'eventExternalId', + ); + expect(searchCalendarChannelEventAssociations).toHaveProperty( + 'recurringEventExternalId', + ); expect(searchCalendarChannelEventAssociations).toHaveProperty('id'); - expect(searchCalendarChannelEventAssociations).toHaveProperty('createdAt'); - expect(searchCalendarChannelEventAssociations).toHaveProperty('updatedAt'); - expect(searchCalendarChannelEventAssociations).toHaveProperty('deletedAt'); - expect(searchCalendarChannelEventAssociations).toHaveProperty('calendarChannelId'); - expect(searchCalendarChannelEventAssociations).toHaveProperty('calendarEventId'); + expect(searchCalendarChannelEventAssociations).toHaveProperty( + 'createdAt', + ); + expect(searchCalendarChannelEventAssociations).toHaveProperty( + 'updatedAt', + ); + expect(searchCalendarChannelEventAssociations).toHaveProperty( + 'deletedAt', + ); + expect(searchCalendarChannelEventAssociations).toHaveProperty( + 'calendarChannelId', + ); + expect(searchCalendarChannelEventAssociations).toHaveProperty( + 'calendarEventId', + ); } }); }); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channels.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channels.integration-spec.ts index 4e984c76398f..28196dce8066 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channels.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-channels.integration-spec.ts @@ -57,8 +57,12 @@ describe('searchCalendarChannelsResolver (e2e)', () => { expect(searchCalendarChannels).toHaveProperty('syncStatus'); expect(searchCalendarChannels).toHaveProperty('syncStage'); expect(searchCalendarChannels).toHaveProperty('visibility'); - expect(searchCalendarChannels).toHaveProperty('isContactAutoCreationEnabled'); - expect(searchCalendarChannels).toHaveProperty('contactAutoCreationPolicy'); + expect(searchCalendarChannels).toHaveProperty( + 'isContactAutoCreationEnabled', + ); + expect(searchCalendarChannels).toHaveProperty( + 'contactAutoCreationPolicy', + ); expect(searchCalendarChannels).toHaveProperty('isSyncEnabled'); expect(searchCalendarChannels).toHaveProperty('syncCursor'); expect(searchCalendarChannels).toHaveProperty('syncedAt'); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-event-participants.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-event-participants.integration-spec.ts index de0f60f7bb77..b72c8aeaa4b5 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-event-participants.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-calendar-event-participants.integration-spec.ts @@ -51,14 +51,20 @@ describe('searchCalendarEventParticipantsResolver (e2e)', () => { expect(searchCalendarEventParticipants).toHaveProperty('handle'); expect(searchCalendarEventParticipants).toHaveProperty('displayName'); expect(searchCalendarEventParticipants).toHaveProperty('isOrganizer'); - expect(searchCalendarEventParticipants).toHaveProperty('responseStatus'); + expect(searchCalendarEventParticipants).toHaveProperty( + 'responseStatus', + ); expect(searchCalendarEventParticipants).toHaveProperty('id'); expect(searchCalendarEventParticipants).toHaveProperty('createdAt'); expect(searchCalendarEventParticipants).toHaveProperty('updatedAt'); expect(searchCalendarEventParticipants).toHaveProperty('deletedAt'); - expect(searchCalendarEventParticipants).toHaveProperty('calendarEventId'); + expect(searchCalendarEventParticipants).toHaveProperty( + 'calendarEventId', + ); expect(searchCalendarEventParticipants).toHaveProperty('personId'); - expect(searchCalendarEventParticipants).toHaveProperty('workspaceMemberId'); + expect(searchCalendarEventParticipants).toHaveProperty( + 'workspaceMemberId', + ); } }); }); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channel-message-associations.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channel-message-associations.integration-spec.ts index 9cfd06fa9ac4..514b67bb32a3 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channel-message-associations.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channel-message-associations.integration-spec.ts @@ -46,15 +46,31 @@ describe('searchMessageChannelMessageAssociationsResolver (e2e)', () => { if (edges.length > 0) { const searchMessageChannelMessageAssociations = edges[0].node; - expect(searchMessageChannelMessageAssociations).toHaveProperty('messageExternalId'); - expect(searchMessageChannelMessageAssociations).toHaveProperty('messageThreadExternalId'); - expect(searchMessageChannelMessageAssociations).toHaveProperty('direction'); + expect(searchMessageChannelMessageAssociations).toHaveProperty( + 'messageExternalId', + ); + expect(searchMessageChannelMessageAssociations).toHaveProperty( + 'messageThreadExternalId', + ); + expect(searchMessageChannelMessageAssociations).toHaveProperty( + 'direction', + ); expect(searchMessageChannelMessageAssociations).toHaveProperty('id'); - expect(searchMessageChannelMessageAssociations).toHaveProperty('createdAt'); - expect(searchMessageChannelMessageAssociations).toHaveProperty('updatedAt'); - expect(searchMessageChannelMessageAssociations).toHaveProperty('deletedAt'); - expect(searchMessageChannelMessageAssociations).toHaveProperty('messageChannelId'); - expect(searchMessageChannelMessageAssociations).toHaveProperty('messageId'); + expect(searchMessageChannelMessageAssociations).toHaveProperty( + 'createdAt', + ); + expect(searchMessageChannelMessageAssociations).toHaveProperty( + 'updatedAt', + ); + expect(searchMessageChannelMessageAssociations).toHaveProperty( + 'deletedAt', + ); + expect(searchMessageChannelMessageAssociations).toHaveProperty( + 'messageChannelId', + ); + expect(searchMessageChannelMessageAssociations).toHaveProperty( + 'messageId', + ); } }); }); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channels.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channels.integration-spec.ts index 981aae89e9cd..c39ccae7c5de 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channels.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-message-channels.integration-spec.ts @@ -59,9 +59,15 @@ describe('searchMessageChannelsResolver (e2e)', () => { expect(searchMessageChannels).toHaveProperty('visibility'); expect(searchMessageChannels).toHaveProperty('handle'); expect(searchMessageChannels).toHaveProperty('type'); - expect(searchMessageChannels).toHaveProperty('isContactAutoCreationEnabled'); - expect(searchMessageChannels).toHaveProperty('contactAutoCreationPolicy'); - expect(searchMessageChannels).toHaveProperty('excludeNonProfessionalEmails'); + expect(searchMessageChannels).toHaveProperty( + 'isContactAutoCreationEnabled', + ); + expect(searchMessageChannels).toHaveProperty( + 'contactAutoCreationPolicy', + ); + expect(searchMessageChannels).toHaveProperty( + 'excludeNonProfessionalEmails', + ); expect(searchMessageChannels).toHaveProperty('excludeGroupEmails'); expect(searchMessageChannels).toHaveProperty('isSyncEnabled'); expect(searchMessageChannels).toHaveProperty('syncCursor'); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-timeline-activities.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-timeline-activities.integration-spec.ts index d73bcb5f9694..b87ec60f1dd4 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/search-timeline-activities.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/search-timeline-activities.integration-spec.ts @@ -60,9 +60,13 @@ describe('searchTimelineActivitiesResolver (e2e)', () => { expect(searchTimelineActivities).toHaveProperty('happensAt'); expect(searchTimelineActivities).toHaveProperty('name'); expect(searchTimelineActivities).toHaveProperty('properties'); - expect(searchTimelineActivities).toHaveProperty('linkedRecordCachedName'); + expect(searchTimelineActivities).toHaveProperty( + 'linkedRecordCachedName', + ); expect(searchTimelineActivities).toHaveProperty('linkedRecordId'); - expect(searchTimelineActivities).toHaveProperty('linkedObjectMetadataId'); + expect(searchTimelineActivities).toHaveProperty( + 'linkedObjectMetadataId', + ); expect(searchTimelineActivities).toHaveProperty('id'); expect(searchTimelineActivities).toHaveProperty('createdAt'); expect(searchTimelineActivities).toHaveProperty('updatedAt');