Files
twenty/packages/twenty-server/test/integration/metadata/suites/front-component/failing-front-component-creation.integration-spec.ts
T
Weiko 9aa63f7ddc Add sync front component (#17748)
## Context
Allow twenty apps to sync front components
2026-02-08 23:00:23 +00:00

69 lines
2.0 KiB
TypeScript

import { expectOneNotInternalServerErrorSnapshot } from 'test/integration/graphql/utils/expect-one-not-internal-server-error-snapshot.util';
import { createFrontComponent } from 'test/integration/metadata/suites/front-component/utils/create-front-component.util';
import { seedBuiltFrontComponentFile } from 'test/integration/metadata/suites/front-component/utils/seed-built-front-component-file.util';
import {
type EachTestingContext,
eachTestingContextFilter,
} from 'twenty-shared/testing';
import { type CreateFrontComponentInput } from 'src/engine/metadata-modules/front-component/dtos/create-front-component.input';
type TestContext = {
input: CreateFrontComponentInput;
};
const FAILING_TEST_CASES: EachTestingContext<TestContext>[] = [
{
title: 'when name is empty',
context: {
input: {
name: '',
componentName: 'TestComponent',
sourceComponentPath: 'src/front-components/index.tsx',
builtComponentPath: 'src/front-components/index.mjs',
builtComponentChecksum: 'abc123',
},
},
},
{
title: 'when name is whitespace-only',
context: {
input: {
name: ' ',
componentName: 'TestComponent',
sourceComponentPath: 'src/front-components/index.tsx',
builtComponentPath: 'src/front-components/index.mjs',
builtComponentChecksum: 'abc123',
},
},
},
];
describe('Front component creation should fail', () => {
let cleanupBuiltFile: (() => void) | undefined;
beforeAll(async () => {
const { cleanup } = await seedBuiltFrontComponentFile({
builtComponentPath: 'src/front-components/index.mjs',
});
cleanupBuiltFile = cleanup;
});
afterAll(() => {
cleanupBuiltFile?.();
});
it.each(eachTestingContextFilter(FAILING_TEST_CASES))(
'$title',
async ({ context }) => {
const { errors } = await createFrontComponent({
expectToFail: true,
input: context.input,
});
expectOneNotInternalServerErrorSnapshot({ errors });
},
);
});