Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 3s
416 lines
13 KiB
TypeScript
416 lines
13 KiB
TypeScript
import { PERSON_GQL_FIELDS } from 'test/integration/constants/person-gql-fields.constants';
|
|
import {
|
|
TEST_PERSON_1_ID,
|
|
TEST_PERSON_2_ID,
|
|
TEST_PERSON_3_ID,
|
|
} from 'test/integration/constants/test-person-ids.constants';
|
|
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 { updateManyOperationFactory } from 'test/integration/graphql/utils/update-many-operation-factory.util';
|
|
import { updateOneOperationFactory } from 'test/integration/graphql/utils/update-one-operation-factory.util';
|
|
import { deleteAllRecords } from 'test/integration/utils/delete-all-records';
|
|
import { generateRecordName } from 'test/integration/utils/generate-record-name';
|
|
|
|
describe('people resolvers (integration)', () => {
|
|
beforeAll(async () => {
|
|
await deleteAllRecords('person');
|
|
});
|
|
|
|
it('1. should create and return people', async () => {
|
|
const personJobTitle1 = generateRecordName(TEST_PERSON_1_ID);
|
|
const personJobTitle2 = generateRecordName(TEST_PERSON_2_ID);
|
|
const graphqlOperation = createManyOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
objectMetadataPluralName: 'people',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
data: [
|
|
{
|
|
id: TEST_PERSON_1_ID,
|
|
jobTitle: personJobTitle1,
|
|
},
|
|
{
|
|
id: TEST_PERSON_2_ID,
|
|
jobTitle: personJobTitle2,
|
|
},
|
|
],
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(response.body.data.createPeople).toHaveLength(2);
|
|
|
|
// @ts-expect-error legacy noImplicitAny
|
|
response.body.data.createPeople.forEach((person) => {
|
|
expect(person).toHaveProperty('jobTitle');
|
|
expect([personJobTitle1, personJobTitle2]).toContain(person.jobTitle);
|
|
|
|
expect(person).toHaveProperty('id');
|
|
expect(person).toHaveProperty('jobTitle');
|
|
expect(person).toHaveProperty('avatarUrl');
|
|
expect(person).toHaveProperty('avatarFile');
|
|
expect(person).toHaveProperty('intro');
|
|
expect(person).toHaveProperty('searchVector');
|
|
expect(person).toHaveProperty('name');
|
|
expect(person).toHaveProperty('createdAt');
|
|
expect(person).toHaveProperty('deletedAt');
|
|
});
|
|
});
|
|
|
|
it('1b. should create and return one person', async () => {
|
|
const personJobTitle3 = generateRecordName(TEST_PERSON_3_ID);
|
|
|
|
const graphqlOperation = createOneOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
data: {
|
|
id: TEST_PERSON_3_ID,
|
|
jobTitle: personJobTitle3,
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
const createdPerson = response.body.data.createPerson;
|
|
|
|
expect(createdPerson).toHaveProperty('jobTitle');
|
|
expect(createdPerson.jobTitle).toEqual(personJobTitle3);
|
|
|
|
expect(createdPerson).toHaveProperty('id');
|
|
expect(createdPerson).toHaveProperty('jobTitle');
|
|
expect(createdPerson).toHaveProperty('avatarUrl');
|
|
expect(createdPerson).toHaveProperty('avatarFile');
|
|
expect(createdPerson).toHaveProperty('intro');
|
|
expect(createdPerson).toHaveProperty('searchVector');
|
|
expect(createdPerson).toHaveProperty('name');
|
|
expect(createdPerson).toHaveProperty('createdAt');
|
|
expect(createdPerson).toHaveProperty('deletedAt');
|
|
});
|
|
|
|
it('2. should find many people', async () => {
|
|
const graphqlOperation = findManyOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
objectMetadataPluralName: 'people',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
const data = response.body.data.people;
|
|
|
|
expect(data).toBeDefined();
|
|
expect(Array.isArray(data.edges)).toBe(true);
|
|
|
|
const edges = data.edges;
|
|
|
|
if (edges.length > 0) {
|
|
const person = edges[0].node;
|
|
|
|
expect(person).toHaveProperty('id');
|
|
expect(person).toHaveProperty('jobTitle');
|
|
expect(person).toHaveProperty('avatarUrl');
|
|
expect(person).toHaveProperty('avatarFile');
|
|
expect(person).toHaveProperty('intro');
|
|
expect(person).toHaveProperty('searchVector');
|
|
expect(person).toHaveProperty('name');
|
|
expect(person).toHaveProperty('createdAt');
|
|
expect(person).toHaveProperty('deletedAt');
|
|
}
|
|
});
|
|
|
|
it('2b. should find one person', async () => {
|
|
const graphqlOperation = findOneOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
filter: {
|
|
id: {
|
|
eq: TEST_PERSON_3_ID,
|
|
},
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
const person = response.body.data.person;
|
|
|
|
expect(person).toHaveProperty('jobTitle');
|
|
|
|
expect(person).toHaveProperty('id');
|
|
expect(person).toHaveProperty('jobTitle');
|
|
expect(person).toHaveProperty('avatarUrl');
|
|
expect(person).toHaveProperty('avatarFile');
|
|
expect(person).toHaveProperty('intro');
|
|
expect(person).toHaveProperty('searchVector');
|
|
expect(person).toHaveProperty('name');
|
|
expect(person).toHaveProperty('createdAt');
|
|
expect(person).toHaveProperty('deletedAt');
|
|
});
|
|
|
|
it('3. should update many people', async () => {
|
|
const graphqlOperation = updateManyOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
objectMetadataPluralName: 'people',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
data: {
|
|
jobTitle: 'Updated City',
|
|
},
|
|
filter: {
|
|
id: {
|
|
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
|
|
},
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
const updatedPeople = response.body.data.updatePeople;
|
|
|
|
expect(updatedPeople).toHaveLength(2);
|
|
|
|
// @ts-expect-error legacy noImplicitAny
|
|
updatedPeople.forEach((person) => {
|
|
expect(person.jobTitle).toEqual('Updated City');
|
|
});
|
|
});
|
|
|
|
it('3b. should update one person', async () => {
|
|
const graphqlOperation = updateOneOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
data: {
|
|
jobTitle: 'New City',
|
|
},
|
|
recordId: TEST_PERSON_3_ID,
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
const updatedPerson = response.body.data.updatePerson;
|
|
|
|
expect(updatedPerson.jobTitle).toEqual('New City');
|
|
});
|
|
|
|
it('4. should find many people with updated city', async () => {
|
|
const graphqlOperation = findManyOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
objectMetadataPluralName: 'people',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
filter: {
|
|
jobTitle: {
|
|
eq: 'Updated City',
|
|
},
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(response.body.data.people.edges).toHaveLength(2);
|
|
});
|
|
|
|
it('4b. should find one person with updated city', async () => {
|
|
const graphqlOperation = findOneOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
filter: {
|
|
jobTitle: {
|
|
eq: 'New City',
|
|
},
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(response.body.data.person.jobTitle).toEqual('New City');
|
|
});
|
|
|
|
it('5. should delete many people', async () => {
|
|
const graphqlOperation = deleteManyOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
objectMetadataPluralName: 'people',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
filter: {
|
|
id: {
|
|
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
|
|
},
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
const deletePeople = response.body.data.deletePeople;
|
|
|
|
expect(deletePeople).toHaveLength(2);
|
|
|
|
// @ts-expect-error legacy noImplicitAny
|
|
deletePeople.forEach((person) => {
|
|
expect(person.deletedAt).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
it('5b. should delete one person', async () => {
|
|
const graphqlOperation = deleteOneOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
recordId: TEST_PERSON_3_ID,
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(response.body.data.deletePerson.deletedAt).toBeTruthy();
|
|
});
|
|
|
|
it('6. should not find many people anymore', async () => {
|
|
const graphqlOperation = findManyOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
objectMetadataPluralName: 'people',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
filter: {
|
|
id: {
|
|
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
|
|
},
|
|
},
|
|
});
|
|
|
|
const findPeopleResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(findPeopleResponse.body.data.people.edges).toHaveLength(0);
|
|
});
|
|
|
|
it('6b. should not find one person anymore', async () => {
|
|
const graphqlOperation = findOneOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
filter: {
|
|
id: {
|
|
eq: TEST_PERSON_3_ID,
|
|
},
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(response.body.data.person).toBeNull();
|
|
});
|
|
|
|
it('7. should find many deleted people with deletedAt filter', async () => {
|
|
const graphqlOperation = findManyOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
objectMetadataPluralName: 'people',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
filter: {
|
|
id: {
|
|
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
|
|
},
|
|
not: {
|
|
deletedAt: {
|
|
is: 'NULL',
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(response.body.data.people.edges).toHaveLength(2);
|
|
});
|
|
|
|
it('7b. should find one deleted person with deletedAt filter', async () => {
|
|
const graphqlOperation = findOneOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
filter: {
|
|
id: {
|
|
eq: TEST_PERSON_3_ID,
|
|
},
|
|
not: {
|
|
deletedAt: {
|
|
is: 'NULL',
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(response.body.data.person.id).toEqual(TEST_PERSON_3_ID);
|
|
});
|
|
|
|
it('8. should destroy many people', async () => {
|
|
const graphqlOperation = destroyManyOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
objectMetadataPluralName: 'people',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
filter: {
|
|
id: {
|
|
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
|
|
},
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(response.body.data.destroyPeople).toHaveLength(2);
|
|
});
|
|
|
|
it('8b. should destroy one person', async () => {
|
|
const graphqlOperation = destroyOneOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
recordId: TEST_PERSON_3_ID,
|
|
});
|
|
|
|
const destroyPeopleResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(destroyPeopleResponse.body.data.destroyPerson).toBeTruthy();
|
|
});
|
|
|
|
it('9. should not find many people anymore', async () => {
|
|
const graphqlOperation = findManyOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
objectMetadataPluralName: 'people',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
filter: {
|
|
id: {
|
|
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
|
|
},
|
|
not: {
|
|
deletedAt: {
|
|
is: 'NULL',
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(response.body.data.people.edges).toHaveLength(0);
|
|
});
|
|
|
|
it('9b. should not find one person anymore', async () => {
|
|
const graphqlOperation = findOneOperationFactory({
|
|
objectMetadataSingularName: 'person',
|
|
gqlFields: PERSON_GQL_FIELDS,
|
|
filter: {
|
|
id: {
|
|
eq: TEST_PERSON_3_ID,
|
|
},
|
|
not: {
|
|
deletedAt: {
|
|
is: 'NULL',
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
|
|
expect(response.body.data.person).toBeNull();
|
|
});
|
|
});
|