Files
twenty/packages/twenty-server/test/integration/graphql/suites/view/view-field/failing-delete-view-field-v2.integration-spec.ts
T
Paul Rastoin 59fbe35a8c Move view in metadata-modules/ and create atomic folder + module for each view entity (#14990)
# Introduction
Preparing view-filter and view-group introduction in v2 core engine
Moving view from `core-modules` to `metadata-modules`

## What happened

### Created dedicated modules for each view entity:
- ViewFieldModule
- ViewFilterModule
- ViewFilterGroupModule
- ViewGroupModule
- ViewSortModule

### Each module is now completely independent with its own:
- Controller
- Resolver
- Service
- Entity

### Created dedicated abstraction metadata module folder for:
- flat-view-field
- flat-view

### Dependencies 
- Eleminated circular dep on ViewModule to all others ones
- Granular import not importing the whole viewModule anymore everywhere


close https://github.com/twentyhq/core-team-issues/issues/1703
2025-10-09 15:18:15 +02:00

61 lines
1.8 KiB
TypeScript

import { TEST_NOT_EXISTING_VIEW_FIELD_ID } from 'test/integration/constants/test-view-ids.constants';
import {
cleanupViewFieldTestV2,
setupViewFieldTestV2,
type ViewFieldTestSetup,
} from 'test/integration/graphql/suites/view/utils/setup-view-field-test-v2.util';
import { deleteOneCoreViewField } from 'test/integration/metadata/suites/view-field/utils/delete-one-core-view-field.util';
import { extractRecordIdsAndDatesAsExpectAny } from 'test/utils/extract-record-ids-and-dates-as-expect-any';
import {
eachTestingContextFilter,
type EachTestingContext,
} from 'twenty-shared/testing';
import { type DeleteViewFieldInput } from 'src/engine/metadata-modules/view-field/dtos/inputs/delete-view-field.input';
describe('View Field Resolver - Failing Delete Operation - v2', () => {
let testSetup: ViewFieldTestSetup;
beforeAll(async () => {
testSetup = await setupViewFieldTestV2();
});
afterAll(async () => {
await cleanupViewFieldTestV2(testSetup.testObjectMetadataId);
});
type DeleteViewFieldTestCase = {
input: DeleteViewFieldInput;
};
const deleteViewFieldTestCases: EachTestingContext<DeleteViewFieldTestCase>[] =
[
{
title: 'non-existent view field',
context: {
input: {
id: TEST_NOT_EXISTING_VIEW_FIELD_ID,
},
},
},
];
it.each(eachTestingContextFilter(deleteViewFieldTestCases))(
'should fail to delete view field when $title',
async ({ context }) => {
const response = await deleteOneCoreViewField({
input: context.input,
expectToFail: true,
});
expect(response.errors).toBeDefined();
expect(response.errors.length).toBe(1);
const [firstError] = response.errors;
expect(firstError).toMatchSnapshot(
extractRecordIdsAndDatesAsExpectAny(firstError),
);
},
);
});