Increase test coverage for /modules/ui (#3314)

* Increase test coverage for `/modules/ui`

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: FellipeMTX <fellipefacdir@gmail.com>
Co-authored-by: Fellipe Montes <102544529+FellipeMTX@users.noreply.github.com>

* Merge main

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: FellipeMTX <fellipefacdir@gmail.com>
Co-authored-by: Fellipe Montes <102544529+FellipeMTX@users.noreply.github.com>

* Fix tests

* Fix tests

* Fix

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: FellipeMTX <fellipefacdir@gmail.com>
Co-authored-by: Fellipe Montes <102544529+FellipeMTX@users.noreply.github.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
gitstart-twenty
2024-01-11 08:51:36 +01:00
committed by GitHub
parent f34516d422
commit ebe8698910
48 changed files with 1652 additions and 55 deletions

View File

@ -1,13 +1,23 @@
import { useEffect } from 'react';
import { Decorator, Meta, StoryObj } from '@storybook/react';
import { expect, fn, userEvent, waitFor, within } from '@storybook/test';
import {
expect,
fireEvent,
fn,
userEvent,
waitFor,
within,
} from '@storybook/test';
import { useSetRecoilState } from 'recoil';
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { ObjectMetadataItemsProvider } from '@/object-metadata/components/ObjectMetadataItemsProvider';
import { RelationPickerScope } from '@/object-record/relation-picker/scopes/RelationPickerScope';
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator';
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
import { mockDefaultWorkspace } from '~/testing/mock-data/users';
import { FieldContextProvider } from '../../../__stories__/FieldContextProvider';
import { useRelationField } from '../../../hooks/useRelationField';
@ -17,11 +27,13 @@ import {
} from '../RelationFieldInput';
const RelationFieldValueSetterEffect = ({ value }: { value: number }) => {
const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
const { setFieldValue } = useRelationField();
useEffect(() => {
setCurrentWorkspace(mockDefaultWorkspace);
setFieldValue(value);
}, [setFieldValue, value]);
}, [setCurrentWorkspace, setFieldValue, value]);
return <></>;
};
@ -131,11 +143,12 @@ export const Cancel: Story = {
const canvas = within(canvasElement);
expect(cancelJestFn).toHaveBeenCalledTimes(0);
await canvas.findByText('John Wick');
const emptyDiv = canvas.getByTestId('data-field-input-click-outside-div');
fireEvent.click(emptyDiv);
await waitFor(() => {
userEvent.click(emptyDiv);
expect(cancelJestFn).toHaveBeenCalledTimes(1);
});
},

View File

@ -30,7 +30,6 @@ export const SingleEntitySelect = ({
refs: [containerRef],
callback: (event) => {
event.stopImmediatePropagation();
onCancel?.();
},
});