b11f77df2a
## PR Description - Uses `expr-eval` to enable front components (SDK plugins) to define conditional availability as declarative expressions. - Moves shared types and constants to `twenty-shared` - Introduces a `conditionalAvailabilityExpression` field on `CommandMenuItemEntity`, allowing command menu items to store an `expr-eval` compatible expression string that is evaluated against a CommandMenuContext to determine if the item should be shown. - Creates an esbuild transform plugin `conditional-availability-transform-plugin` in `twenty-sdk` that converts TypeScript conditional availability expressions into `expr-eval` compatible syntax at build time, so SDK developers can write natural TS expressions that get transformed to evaluable strings. - Removes deprecated `forceRegisteredActionsByKey` state and its usage. - Creates `useCommandMenuContext` hook that builds the full `CommandMenuContext` object from React state, which is then passed to `useCommandMenuItemFrontComponentActions` for evaluating conditional availability expressions.
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { faker } from '@faker-js/faker';
|
|
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 { findCommandMenuItems } from 'test/integration/metadata/suites/command-menu-item/utils/find-command-menu-items.util';
|
|
import { FeatureFlagKey } from 'twenty-shared/types';
|
|
|
|
describe('CommandMenuItem deletion should succeed', () => {
|
|
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,
|
|
});
|
|
});
|
|
|
|
it('should delete an existing command menu item', async () => {
|
|
const workflowVersionId = faker.string.uuid();
|
|
|
|
const { data: createData } = await createCommandMenuItem({
|
|
expectToFail: false,
|
|
input: {
|
|
workflowVersionId,
|
|
label: 'Command Menu Item To Delete',
|
|
},
|
|
});
|
|
|
|
const createdId = createData.createCommandMenuItem.id;
|
|
|
|
const { data: deleteData } = await deleteCommandMenuItem({
|
|
expectToFail: false,
|
|
input: { id: createdId },
|
|
});
|
|
|
|
expect(deleteData.deleteCommandMenuItem).toMatchObject({
|
|
id: createdId,
|
|
label: 'Command Menu Item To Delete',
|
|
});
|
|
|
|
const { data: findData } = await findCommandMenuItems({
|
|
expectToFail: false,
|
|
input: undefined,
|
|
});
|
|
|
|
const deletedItem = findData.commandMenuItems.find(
|
|
(item) => item.id === createdId,
|
|
);
|
|
|
|
expect(deletedItem).toBeUndefined();
|
|
});
|
|
});
|