Revert "Revert "[4/n]: migrate the RESTAPI GET /rest/* to use TwentyORM direc…" (#11349)

This commit is contained in:
martmull
2025-05-12 10:32:04 +02:00
committed by GitHub
parent 1f4d4c5265
commit 650f8f5963
50 changed files with 1532 additions and 698 deletions

View File

@ -1,8 +1,8 @@
import {
PERSON_1_ID,
PERSON_2_ID,
PERSON_3_ID,
} from 'test/integration/constants/mock-person-ids.constants';
TEST_PERSON_1_ID,
TEST_PERSON_2_ID,
TEST_PERSON_3_ID,
} from 'test/integration/constants/test-person-ids.constants';
import { PERSON_GQL_FIELDS } from 'test/integration/constants/person-gql-fields.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';
@ -16,22 +16,27 @@ import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graph
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';
import { deleteAllRecords } from 'test/integration/utils/delete-all-records';
describe('people resolvers (integration)', () => {
beforeAll(async () => {
await deleteAllRecords('person');
});
it('1. should create and return people', async () => {
const personCity1 = generateRecordName(PERSON_1_ID);
const personCity2 = generateRecordName(PERSON_2_ID);
const personCity1 = generateRecordName(TEST_PERSON_1_ID);
const personCity2 = generateRecordName(TEST_PERSON_2_ID);
const graphqlOperation = createManyOperationFactory({
objectMetadataSingularName: 'person',
objectMetadataPluralName: 'people',
gqlFields: PERSON_GQL_FIELDS,
data: [
{
id: PERSON_1_ID,
id: TEST_PERSON_1_ID,
city: personCity1,
},
{
id: PERSON_2_ID,
id: TEST_PERSON_2_ID,
city: personCity2,
},
],
@ -57,13 +62,13 @@ describe('people resolvers (integration)', () => {
});
it('1b. should create and return one person', async () => {
const personCity3 = generateRecordName(PERSON_3_ID);
const personCity3 = generateRecordName(TEST_PERSON_3_ID);
const graphqlOperation = createOneOperationFactory({
objectMetadataSingularName: 'person',
gqlFields: PERSON_GQL_FIELDS,
data: {
id: PERSON_3_ID,
id: TEST_PERSON_3_ID,
city: personCity3,
},
});
@ -121,7 +126,7 @@ describe('people resolvers (integration)', () => {
gqlFields: PERSON_GQL_FIELDS,
filter: {
id: {
eq: PERSON_3_ID,
eq: TEST_PERSON_3_ID,
},
},
});
@ -152,7 +157,7 @@ describe('people resolvers (integration)', () => {
},
filter: {
id: {
in: [PERSON_1_ID, PERSON_2_ID],
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
},
},
});
@ -175,7 +180,7 @@ describe('people resolvers (integration)', () => {
data: {
city: 'New City',
},
recordId: PERSON_3_ID,
recordId: TEST_PERSON_3_ID,
});
const response = await makeGraphqlAPIRequest(graphqlOperation);
@ -225,7 +230,7 @@ describe('people resolvers (integration)', () => {
gqlFields: PERSON_GQL_FIELDS,
filter: {
id: {
in: [PERSON_1_ID, PERSON_2_ID],
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
},
},
});
@ -245,7 +250,7 @@ describe('people resolvers (integration)', () => {
const graphqlOperation = deleteOneOperationFactory({
objectMetadataSingularName: 'person',
gqlFields: PERSON_GQL_FIELDS,
recordId: PERSON_3_ID,
recordId: TEST_PERSON_3_ID,
});
const response = await makeGraphqlAPIRequest(graphqlOperation);
@ -260,7 +265,7 @@ describe('people resolvers (integration)', () => {
gqlFields: PERSON_GQL_FIELDS,
filter: {
id: {
in: [PERSON_1_ID, PERSON_2_ID],
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
},
},
});
@ -276,7 +281,7 @@ describe('people resolvers (integration)', () => {
gqlFields: PERSON_GQL_FIELDS,
filter: {
id: {
eq: PERSON_3_ID,
eq: TEST_PERSON_3_ID,
},
},
});
@ -293,7 +298,7 @@ describe('people resolvers (integration)', () => {
gqlFields: PERSON_GQL_FIELDS,
filter: {
id: {
in: [PERSON_1_ID, PERSON_2_ID],
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
},
not: {
deletedAt: {
@ -314,7 +319,7 @@ describe('people resolvers (integration)', () => {
gqlFields: PERSON_GQL_FIELDS,
filter: {
id: {
eq: PERSON_3_ID,
eq: TEST_PERSON_3_ID,
},
not: {
deletedAt: {
@ -326,7 +331,7 @@ describe('people resolvers (integration)', () => {
const response = await makeGraphqlAPIRequest(graphqlOperation);
expect(response.body.data.person.id).toEqual(PERSON_3_ID);
expect(response.body.data.person.id).toEqual(TEST_PERSON_3_ID);
});
it('8. should destroy many people', async () => {
@ -336,7 +341,7 @@ describe('people resolvers (integration)', () => {
gqlFields: PERSON_GQL_FIELDS,
filter: {
id: {
in: [PERSON_1_ID, PERSON_2_ID],
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
},
},
});
@ -350,7 +355,7 @@ describe('people resolvers (integration)', () => {
const graphqlOperation = destroyOneOperationFactory({
objectMetadataSingularName: 'person',
gqlFields: PERSON_GQL_FIELDS,
recordId: PERSON_3_ID,
recordId: TEST_PERSON_3_ID,
});
const destroyPeopleResponse = await makeGraphqlAPIRequest(graphqlOperation);
@ -365,7 +370,7 @@ describe('people resolvers (integration)', () => {
gqlFields: PERSON_GQL_FIELDS,
filter: {
id: {
in: [PERSON_1_ID, PERSON_2_ID],
in: [TEST_PERSON_1_ID, TEST_PERSON_2_ID],
},
not: {
deletedAt: {
@ -386,7 +391,7 @@ describe('people resolvers (integration)', () => {
gqlFields: PERSON_GQL_FIELDS,
filter: {
id: {
eq: PERSON_3_ID,
eq: TEST_PERSON_3_ID,
},
not: {
deletedAt: {

View File

@ -8,7 +8,7 @@ const ORIGIN = new URL(SERVER_URL);
ORIGIN.hostname =
process.env.IS_MULTIWORKSPACE_ENABLED === 'true'
? `acme.${ORIGIN.hostname}`
? `apple.${ORIGIN.hostname}`
: ORIGIN.hostname;
const auth = {

View File

@ -14,8 +14,6 @@ import { ErrorCode } from 'src/engine/core-modules/graphql/utils/graphql-errors.
import { PermissionsExceptionMessage } from 'src/engine/metadata-modules/permissions/permissions.exception';
describe('datamodel permissions', () => {
beforeAll(async () => {});
describe('fieldMetadata', () => {
let listingObjectId = '';
let testFieldId = '';