TWNTY-4602 - Increase coverage for coverage for twenty-front:storybook:modules (#4649)

* Increase coverage for coverage for  `twenty-front:storybook:modules`

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Chiazokam <chiazokamecheta@gmail.com>

* Increase code coverage threshold

* Increase code coverage threshold

* Increase code coverage threshold

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Chiazokam <chiazokamecheta@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
gitstart-app[bot]
2024-03-25 18:03:55 +01:00
committed by GitHub
parent 04c5d066f8
commit e126c5c7f3
11 changed files with 156 additions and 26 deletions

View File

@ -1,6 +1,6 @@
import { useCallback } from 'react';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar.tsx';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { useEmailPasswordResetLinkMutation } from '~/generated/graphql.tsx';
export const useHandleResetPassword = () => {

View File

@ -0,0 +1,37 @@
import { expect } from '@storybook/jest';
import { Meta, StoryObj } from '@storybook/react';
import { within } from '@storybook/test';
import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator';
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
import { ObjectMetadataNavItems } from '../ObjectMetadataNavItems';
const meta: Meta<typeof ObjectMetadataNavItems> = {
title: 'Modules/ObjectMetadata/ObjectMetadataNavItems',
component: ObjectMetadataNavItems,
decorators: [
ObjectMetadataItemsDecorator,
ComponentWithRouterDecorator,
ComponentWithRecoilScopeDecorator,
SnackBarDecorator,
],
parameters: {
msw: graphqlMocks,
},
};
export default meta;
type Story = StoryObj<typeof ObjectMetadataNavItems>;
export const Default: Story = {
play: async () => {
const canvas = within(document.body);
expect(await canvas.findByText('People')).toBeInTheDocument();
expect(await canvas.findByText('Companies')).toBeInTheDocument();
expect(await canvas.findByText('Opportunities')).toBeInTheDocument();
},
};

View File

@ -0,0 +1,27 @@
import { expect } from '@storybook/jest';
import { Meta, StoryObj } from '@storybook/react';
import { within } from '@storybook/test';
import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator';
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
import { Steps } from '../Steps';
const meta: Meta<typeof Steps> = {
title: 'Modules/SpreadsheetImport/Steps',
component: Steps,
decorators: [ComponentWithRecoilScopeDecorator, SnackBarDecorator],
};
export default meta;
type Story = StoryObj<typeof Steps>;
export const Default: Story = {
play: async () => {
const canvas = within(document.body);
expect(await canvas.findByText('Upload file')).toBeInTheDocument();
expect(await canvas.findByText('Match columns')).toBeInTheDocument();
expect(await canvas.findByText('Validate data')).toBeInTheDocument();
expect(await canvas.findByText('Select file')).toBeInTheDocument();
},
};

View File

@ -45,26 +45,32 @@ export const SupportChat = () => {
currentWorkspaceMember: Pick<WorkspaceMember, 'name'>,
) => {
const url = 'https://chat-assets.frontapp.com/v1/chat.bundle.js';
const script = document.querySelector(`script[src="${url}"]`);
let script = document.querySelector(`script[src="${url}"]`);
if (!script) {
insertScript({
src: url,
onLoad: () => {
window.FrontChat?.('init', {
chatId,
useDefaultLauncher: false,
email: currentUser.email,
name:
currentWorkspaceMember.name.firstName +
' ' +
currentWorkspaceMember.name.lastName,
userHash: currentUser?.supportUserHash,
});
setIsFrontChatLoaded(true);
},
});
// This function only gets called when front chat is not loaded
// If the script is already defined, but front chat is not loaded
// then there was an error loading the script; reload the script
if (isDefined(script)) {
script.parentNode?.removeChild(script);
script = null;
}
insertScript({
src: url,
onLoad: () => {
window.FrontChat?.('init', {
chatId,
useDefaultLauncher: false,
email: currentUser.email,
name:
currentWorkspaceMember.name.firstName +
' ' +
currentWorkspaceMember.name.lastName,
userHash: currentUser?.supportUserHash,
});
setIsFrontChatLoaded(true);
},
});
},
[],
);

View File

@ -0,0 +1,52 @@
import { expect } from '@storybook/jest';
import { Meta, StoryObj } from '@storybook/react';
import { within } from '@storybook/test';
import { useSetRecoilState } from 'recoil';
import { currentUserState } from '@/auth/states/currentUserState';
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { supportChatState } from '@/client-config/states/supportChatState';
import { graphqlMocks } from '~/testing/graphqlMocks';
import {
mockDefaultWorkspace,
mockedUsersData,
mockedWorkspaceMemberData,
} from '~/testing/mock-data/users';
import { SupportChat } from '../SupportChat';
const meta: Meta<typeof SupportChat> = {
title: 'Modules/Support/SupportChat',
component: SupportChat,
decorators: [
(Story) => {
const setCurrentUser = useSetRecoilState(currentUserState);
const setSupportChat = useSetRecoilState(supportChatState);
const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
const setCurrentWorkspaceMember = useSetRecoilState(
currentWorkspaceMemberState,
);
setCurrentWorkspace(mockDefaultWorkspace);
setCurrentWorkspaceMember(mockedWorkspaceMemberData);
setCurrentUser(mockedUsersData[0]);
setSupportChat({ supportDriver: 'front', supportFrontChatId: '1234' });
return <Story />;
},
],
parameters: {
msw: graphqlMocks,
},
};
export default meta;
type Story = StoryObj<typeof SupportChat>;
export const Default: Story = {
play: async () => {
const canvas = within(document.body);
expect(await canvas.findByText('Support')).toBeInTheDocument();
},
};