Files
twenty/packages/twenty-server/test/integration/metadata/suites/command-menu-item/failing-command-menu-item-creation.integration-spec.ts
T
neo773 323e66433e lint: migrate prettier to oxfmt (#20783)
Most changes are `implements` being unwrapped this is not a oxfmt
regression
Prettier in 3.7 (we're on 3.1) changed this behaviour prettier blog
[post](https://prettier.io/blog/2025/11/27/3.7.0#change-18094)

This unifies our linting tooling

---------

Co-authored-by: github-actions <github-actions@twenty.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2026-05-22 00:21:33 +02:00

142 lines
4.1 KiB
TypeScript

import { faker } from '@faker-js/faker';
import { expectOneNotInternalServerErrorSnapshot } from 'test/integration/graphql/utils/expect-one-not-internal-server-error-snapshot.util';
import { createCommandMenuItem } from 'test/integration/metadata/suites/command-menu-item/utils/create-command-menu-item.util';
import {
eachTestingContextFilter,
type EachTestingContext,
} from 'twenty-shared/testing';
import { type CreateCommandMenuItemInput } from 'src/engine/metadata-modules/command-menu-item/dtos/create-command-menu-item.input';
import { EngineComponentKey } from 'src/engine/metadata-modules/command-menu-item/enums/engine-component-key.enum';
type TestContext = {
input: CreateCommandMenuItemInput;
};
const failingCommandMenuItemCreationTestCases: EachTestingContext<TestContext>[] =
[
{
title: 'when creating with empty label',
context: {
input: {
workflowVersionId: faker.string.uuid(),
engineComponentKey: EngineComponentKey.TRIGGER_WORKFLOW_VERSION,
label: '',
},
},
},
{
title: 'when creating with missing label',
context: {
input: {
workflowVersionId: faker.string.uuid(),
engineComponentKey: EngineComponentKey.TRIGGER_WORKFLOW_VERSION,
} as CreateCommandMenuItemInput,
},
},
{
title: 'when creating with missing engineComponentKey',
context: {
input: {
label: 'Test Label',
} as CreateCommandMenuItemInput,
},
},
{
title: 'when creating with empty workflowVersionId',
context: {
input: {
workflowVersionId: '',
engineComponentKey: EngineComponentKey.TRIGGER_WORKFLOW_VERSION,
label: 'Test Label',
},
},
},
{
title: 'when creating with invalid workflowVersionId (not a UUID)',
context: {
input: {
workflowVersionId: 'not-a-valid-uuid',
engineComponentKey: EngineComponentKey.TRIGGER_WORKFLOW_VERSION,
label: 'Test Label',
},
},
},
{
title: 'when creating TRIGGER_WORKFLOW_VERSION without workflowVersionId',
context: {
input: {
engineComponentKey: EngineComponentKey.TRIGGER_WORKFLOW_VERSION,
label: 'Test Label',
},
},
},
{
title: 'when creating TRIGGER_WORKFLOW_VERSION with frontComponentId',
context: {
input: {
workflowVersionId: faker.string.uuid(),
frontComponentId: faker.string.uuid(),
engineComponentKey: EngineComponentKey.TRIGGER_WORKFLOW_VERSION,
label: 'Test Label',
},
},
},
{
title: 'when creating FRONT_COMPONENT_RENDERER without frontComponentId',
context: {
input: {
engineComponentKey: EngineComponentKey.FRONT_COMPONENT_RENDERER,
label: 'Test Label',
},
},
},
{
title: 'when creating FRONT_COMPONENT_RENDERER with workflowVersionId',
context: {
input: {
frontComponentId: faker.string.uuid(),
workflowVersionId: faker.string.uuid(),
engineComponentKey: EngineComponentKey.FRONT_COMPONENT_RENDERER,
label: 'Test Label',
},
},
},
{
title: 'when creating standard key with workflowVersionId',
context: {
input: {
workflowVersionId: faker.string.uuid(),
engineComponentKey: EngineComponentKey.GO_TO_PEOPLE,
label: 'Test Label',
},
},
},
{
title: 'when creating standard key with frontComponentId',
context: {
input: {
frontComponentId: faker.string.uuid(),
engineComponentKey: EngineComponentKey.GO_TO_PEOPLE,
label: 'Test Label',
},
},
},
];
describe('CommandMenuItem creation should fail', () => {
it.each(eachTestingContextFilter(failingCommandMenuItemCreationTestCases))(
'$title',
async ({ context }) => {
const { errors } = await createCommandMenuItem({
expectToFail: true,
input: context.input,
});
expectOneNotInternalServerErrorSnapshot({
errors,
});
},
);
});