## Context - Removing search* integration tests instead of fixing them because they will be replaced by global search very soon - Fixed billing + add missing seeds to make them work - Fixed integration tests not using consistently the correct "test" db - Fixed ci not running the with-db-reset configuration due to nx configuration being used twice for different level of the command - Enriched .env.test - Fixed parts where exceptions were not thrown properly and not caught by exception handler to convert to 400 when needed - Refactored feature flag service that had 2 different implementations in lab and admin panel + added tests - Fixed race condition when migrations are created at the same timestamp and doing the same type of operation, in this case object deletion could break because table could be deleted earlier than its relations - Fixed many integration tests that were not up to date since the CI has been broken for a while --------- Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
138 lines
3.9 KiB
TypeScript
138 lines
3.9 KiB
TypeScript
import { getMockCreateObjectInput } from 'test/integration/utils/object-metadata/generate-mock-create-object-metadata-input';
|
|
import { performFailingObjectMetadataCreation } from 'test/integration/utils/object-metadata/perform-failing-object-metadata-creation';
|
|
import { EachTestingContext } from 'twenty-shared';
|
|
|
|
import { ErrorCode } from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
|
|
import { CreateObjectInput } from 'src/engine/metadata-modules/object-metadata/dtos/create-object.input';
|
|
|
|
type CreateObjectInputPayload = Omit<
|
|
CreateObjectInput,
|
|
'workspaceId' | 'dataSourceId'
|
|
>;
|
|
|
|
type CreateOneObjectMetadataItemTestingContext = EachTestingContext<
|
|
Partial<CreateObjectInputPayload>
|
|
>[];
|
|
const failingNamesCreationTestsUseCase: CreateOneObjectMetadataItemTestingContext =
|
|
[
|
|
{
|
|
title: 'when nameSingular has invalid characters',
|
|
context: { nameSingular: 'μ' },
|
|
},
|
|
{
|
|
title: 'when namePlural has invalid characters',
|
|
context: { namePlural: 'μ' },
|
|
},
|
|
{
|
|
title: 'when nameSingular is a reserved keyword',
|
|
context: { nameSingular: 'user' },
|
|
},
|
|
{
|
|
title: 'when namePlural is a reserved keyword',
|
|
context: { namePlural: 'users' },
|
|
},
|
|
{
|
|
title: 'when nameSingular is not camelCased',
|
|
context: { nameSingular: 'Not_Camel_Case' },
|
|
},
|
|
{
|
|
title: 'when namePlural is not camelCased',
|
|
context: { namePlural: 'Not_Camel_Case' },
|
|
},
|
|
{
|
|
title: 'when namePlural is an empty string',
|
|
context: { namePlural: '' },
|
|
},
|
|
{
|
|
title: 'when nameSingular is an empty string',
|
|
context: { nameSingular: '' },
|
|
},
|
|
{
|
|
title: 'when nameSingular contains only whitespaces',
|
|
context: { nameSingular: ' ' },
|
|
},
|
|
{
|
|
title: 'when nameSingular contains only one char and whitespaces',
|
|
context: { nameSingular: ' a a ' },
|
|
},
|
|
{
|
|
title: 'when name exceeds maximum length',
|
|
context: { nameSingular: 'a'.repeat(64) },
|
|
},
|
|
{
|
|
title: 'when names are identical',
|
|
context: {
|
|
nameSingular: 'fooBar',
|
|
namePlural: 'fooBar',
|
|
},
|
|
},
|
|
{
|
|
title: 'when names with whitespaces result to be identical',
|
|
context: {
|
|
nameSingular: ' fooBar ',
|
|
namePlural: 'fooBar',
|
|
},
|
|
},
|
|
];
|
|
|
|
const failingLabelsCreationTestsUseCase: CreateOneObjectMetadataItemTestingContext =
|
|
[
|
|
{
|
|
title: 'when labelSingular is empty',
|
|
context: { labelSingular: '' },
|
|
},
|
|
{
|
|
title: 'when labelPlural is empty',
|
|
context: { labelPlural: '' },
|
|
},
|
|
{
|
|
title: 'when labelSingular exceeds maximum length',
|
|
context: { labelSingular: 'A'.repeat(64) },
|
|
},
|
|
{
|
|
title: 'when labelPlural exceeds maximum length',
|
|
context: { labelPlural: 'A'.repeat(64) },
|
|
},
|
|
{
|
|
title: 'when labelSingular contains only whitespace',
|
|
context: { labelSingular: ' ' },
|
|
},
|
|
{
|
|
title: 'when labelPlural contains only whitespace',
|
|
context: { labelPlural: ' ' },
|
|
},
|
|
{
|
|
title: 'when labels are identical',
|
|
context: {
|
|
labelPlural: 'fooBar',
|
|
labelSingular: 'fooBar',
|
|
},
|
|
},
|
|
{
|
|
title: 'when labels with whitespaces result to be identical',
|
|
context: {
|
|
labelPlural: ' fooBar ',
|
|
labelSingular: 'fooBar',
|
|
},
|
|
},
|
|
];
|
|
|
|
const allTestsUseCases = [
|
|
...failingNamesCreationTestsUseCase,
|
|
...failingLabelsCreationTestsUseCase,
|
|
];
|
|
|
|
describe('Object metadata creation should fail', () => {
|
|
it.each(allTestsUseCases)('$title', async ({ context }) => {
|
|
const errors = await performFailingObjectMetadataCreation(
|
|
getMockCreateObjectInput(context),
|
|
);
|
|
|
|
expect(errors.length).toBe(1);
|
|
const firstError = errors[0];
|
|
|
|
expect(firstError.extensions.code).toBe(ErrorCode.BAD_USER_INPUT);
|
|
expect(firstError.message).toMatchSnapshot();
|
|
});
|
|
});
|