Files
twenty/packages/twenty-server/test/integration/metadata/suites/command-menu-item/failing-command-menu-item-update.integration-spec.ts
T
Raphaël Bosi 49afe5dbc4 Refactor: Unify command menu item execution (#18908)
- Makes engineComponentKey non-nullable on CommandMenuItem. Adds two new
engine component keys: TRIGGER_WORKFLOW_VERSION and
FRONT_COMPONENT_RENDERER to cover the former standalone cases.
- Unifies the previously separated engine, front component and workflow
runners into a single `CommandRunner` component with a unified
`useMountCommand` hook that handles all command types.
2026-03-24 15:59:52 +00:00

146 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 { updateFeatureFlag } from 'test/integration/metadata/suites/utils/update-feature-flag.util';
import { createCommandMenuItem } from 'test/integration/metadata/suites/command-menu-item/utils/create-command-menu-item.util';
import { deleteCommandMenuItem } from 'test/integration/metadata/suites/command-menu-item/utils/delete-command-menu-item.util';
import { updateCommandMenuItem } from 'test/integration/metadata/suites/command-menu-item/utils/update-command-menu-item.util';
import {
eachTestingContextFilter,
type EachTestingContext,
} from 'twenty-shared/testing';
import { FeatureFlagKey } from 'twenty-shared/types';
import { EngineComponentKey } from 'src/engine/metadata-modules/command-menu-item/enums/engine-component-key.enum';
import { type UpdateCommandMenuItemInput } from 'src/engine/metadata-modules/command-menu-item/dtos/update-command-menu-item.input';
type TestContext = {
input: (testSetup: TestSetup) => UpdateCommandMenuItemInput;
};
type TestSetup = {
testCommandMenuItemId: string;
};
describe('CommandMenuItem update should fail', () => {
let testCommandMenuItemId: string;
beforeAll(async () => {
await updateFeatureFlag({
featureFlag: FeatureFlagKey.IS_COMMAND_MENU_ITEM_ENABLED,
value: true,
expectToFail: false,
});
});
afterAll(async () => {
await updateFeatureFlag({
featureFlag: FeatureFlagKey.IS_COMMAND_MENU_ITEM_ENABLED,
value: false,
expectToFail: false,
});
});
beforeEach(async () => {
const { data } = await createCommandMenuItem({
expectToFail: false,
input: {
workflowVersionId: faker.string.uuid(),
engineComponentKey: EngineComponentKey.TRIGGER_WORKFLOW_VERSION,
label: 'Test Command Menu Item To Update',
icon: 'IconOriginal',
isPinned: false,
},
});
testCommandMenuItemId = data.createCommandMenuItem.id;
});
afterEach(async () => {
if (testCommandMenuItemId) {
await deleteCommandMenuItem({
expectToFail: false,
input: { id: testCommandMenuItemId },
});
}
});
const failingCommandMenuItemUpdateTestCases: EachTestingContext<TestContext>[] =
[
{
title: 'when updating with empty label',
context: {
input: (testSetup) => ({
id: testSetup.testCommandMenuItemId,
label: '',
}),
},
},
{
title: 'when updating with missing id',
context: {
input: () =>
({
label: 'Updated Label',
}) as UpdateCommandMenuItemInput,
},
},
{
title: 'when updating with empty id',
context: {
input: () => ({
id: '',
label: 'Updated Label',
}),
},
},
{
title: 'when updating with invalid id (not a UUID)',
context: {
input: () => ({
id: 'not-a-valid-uuid',
label: 'Updated Label',
}),
},
},
{
title: 'when updating a non-existent command menu item',
context: {
input: () => ({
id: faker.string.uuid(),
label: 'Updated Label',
}),
},
},
{
title:
'when changing engineComponentKey to a standard key on an item with workflowVersionId',
context: {
input: (testSetup) => ({
id: testSetup.testCommandMenuItemId,
engineComponentKey: EngineComponentKey.GO_TO_PEOPLE,
}),
},
},
];
it.each(eachTestingContextFilter(failingCommandMenuItemUpdateTestCases))(
'$title',
async ({ context }) => {
const testSetup: TestSetup = {
testCommandMenuItemId,
};
const input = context.input(testSetup);
const { errors } = await updateCommandMenuItem({
expectToFail: true,
input,
});
expectOneNotInternalServerErrorSnapshot({
errors,
});
},
);
});