From 07180af8c02048a4672d11ee986eab3d5bd58af8 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Mon, 24 Jul 2023 00:57:56 -0700 Subject: [PATCH] Improve tests (#871) --- front/.storybook/preview.ts | 2 +- .../comment/__stories__/Comment.stories.tsx | 2 +- .../__stories__/CommentHeader.stories.tsx | 2 +- .../components/CommentThreadCreateButton.tsx | 2 +- .../CommentThreadRelationPicker.tsx | 2 +- .../components/CommentThreadTypeDropdown.tsx | 3 +- .../CommentThreadRelationPicker.stories.tsx | 2 +- .../__stories__/CommentChip.stories.tsx | 2 +- .../__stories__/CommandMenu.stories.tsx | 2 +- .../components/CommentThreadTypeDropdown.tsx | 60 --------- .../companies/__stories__/Board.stories.tsx | 2 +- .../__stories__/CompanyBoardCard.stories.tsx | 2 +- .../__stories__/CompanyChip.stories.tsx | 7 +- .../components/CompanyAccountOwnerCell.tsx | 2 +- .../companies/components/CompanyBoardCard.tsx | 6 +- .../companies/components/CompanyChip.tsx | 16 +-- .../components/CompanyEditableNameCell.tsx | 2 +- .../CompanyAccountOwnerEditableField.tsx | 2 +- .../components/EditablePeopleFullName.tsx | 1 - .../people/components/PeopleCompanyCell.tsx | 2 +- .../modules/people/components/PersonChip.tsx | 11 +- .../__stories__/PeopleChip.stories.tsx | 3 +- .../components/PeopleCompanyEditableField.tsx | 2 +- .../__stories__/ActionBar.stories.tsx | 2 +- .../BoardColumnEditTitleMenu.stories.tsx | 2 +- .../__stories__/MainButton.stories.tsx | 2 +- .../__stories__/RoundedIconButton.stories.tsx | 2 +- front/src/modules/ui/chip/components/Chip.tsx | 120 ++++++++++++++++++ .../modules/ui/chip/components/EntityChip.tsx | 117 ++++------------- .../components/__stories__/Chip.stories.tsx | 48 +++++++ .../__stories__/EntityChip.stories.tsx | 21 +++ .../__stories__/ColorSchemeCard.stories.tsx | 2 +- .../__stories__/DropdownMenu.stories.tsx | 2 +- .../__stories__/DateEditableField.stories.tsx | 2 +- .../NumberEditableField.stories.tsx | 2 +- .../PhoneEditableField.stories.tsx | 2 +- .../__stories__/TextEditableField.stories.tsx | 2 +- .../__stories__/AutosizeTextInput.stories.tsx | 2 +- .../__stories__/TextInput.stories.tsx | 2 +- .../__stories__/PrimaryLink.stories.tsx | 2 +- .../__stories__/SoonPill.stories.tsx | 2 +- .../__stories__/RightDrawerTopBar.stories.tsx | 2 +- .../__stories__/EditableCellText.stories.tsx | 6 +- .../components/__stories__/Tag.stories.tsx | 2 +- .../components/__stories__/Avatar.stories.tsx | 2 +- .../__stories__/People.inputs.stories.tsx | 10 +- .../src/testing/ComponentStorybookLayout.tsx | 1 + front/src/testing/decorators.tsx | 32 ----- .../decorators/CellPositionDecorator.tsx | 13 ++ .../testing/decorators/ComponentDecorator.tsx | 9 ++ .../ComponentWithRouterDecorator.tsx | 12 ++ .../ExhaustiveComponentDecorator.tsx | 110 ++++++++++++++++ .../src/testing/decorators/RootDecorator.tsx | 13 ++ 53 files changed, 432 insertions(+), 251 deletions(-) delete mode 100644 front/src/modules/comments/components/CommentThreadTypeDropdown.tsx create mode 100644 front/src/modules/ui/chip/components/Chip.tsx create mode 100644 front/src/modules/ui/chip/components/__stories__/Chip.stories.tsx create mode 100644 front/src/modules/ui/chip/components/__stories__/EntityChip.stories.tsx delete mode 100644 front/src/testing/decorators.tsx create mode 100644 front/src/testing/decorators/CellPositionDecorator.tsx create mode 100644 front/src/testing/decorators/ComponentDecorator.tsx create mode 100644 front/src/testing/decorators/ComponentWithRouterDecorator.tsx create mode 100644 front/src/testing/decorators/ExhaustiveComponentDecorator.tsx create mode 100644 front/src/testing/decorators/RootDecorator.tsx diff --git a/front/.storybook/preview.ts b/front/.storybook/preview.ts index df1f1131f..77ee7cdd0 100644 --- a/front/.storybook/preview.ts +++ b/front/.storybook/preview.ts @@ -3,7 +3,7 @@ import { Preview } from '@storybook/react'; import { ThemeProvider } from '@emotion/react'; import { withThemeFromJSXProvider } from '@storybook/addon-styling'; import { lightTheme, darkTheme } from '../src/modules/ui/themes/themes'; -import { RootDecorator } from '../src/testing/decorators'; +import { RootDecorator } from '../src/testing/decorators/RootDecorator'; import 'react-loading-skeleton/dist/skeleton.css'; import { mockedUserJWT } from '../src/testing/mock-data/jwt'; initialize(); diff --git a/front/src/modules/activities/comment/__stories__/Comment.stories.tsx b/front/src/modules/activities/comment/__stories__/Comment.stories.tsx index ced54302d..aaf31f461 100644 --- a/front/src/modules/activities/comment/__stories__/Comment.stories.tsx +++ b/front/src/modules/activities/comment/__stories__/Comment.stories.tsx @@ -1,6 +1,6 @@ import type { Meta, StoryObj } from '@storybook/react'; -import { ComponentDecorator } from '~/testing/decorators'; +import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator'; import { CommentThreadActionBar } from '../../right-drawer/components/CommentThreadActionBar'; import { Comment } from '../Comment'; diff --git a/front/src/modules/activities/comment/__stories__/CommentHeader.stories.tsx b/front/src/modules/activities/comment/__stories__/CommentHeader.stories.tsx index 536a8992d..3e5a53eb3 100644 --- a/front/src/modules/activities/comment/__stories__/CommentHeader.stories.tsx +++ b/front/src/modules/activities/comment/__stories__/CommentHeader.stories.tsx @@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react'; import { DateTime } from 'luxon'; import { CommentThreadActionBar } from '@/activities/right-drawer/components/CommentThreadActionBar'; -import { ComponentDecorator } from '~/testing/decorators'; +import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator'; import { avatarUrl } from '~/testing/mock-data/users'; import { CommentHeader } from '../CommentHeader'; diff --git a/front/src/modules/activities/components/CommentThreadCreateButton.tsx b/front/src/modules/activities/components/CommentThreadCreateButton.tsx index 537e436f6..75e8d5788 100644 --- a/front/src/modules/activities/components/CommentThreadCreateButton.tsx +++ b/front/src/modules/activities/components/CommentThreadCreateButton.tsx @@ -26,7 +26,7 @@ export function CommentThreadCreateButton({