[QRQC_2] No implicitAny in twenty-server (#12075)
# Introduction Following https://github.com/twentyhq/twenty/pull/12068 Related with https://github.com/twentyhq/core-team-issues/issues/975 We're enabling `noImplicitAny` handled few use case manually, added a `ts-expect-error` to the others, we should plan to handle them in the future
This commit is contained in:
@ -46,6 +46,7 @@ describe('people resolvers (integration)', () => {
|
||||
|
||||
expect(response.body.data.createPeople).toHaveLength(2);
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
response.body.data.createPeople.forEach((person) => {
|
||||
expect(person).toHaveProperty('city');
|
||||
expect([personCity1, personCity2]).toContain(person.city);
|
||||
@ -168,6 +169,7 @@ describe('people resolvers (integration)', () => {
|
||||
|
||||
expect(updatedPeople).toHaveLength(2);
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
updatedPeople.forEach((person) => {
|
||||
expect(person.city).toEqual('Updated City');
|
||||
});
|
||||
@ -241,6 +243,7 @@ describe('people resolvers (integration)', () => {
|
||||
|
||||
expect(deletePeople).toHaveLength(2);
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
deletePeople.forEach((person) => {
|
||||
expect(person.deletedAt).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -56,6 +56,7 @@ describe('SearchResolver', () => {
|
||||
});
|
||||
|
||||
const listingObjectMetadata = objectsMetadata.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(object) => object.nameSingular === LISTING_NAME_SINGULAR,
|
||||
);
|
||||
|
||||
|
||||
@ -63,10 +63,12 @@ describe('roles permissions', () => {
|
||||
.send(query);
|
||||
|
||||
adminRoleId = resp.body.data.getRoles.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(role) => role.label === 'Admin',
|
||||
).id;
|
||||
|
||||
guestRoleId = resp.body.data.getRoles.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(role) => role.label === 'Guest',
|
||||
).id;
|
||||
});
|
||||
@ -231,10 +233,12 @@ describe('roles permissions', () => {
|
||||
.send(getRolesQuery);
|
||||
|
||||
const memberRoleId = resp.body.data.getRoles.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(role) => role.label === 'Member',
|
||||
).id;
|
||||
|
||||
const guestRoleId = resp.body.data.getRoles.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(role) => role.label === 'Guest',
|
||||
).id;
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ import { PermissionsExceptionMessage } from 'src/engine/metadata-modules/permiss
|
||||
const client = request(`http://localhost:${APP_PORT}`);
|
||||
|
||||
describe('Security permissions', () => {
|
||||
let originalWorkspaceState;
|
||||
let originalWorkspaceState: Record<string, unknown>;
|
||||
|
||||
beforeAll(async () => {
|
||||
// Store original workspace state
|
||||
|
||||
@ -11,7 +11,7 @@ import { PermissionsExceptionMessage } from 'src/engine/metadata-modules/permiss
|
||||
const client = request(`http://localhost:${APP_PORT}`);
|
||||
|
||||
describe('workspace permissions', () => {
|
||||
let originalWorkspaceState;
|
||||
let originalWorkspaceState: Record<string, unknown>;
|
||||
|
||||
beforeAll(async () => {
|
||||
// Store original workspace state
|
||||
|
||||
@ -25,5 +25,6 @@ export const findManyFieldsMetadata = async ({
|
||||
});
|
||||
}
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
return response.body.data.fields.edges.map((edge) => edge.node);
|
||||
};
|
||||
|
||||
@ -63,10 +63,13 @@ describe('Custom object renaming', () => {
|
||||
},
|
||||
});
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const fillStandardObjectRelationsMapObjectMetadataId = (standardObjects) => {
|
||||
STANDARD_OBJECT_RELATIONS.forEach((relation) => {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
standardObjectRelationsMap[relation].objectMetadataId =
|
||||
standardObjects.body.data.objects.edges.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(object) => object.node.nameSingular === relation,
|
||||
).node.id;
|
||||
});
|
||||
@ -108,22 +111,27 @@ describe('Custom object renaming', () => {
|
||||
|
||||
const relationFieldsMetadataForListing = fields.body.data.fields.edges
|
||||
.filter(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(field) =>
|
||||
field.node.name === `${LISTING_NAME_SINGULAR}` &&
|
||||
field.node.type === FieldMetadataType.RELATION,
|
||||
)
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
.map((field) => field.node);
|
||||
|
||||
STANDARD_OBJECT_RELATIONS.forEach((relation) => {
|
||||
// relation field
|
||||
const relationFieldMetadataId = relationFieldsMetadataForListing.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(field) =>
|
||||
field.object.id ===
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
standardObjectRelationsMap[relation].objectMetadataId,
|
||||
).id;
|
||||
|
||||
expect(relationFieldMetadataId).not.toBeUndefined();
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
standardObjectRelationsMap[relation].relationFieldMetadataId =
|
||||
relationFieldMetadataId;
|
||||
});
|
||||
@ -138,6 +146,7 @@ describe('Custom object renaming', () => {
|
||||
standardObjectsGraphqlOperation,
|
||||
);
|
||||
const personObjectId = standardObjects.body.data.objects.edges.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(object) => object.node.nameSingular === 'person',
|
||||
).node.id;
|
||||
|
||||
@ -208,6 +217,7 @@ describe('Custom object renaming', () => {
|
||||
const fieldsResponse = await makeMetadataAPIRequest(fieldsGraphqlOperation);
|
||||
|
||||
const fieldsMetadata = fieldsResponse.body.data.fields.edges.map(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(field) => field.node,
|
||||
);
|
||||
|
||||
@ -215,9 +225,11 @@ describe('Custom object renaming', () => {
|
||||
STANDARD_OBJECT_RELATIONS.forEach((relation) => {
|
||||
// relation field
|
||||
const relationFieldMetadataId =
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
standardObjectRelationsMap[relation].relationFieldMetadataId;
|
||||
|
||||
const updatedRelationFieldMetadataId = fieldsMetadata.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(field) => field.id === relationFieldMetadataId,
|
||||
);
|
||||
|
||||
@ -227,6 +239,7 @@ describe('Custom object renaming', () => {
|
||||
|
||||
// custom relation are unchanged
|
||||
const updatedRelationFieldMetadata = fieldsMetadata.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(field) => field.id === relationFieldMetadataOnPersonId,
|
||||
);
|
||||
|
||||
|
||||
@ -25,5 +25,6 @@ export const findManyObjectMetadata = async ({
|
||||
});
|
||||
}
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
return response.body.data.objects.edges.map((edge) => edge.node);
|
||||
};
|
||||
|
||||
@ -128,9 +128,11 @@ describe('Core REST API Create Many endpoint', () => {
|
||||
expect(createdPerson2.company.people).toBeDefined();
|
||||
|
||||
const depth2Person1 = createdPerson1.company.people.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(p) => p.id === createdPerson1.id,
|
||||
);
|
||||
const depth2Person2 = createdPerson2.company.people.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(p) => p.id === createdPerson2.id,
|
||||
);
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { TEST_COMPANY_1_ID } from 'test/integration/constants/test-company-ids.constants';
|
||||
import { TEST_PERSON_1_ID } from 'test/integration/constants/test-person-ids.constants';
|
||||
import { TEST_PRIMARY_LINK_URL } from 'test/integration/constants/test-primary-link-url.constant';
|
||||
import { makeRestAPIRequest } from 'test/integration/rest/utils/make-rest-api-request.util';
|
||||
import { deleteAllRecords } from 'test/integration/utils/delete-all-records';
|
||||
import { generateRecordName } from 'test/integration/utils/generate-record-name';
|
||||
import { TEST_COMPANY_1_ID } from 'test/integration/constants/test-company-ids.constants';
|
||||
import { TEST_PRIMARY_LINK_URL } from 'test/integration/constants/test-primary-link-url.constant';
|
||||
|
||||
describe('Core REST API Create One endpoint', () => {
|
||||
beforeEach(async () => {
|
||||
@ -108,6 +108,7 @@ describe('Core REST API Create One endpoint', () => {
|
||||
|
||||
expect(createdPerson.company.people).toBeDefined();
|
||||
const depth2Person = createdPerson.company.people.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(p) => p.id === createdPerson.id,
|
||||
);
|
||||
|
||||
|
||||
@ -268,9 +268,11 @@ describe('Core REST API Find Duplicates endpoint', () => {
|
||||
expect(personDuplicated2.company.people).toBeDefined();
|
||||
|
||||
const depth2Person1 = personDuplicated1.company.people.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(p) => p.id === personDuplicated1.id,
|
||||
);
|
||||
const depth2Person2 = personDuplicated2.company.people.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(p) => p.id === personDuplicated2.id,
|
||||
);
|
||||
|
||||
|
||||
@ -70,6 +70,7 @@ describe('Core REST API Find Many endpoint', () => {
|
||||
|
||||
// Check that our test people are included in the results
|
||||
for (const personId of testPersonIds) {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const person = people.find((p) => p.id === personId);
|
||||
|
||||
expect(person).toBeDefined();
|
||||
@ -308,6 +309,7 @@ describe('Core REST API Find Many endpoint', () => {
|
||||
|
||||
expect(person.company.people).toBeDefined();
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const depth2Person = person.company.people.find((p) => p.id === person.id);
|
||||
|
||||
expect(depth2Person).toBeDefined();
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { TEST_COMPANY_1_ID } from 'test/integration/constants/test-company-ids.constants';
|
||||
import {
|
||||
NOT_EXISTING_TEST_PERSON_ID,
|
||||
TEST_PERSON_1_ID,
|
||||
} from 'test/integration/constants/test-person-ids.constants';
|
||||
import { TEST_COMPANY_1_ID } from 'test/integration/constants/test-company-ids.constants';
|
||||
import { makeRestAPIRequest } from 'test/integration/rest/utils/make-rest-api-request.util';
|
||||
import { generateRecordName } from 'test/integration/utils/generate-record-name';
|
||||
import { deleteAllRecords } from 'test/integration/utils/delete-all-records';
|
||||
import { TEST_PRIMARY_LINK_URL } from 'test/integration/constants/test-primary-link-url.constant';
|
||||
import { makeRestAPIRequest } from 'test/integration/rest/utils/make-rest-api-request.util';
|
||||
import { deleteAllRecords } from 'test/integration/utils/delete-all-records';
|
||||
import { generateRecordName } from 'test/integration/utils/generate-record-name';
|
||||
|
||||
describe('Core REST API Find One endpoint', () => {
|
||||
let personCity: string;
|
||||
@ -124,6 +124,7 @@ describe('Core REST API Find One endpoint', () => {
|
||||
expect(person.company.people).toBeDefined();
|
||||
|
||||
const depth2Person = person.company.people.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(p) => p.id === person.id,
|
||||
);
|
||||
|
||||
|
||||
@ -115,6 +115,7 @@ describe('Core REST API Update One endpoint', () => {
|
||||
expect(updatedPerson.company.people).toBeDefined();
|
||||
|
||||
const depth2Person = updatedPerson.company.people.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(p) => p.id === updatedPerson.id,
|
||||
);
|
||||
|
||||
|
||||
@ -342,9 +342,11 @@ describe('TwentyConfig Integration', () => {
|
||||
);
|
||||
|
||||
const allVariables = result.data.getConfigVariablesGrouped.groups.flatMap(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(group) => group.variables,
|
||||
);
|
||||
const testVariable = allVariables.find(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(variable) => variable.name === testKey,
|
||||
);
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ const TEST_SCHEMA_NAME = 'workspace_1wgvd1injqtife6y4rvfbu3h5';
|
||||
|
||||
export const deleteAllRecords = async (objectNameSingular: string) => {
|
||||
try {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
await global.testDataSource.query(
|
||||
`DELETE from "${TEST_SCHEMA_NAME}"."${objectNameSingular}"`,
|
||||
);
|
||||
|
||||
@ -5,6 +5,7 @@ import { rawDataSource } from 'src/database/typeorm/raw/raw.datasource';
|
||||
|
||||
import { createApp } from './create-app';
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
export default async (_, projectConfig: JestConfigWithTsJest) => {
|
||||
const app = await createApp({});
|
||||
|
||||
@ -16,6 +17,8 @@ export default async (_, projectConfig: JestConfigWithTsJest) => {
|
||||
|
||||
await app.listen(projectConfig.globals.APP_PORT);
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
global.app = app;
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
global.testDataSource = rawDataSource;
|
||||
};
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import 'tsconfig-paths/register';
|
||||
|
||||
export default async () => {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
global.testDataSource.destroy();
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
global.app.close();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user