From e83b74b7ca399d68ecea17ea53eebcbeb0c0cce5 Mon Sep 17 00:00:00 2001 From: Sebastien LE MOUILLOUR <32456736+smouillour@users.noreply.github.com> Date: Fri, 20 Oct 2023 16:06:08 +0200 Subject: [PATCH 1/2] fix(TDOPS-5489): PNPM - Prepare scripts-config-jest (#4946) * fix(TDOPS-5489): PNPM - Prepare scripts-config-jest * add changeset --- .changeset/funny-rockets-bake.md | 5 + .../Headers/TreeHeader/TreeHeader.test.js | 7 - .../TreeBranchIcon/TreeBranchIcon.test.js | 6 - packages/components/test/i18nMock.js | 57 ------- packages/faceted-search/jest.setup.js | 1 - .../BadgeTags/BadgeTags.component.test.js | 6 +- .../forms/src/UIForm/UIForm.container.test.js | 2 - .../UIForm/Widget/Widget.component.test.js | 1 - .../Button/SingleButton.component.test.js | 1 - .../fields/Code/Code.component.test.tsx | 3 - .../Datalist/Datalist.component.test.js | 1 - .../displayMode/TextMode.component.test.js | 1 - .../UIForm/fields/Date/Date.component.test.js | 2 +- .../fields/Date/DateTime.component.test.js | 1 - .../UIForm/fields/Date/Time.component.test.js | 1 - .../Enumeration/EnumerationWidget.test.js | 1 - .../FieldTemplate.component.test.js | 1 - .../UIForm/fields/File/File.component.test.js | 1 - .../displayMode/TextMode.component.test.js | 1 - .../KeyValue/KeyValue.component.test.js | 1 - .../ListView/ListView.component.test.js | 2 +- .../MultiSelectTag.component.test.js | 1 - .../RadioOrSelect.component.test.js | 1 - .../fields/Radios/Radios.component.test.js | 1 - .../ResourcePicker.component.test.js | 1 - .../fields/Select/Select.component.test.js | 1 - .../fields/Toggle/Toggle.component.test.js | 1 - .../fieldsets/Array/Array.component.test.js | 1 - .../Array/ArrayItem.component.test.js | 1 - .../DefaultArrayTemplate.component.test.js | 1 - .../CollapsibleFieldset.component.test.js | 1 - .../forms/src/rhf/fields/Input/Input.test.js | 1 - .../src/rhf/fields/Select/Select.test.js | 1 - .../rhf/fields/TextArea/RHFTextArea.test.js | 1 - tools/scripts-config-jest/jest.config.js | 4 +- tools/scripts-config-jest/package.json | 46 +++++- tools/scripts-config-jest/test-setup.js | 85 +++++------ yarn.lock | 139 ++---------------- 38 files changed, 105 insertions(+), 284 deletions(-) create mode 100644 .changeset/funny-rockets-bake.md delete mode 100644 packages/components/test/i18nMock.js diff --git a/.changeset/funny-rockets-bake.md b/.changeset/funny-rockets-bake.md new file mode 100644 index 00000000000..886c1aa178f --- /dev/null +++ b/.changeset/funny-rockets-bake.md @@ -0,0 +1,5 @@ +--- +'@talend/scripts-config-jest': minor +--- + +Fix peer dependencies and adapt code to be compatible with pnpm diff --git a/packages/components/src/DataViewer/Headers/TreeHeader/TreeHeader.test.js b/packages/components/src/DataViewer/Headers/TreeHeader/TreeHeader.test.js index 81dd53fceae..1e1c3e7f210 100644 --- a/packages/components/src/DataViewer/Headers/TreeHeader/TreeHeader.test.js +++ b/packages/components/src/DataViewer/Headers/TreeHeader/TreeHeader.test.js @@ -2,13 +2,6 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import Component from './TreeHeader.component'; -jest.mock('react-i18next', () => { - // eslint-disable-next-line global-require - const mockTranslations = require('../../../../test/i18nMock').default; - - return mockTranslations(); -}); - describe('TreeHeader', () => { it('should render a simple tree header', () => { const { container } = render(); diff --git a/packages/components/src/DataViewer/Icons/TreeBranchIcon/TreeBranchIcon.test.js b/packages/components/src/DataViewer/Icons/TreeBranchIcon/TreeBranchIcon.test.js index 56fdcb54be1..f1d54ad4830 100644 --- a/packages/components/src/DataViewer/Icons/TreeBranchIcon/TreeBranchIcon.test.js +++ b/packages/components/src/DataViewer/Icons/TreeBranchIcon/TreeBranchIcon.test.js @@ -1,12 +1,6 @@ import { render, screen } from '@testing-library/react'; import Component, { getDefaultIcon } from './TreeBranchIcon.component'; jest.unmock('@talend/design-system'); -jest.mock('react-i18next', () => { - // eslint-disable-next-line global-require - const mockTranslations = require('../../../../test/i18nMock').default; - - return mockTranslations(); -}); describe('getDefaultIcon', () => { it('should return a custom object icon', () => { diff --git a/packages/components/test/i18nMock.js b/packages/components/test/i18nMock.js deleted file mode 100644 index b69937e5963..00000000000 --- a/packages/components/test/i18nMock.js +++ /dev/null @@ -1,57 +0,0 @@ -export default function mockTranslations() { - const React = require('react'); - - const useMock = [k => k, {}]; - useMock.t = (key, options) => - (options.defaultValue || '').replace(/{{(\w+)}}/g, (_, k) => options[k]); - useMock.i18n = {}; - - // from https://github.com/i18next/react-i18next/blob/master/example/test-jest/__mocks__/react-i18next.js - - const hasChildren = node => node && (node.children || (node.props && node.props.children)); - - const getChildren = node => - node && node.children ? node.children : node.props && node.props.children; - - const renderNodes = reactNodes => { - if (typeof reactNodes === 'string') { - return reactNodes; - } - - return Object.keys(reactNodes).map((key, i) => { - const child = reactNodes[key]; - const isElement = React.isValidElement(child); - - if (typeof child === 'string') { - return child; - } - if (hasChildren(child)) { - const inner = renderNodes(getChildren(child)); - return React.cloneElement(child, { ...child.props, key: i }, inner); - } - if (typeof child === 'object' && !isElement) { - return Object.keys(child).reduce((str, childKey) => `${str}${child[childKey]}`, ''); - } - - return child; - }); - }; - return { - // this mock makes sure any components using the translate HoC receive the t function as a prop - withTranslation: () => Component => { - Component.defaultProps = { - ...Component.defaultProps, - t: (key, options) => - (options.defaultValue || '').replace(/{{(\w+)}}/g, (_, k) => options[k]), - }; - Component.displayName = `withI18nextTranslation(${Component.displayName || Component.name})`; - return Component; - }, - useTranslation: () => useMock, - setI18n: () => {}, - getI18n: () => ({ - t: (key, options) => (options.defaultValue || '').replace(/{{(\w+)}}/g, (_, k) => options[k]), - }), - Trans: ({ children }) => renderNodes(children), - }; -} diff --git a/packages/faceted-search/jest.setup.js b/packages/faceted-search/jest.setup.js index d3d48b9808c..2ce0d641a5e 100644 --- a/packages/faceted-search/jest.setup.js +++ b/packages/faceted-search/jest.setup.js @@ -1,3 +1,2 @@ // DS is mocked by ui-scripts, preventing us to use testing-library getByLabelText & others selectors jest.unmock('@talend/design-system'); -jest.mock('ally.js'); diff --git a/packages/faceted-search/src/components/Badges/BadgeTags/BadgeTags.component.test.js b/packages/faceted-search/src/components/Badges/BadgeTags/BadgeTags.component.test.js index e51ee0c1018..01c1c60c019 100644 --- a/packages/faceted-search/src/components/Badges/BadgeTags/BadgeTags.component.test.js +++ b/packages/faceted-search/src/components/Badges/BadgeTags/BadgeTags.component.test.js @@ -1,11 +1,9 @@ -import { BadgeTags } from './BadgeTags.component'; -import { BadgeFacetedProvider } from '../../context/badgeFaceted.context'; import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { BadgeTags } from './BadgeTags.component'; +import { BadgeFacetedProvider } from '../../context/badgeFaceted.context'; import getDefaultT from '../../../translate'; -jest.mock('ally.js'); - const badgeFacetedContextValue = { dispatch: jest.fn(), }; diff --git a/packages/forms/src/UIForm/UIForm.container.test.js b/packages/forms/src/UIForm/UIForm.container.test.js index 5e4318f5698..228415e0c38 100644 --- a/packages/forms/src/UIForm/UIForm.container.test.js +++ b/packages/forms/src/UIForm/UIForm.container.test.js @@ -4,8 +4,6 @@ import userEvent from '@testing-library/user-event'; import { actions, getMockData, getMockNestedData, initProps } from '../../__mocks__/data'; import UIForm from './UIForm.container'; -jest.mock('ally.js'); - describe('UIForm container', () => { let props; beforeEach(() => { diff --git a/packages/forms/src/UIForm/Widget/Widget.component.test.js b/packages/forms/src/UIForm/Widget/Widget.component.test.js index 82d4658e92e..dd70aeed7d4 100644 --- a/packages/forms/src/UIForm/Widget/Widget.component.test.js +++ b/packages/forms/src/UIForm/Widget/Widget.component.test.js @@ -6,7 +6,6 @@ import { WidgetContext } from '../context'; import Widget from './Widget.component'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); describe('Widget component', () => { const schema = { diff --git a/packages/forms/src/UIForm/fields/Button/SingleButton.component.test.js b/packages/forms/src/UIForm/fields/Button/SingleButton.component.test.js index 137a39735fa..37f252ebf05 100644 --- a/packages/forms/src/UIForm/fields/Button/SingleButton.component.test.js +++ b/packages/forms/src/UIForm/fields/Button/SingleButton.component.test.js @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event'; import SingleButton from './SingleButton.component'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); describe('SingleButton field', () => { diff --git a/packages/forms/src/UIForm/fields/Code/Code.component.test.tsx b/packages/forms/src/UIForm/fields/Code/Code.component.test.tsx index a7d5f5e25ee..70536ad8ca0 100644 --- a/packages/forms/src/UIForm/fields/Code/Code.component.test.tsx +++ b/packages/forms/src/UIForm/fields/Code/Code.component.test.tsx @@ -9,9 +9,6 @@ import 'ace-builds/src-noconflict/ext-language_tools'; import Code, { CodeProps } from './Code.component'; -// fix cannot read appendChild of null; -jest.mock('ally.js'); - declare global { interface Window { ReactAce: { default: typeof ReactAce }; diff --git a/packages/forms/src/UIForm/fields/Datalist/Datalist.component.test.js b/packages/forms/src/UIForm/fields/Datalist/Datalist.component.test.js index e8ce0d48e59..408b2fd511e 100644 --- a/packages/forms/src/UIForm/fields/Datalist/Datalist.component.test.js +++ b/packages/forms/src/UIForm/fields/Datalist/Datalist.component.test.js @@ -4,7 +4,6 @@ import userEvent from '@testing-library/user-event'; import Datalist from './Datalist.component'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); const schema = { diff --git a/packages/forms/src/UIForm/fields/Datalist/displayMode/TextMode.component.test.js b/packages/forms/src/UIForm/fields/Datalist/displayMode/TextMode.component.test.js index 5eb76eb3eee..eb62a0ec9a7 100644 --- a/packages/forms/src/UIForm/fields/Datalist/displayMode/TextMode.component.test.js +++ b/packages/forms/src/UIForm/fields/Datalist/displayMode/TextMode.component.test.js @@ -1,7 +1,6 @@ import { render, screen } from '@testing-library/react'; import DatalistTextMode from './TextMode.component'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); const schema = { title: 'My List', diff --git a/packages/forms/src/UIForm/fields/Date/Date.component.test.js b/packages/forms/src/UIForm/fields/Date/Date.component.test.js index da4b06f6bf0..a2e480122aa 100644 --- a/packages/forms/src/UIForm/fields/Date/Date.component.test.js +++ b/packages/forms/src/UIForm/fields/Date/Date.component.test.js @@ -1,6 +1,6 @@ import { act, render, screen, fireEvent } from '@testing-library/react'; import DateWidget from './Date.component'; -jest.mock('ally.js'); + jest.unmock('@talend/design-system'); describe('Date widget', () => { diff --git a/packages/forms/src/UIForm/fields/Date/DateTime.component.test.js b/packages/forms/src/UIForm/fields/Date/DateTime.component.test.js index c8d43298795..54c012796fc 100644 --- a/packages/forms/src/UIForm/fields/Date/DateTime.component.test.js +++ b/packages/forms/src/UIForm/fields/Date/DateTime.component.test.js @@ -1,7 +1,6 @@ import { act, render, screen, fireEvent } from '@testing-library/react'; import DateTimeWidget from './DateTime.component'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); describe('DateTime widget', () => { diff --git a/packages/forms/src/UIForm/fields/Date/Time.component.test.js b/packages/forms/src/UIForm/fields/Date/Time.component.test.js index b6347805a02..b1f0c1d6181 100644 --- a/packages/forms/src/UIForm/fields/Date/Time.component.test.js +++ b/packages/forms/src/UIForm/fields/Date/Time.component.test.js @@ -2,7 +2,6 @@ import { act, render, screen, fireEvent } from '@testing-library/react'; import TimeWidget from './Time.component'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); describe('Time component', () => { beforeEach(() => { diff --git a/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js b/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js index a728c67b41f..1cf42d191ec 100644 --- a/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js +++ b/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event'; import EnumerationWidget from './EnumerationWidget'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); describe('EnumerationWidget', () => { it('should render items', () => { diff --git a/packages/forms/src/UIForm/fields/FieldTemplate/FieldTemplate.component.test.js b/packages/forms/src/UIForm/fields/FieldTemplate/FieldTemplate.component.test.js index 11f3a06693b..cf07e0b033a 100644 --- a/packages/forms/src/UIForm/fields/FieldTemplate/FieldTemplate.component.test.js +++ b/packages/forms/src/UIForm/fields/FieldTemplate/FieldTemplate.component.test.js @@ -3,7 +3,6 @@ import { screen, render } from '@testing-library/react'; import FieldTemplate from './FieldTemplate.component'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); describe('FieldTemplate', () => { const defaultProps = { diff --git a/packages/forms/src/UIForm/fields/File/File.component.test.js b/packages/forms/src/UIForm/fields/File/File.component.test.js index 87d035a66a0..b590a630325 100644 --- a/packages/forms/src/UIForm/fields/File/File.component.test.js +++ b/packages/forms/src/UIForm/fields/File/File.component.test.js @@ -2,7 +2,6 @@ import { screen, render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import File, { FileWidget, base64Decode } from './File.component'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); describe('File field', () => { diff --git a/packages/forms/src/UIForm/fields/File/displayMode/TextMode.component.test.js b/packages/forms/src/UIForm/fields/File/displayMode/TextMode.component.test.js index 13dcaec0303..ebdc24d94a9 100644 --- a/packages/forms/src/UIForm/fields/File/displayMode/TextMode.component.test.js +++ b/packages/forms/src/UIForm/fields/File/displayMode/TextMode.component.test.js @@ -1,6 +1,5 @@ import { screen, render } from '@testing-library/react'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); import TextMode from './TextMode.component'; diff --git a/packages/forms/src/UIForm/fields/KeyValue/KeyValue.component.test.js b/packages/forms/src/UIForm/fields/KeyValue/KeyValue.component.test.js index 2d0be6492de..21fff5e190c 100644 --- a/packages/forms/src/UIForm/fields/KeyValue/KeyValue.component.test.js +++ b/packages/forms/src/UIForm/fields/KeyValue/KeyValue.component.test.js @@ -3,7 +3,6 @@ import { screen, render } from '@testing-library/react'; import { WidgetContext } from '../../context'; import KeyValue from './KeyValue.component'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); const widgets = { diff --git a/packages/forms/src/UIForm/fields/ListView/ListView.component.test.js b/packages/forms/src/UIForm/fields/ListView/ListView.component.test.js index 2774af86448..c0ab93a0f58 100644 --- a/packages/forms/src/UIForm/fields/ListView/ListView.component.test.js +++ b/packages/forms/src/UIForm/fields/ListView/ListView.component.test.js @@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event'; import ListView from './ListView.component'; const NO_RESULT_MESSAGE = 'No results found'; -jest.mock('ally.js'); + jest.unmock('@talend/design-system'); describe('ListView field', () => { diff --git a/packages/forms/src/UIForm/fields/MultiSelectTag/MultiSelectTag.component.test.js b/packages/forms/src/UIForm/fields/MultiSelectTag/MultiSelectTag.component.test.js index cfb628b23fc..7e0af78e3a0 100644 --- a/packages/forms/src/UIForm/fields/MultiSelectTag/MultiSelectTag.component.test.js +++ b/packages/forms/src/UIForm/fields/MultiSelectTag/MultiSelectTag.component.test.js @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event'; import MultiSelectTag from './MultiSelectTag.component'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); describe('MultiSelectTag field', () => { diff --git a/packages/forms/src/UIForm/fields/RadioOrSelect/RadioOrSelect.component.test.js b/packages/forms/src/UIForm/fields/RadioOrSelect/RadioOrSelect.component.test.js index afa1d28ff1c..33b62d1a0e2 100644 --- a/packages/forms/src/UIForm/fields/RadioOrSelect/RadioOrSelect.component.test.js +++ b/packages/forms/src/UIForm/fields/RadioOrSelect/RadioOrSelect.component.test.js @@ -2,7 +2,6 @@ import { screen, render } from '@testing-library/react'; import RadioOrSelect from './RadioOrSelect.component'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); describe('RadioOrSelect field', () => { diff --git a/packages/forms/src/UIForm/fields/Radios/Radios.component.test.js b/packages/forms/src/UIForm/fields/Radios/Radios.component.test.js index cad819f0b36..7350280d17b 100644 --- a/packages/forms/src/UIForm/fields/Radios/Radios.component.test.js +++ b/packages/forms/src/UIForm/fields/Radios/Radios.component.test.js @@ -2,7 +2,6 @@ import { screen, render, fireEvent } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import Radios from './Radios.component'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); describe('Radios field', () => { diff --git a/packages/forms/src/UIForm/fields/ResourcePicker/ResourcePicker.component.test.js b/packages/forms/src/UIForm/fields/ResourcePicker/ResourcePicker.component.test.js index b65acf40b7c..0f5e1eb9300 100644 --- a/packages/forms/src/UIForm/fields/ResourcePicker/ResourcePicker.component.test.js +++ b/packages/forms/src/UIForm/fields/ResourcePicker/ResourcePicker.component.test.js @@ -5,7 +5,6 @@ import userEvent from '@testing-library/user-event'; import ResourcePicker from './ResourcePicker.component'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); jest.mock( '@talend/react-components/lib/ResourcePicker', diff --git a/packages/forms/src/UIForm/fields/Select/Select.component.test.js b/packages/forms/src/UIForm/fields/Select/Select.component.test.js index 4d832e5fe38..e85082f5128 100644 --- a/packages/forms/src/UIForm/fields/Select/Select.component.test.js +++ b/packages/forms/src/UIForm/fields/Select/Select.component.test.js @@ -4,7 +4,6 @@ import omit from 'lodash/omit'; import Select from './Select.component'; -jest.mock('ally.js'); jest.unmock('@talend/design-system'); describe('Select field', () => { diff --git a/packages/forms/src/UIForm/fields/Toggle/Toggle.component.test.js b/packages/forms/src/UIForm/fields/Toggle/Toggle.component.test.js index b8a42ffbb8a..475d3db9f6d 100644 --- a/packages/forms/src/UIForm/fields/Toggle/Toggle.component.test.js +++ b/packages/forms/src/UIForm/fields/Toggle/Toggle.component.test.js @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event'; import Toggle from './Toggle.component'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); describe('Toggle field', () => { const schema = { diff --git a/packages/forms/src/UIForm/fieldsets/Array/Array.component.test.js b/packages/forms/src/UIForm/fieldsets/Array/Array.component.test.js index 20619cfb102..c7ee52e4c73 100644 --- a/packages/forms/src/UIForm/fieldsets/Array/Array.component.test.js +++ b/packages/forms/src/UIForm/fieldsets/Array/Array.component.test.js @@ -7,7 +7,6 @@ import { screen, render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); function TestArray(props) { return
; diff --git a/packages/forms/src/UIForm/fieldsets/Array/ArrayItem.component.test.js b/packages/forms/src/UIForm/fieldsets/Array/ArrayItem.component.test.js index 174e895a074..e5271121e45 100644 --- a/packages/forms/src/UIForm/fieldsets/Array/ArrayItem.component.test.js +++ b/packages/forms/src/UIForm/fieldsets/Array/ArrayItem.component.test.js @@ -4,7 +4,6 @@ import userEvent from '@testing-library/user-event'; import ArrayItem from './ArrayItem.component'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); describe('Array Item component', () => { it('should render control panel with item content', () => { diff --git a/packages/forms/src/UIForm/fieldsets/Array/DefaultArrayTemplate.component.test.js b/packages/forms/src/UIForm/fieldsets/Array/DefaultArrayTemplate.component.test.js index f6dc7e83b0b..466120fea76 100644 --- a/packages/forms/src/UIForm/fieldsets/Array/DefaultArrayTemplate.component.test.js +++ b/packages/forms/src/UIForm/fieldsets/Array/DefaultArrayTemplate.component.test.js @@ -2,7 +2,6 @@ import { screen, render } from '@testing-library/react'; import DefaultArrayTemplate from './DefaultArrayTemplate.component'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); const schema = { description: 'Tnstructions to fill it', diff --git a/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.test.js b/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.test.js index e6db764589a..70f377b60a9 100644 --- a/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.test.js +++ b/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.test.js @@ -7,7 +7,6 @@ import { WidgetContext } from '../../context'; import widgets from '../../utils/widgets'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); function customTitle(value, schema) { return `${schema.title}: ${value.firstname} ${value.lastname}`; diff --git a/packages/forms/src/rhf/fields/Input/Input.test.js b/packages/forms/src/rhf/fields/Input/Input.test.js index cc375fb145f..fb876319190 100644 --- a/packages/forms/src/rhf/fields/Input/Input.test.js +++ b/packages/forms/src/rhf/fields/Input/Input.test.js @@ -5,7 +5,6 @@ import { useForm, FormProvider } from 'react-hook-form'; import Input from './RHFInput.component'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); /* eslint-disable-next-line react/prop-types */ function FormWrapper({ children, onSubmit }) { diff --git a/packages/forms/src/rhf/fields/Select/Select.test.js b/packages/forms/src/rhf/fields/Select/Select.test.js index fcabcec89fd..0a45727e40f 100644 --- a/packages/forms/src/rhf/fields/Select/Select.test.js +++ b/packages/forms/src/rhf/fields/Select/Select.test.js @@ -5,7 +5,6 @@ import { useForm, FormProvider } from 'react-hook-form'; import Select from './RHFSelect.component'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); /* eslint-disable-next-line react/prop-types */ function FormWrapper({ children, onSubmit }) { diff --git a/packages/forms/src/rhf/fields/TextArea/RHFTextArea.test.js b/packages/forms/src/rhf/fields/TextArea/RHFTextArea.test.js index 948f64798ee..5d6992c3af1 100644 --- a/packages/forms/src/rhf/fields/TextArea/RHFTextArea.test.js +++ b/packages/forms/src/rhf/fields/TextArea/RHFTextArea.test.js @@ -5,7 +5,6 @@ import { useForm, FormProvider } from 'react-hook-form'; import TextArea from './RHFTextArea.component'; jest.unmock('@talend/design-system'); -jest.mock('ally.js'); /* eslint-disable-next-line react/prop-types */ function FormWrapper({ children, onSubmit }) { diff --git a/tools/scripts-config-jest/jest.config.js b/tools/scripts-config-jest/jest.config.js index 8086069a78c..9496cf84088 100644 --- a/tools/scripts-config-jest/jest.config.js +++ b/tools/scripts-config-jest/jest.config.js @@ -59,9 +59,9 @@ module.exports = { // stop ignore node_modules transform since d3 and others start to put es6 as main of packages transformIgnorePatterns: [ // option 2, stop ignore transform on es6 packages - `/node_modules/(?!${d3Pkgs.join( + `node_modules/(?!(?:.pnpm/)?(${d3Pkgs.join( '|', - )}|internmap|d3-delaunay|delaunator|robust-predicates|@talend/tql/index)`, + )}|internmap|d3-delaunay|delaunator|robust-predicates|@talend/tql/index))`, // we can't have it twice (double negative patterns cancel each other), // so you can import addToIgnorePatterns from './utils' to add more pkgs diff --git a/tools/scripts-config-jest/package.json b/tools/scripts-config-jest/package.json index 62d2ddee4cd..956444e9c4c 100644 --- a/tools/scripts-config-jest/package.json +++ b/tools/scripts-config-jest/package.json @@ -14,21 +14,15 @@ "url": "https://github.com/Talend/ui.git" }, "scripts": { - "lint": "talend-scripts lint ./", - "test": "talend-scripts test" - }, - "peerDependencies": { - "enzyme": "3", - "react": ">= 16.14.0" + "lint": "echo \"Not possible to use talend-scripts here (risk of circular dependency)\" && exit 0", + "test": "jest" }, "dependencies": { "@talend/scripts-config-babel": "^13.0.0", "@testing-library/jest-dom": "^5.17.0", "@types/jest": "^29.5.5", - "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0", "babel-jest": "^29.7.0", "core-js": "^3.32.2", - "enzyme-adapter-react-16": "^1.15.7", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "jest-environment-jsdom-global": "^4.0.0", @@ -36,6 +30,42 @@ "raf": "^3.4.1", "regenerator-runtime": "^0.13.11" }, + "peerDependencies": { + "@talend/design-system": ">= 7.15.1", + "ally.js": ">= 1.4.1", + "i18next": ">= 20.6.1", + "classnames": ">= 2.3.2", + "jest-axe": ">= 8.0.0", + "prop-types": ">= 15.8.1", + "react": ">= 16.14.0", + "react-i18next": ">= 11.18.6" + }, + "peerDependenciesMeta": { + "@talend/design-system": { + "optional": true + }, + "ally.js": { + "optional": true + }, + "classnames": { + "optional": true + }, + "i18next": { + "optional": true + }, + "jest-axe": { + "optional": true + }, + "prop-types": { + "optional": true + }, + "react": { + "optional": true + }, + "react-i18next": { + "optional": true + } + }, "publishConfig": { "access": "public" } diff --git a/tools/scripts-config-jest/test-setup.js b/tools/scripts-config-jest/test-setup.js index 5ce325ca6f4..158134583be 100644 --- a/tools/scripts-config-jest/test-setup.js +++ b/tools/scripts-config-jest/test-setup.js @@ -7,15 +7,41 @@ /* eslint-disable no-empty */ /* eslint-disable import/no-extraneous-dependencies */ require('@testing-library/jest-dom'); +require('@testing-library/jest-dom/extend-expect'); require('core-js/stable'); require('regenerator-runtime/runtime'); require('raf/polyfill'); -const jestAxe = require('jest-axe'); +const warnMessageOptionalDep = (mainDepToMock, depList = []) => { + if (depList.length === 0) { + console.warn( + `JEST MOCK WARN: ${mainDepToMock} is not resolved.` + + '\nThis is an optional dependency.' + + '\nPlease add it in your dependencies if you need it', + ); + } else if (depList.length > 0) { + console.warn( + `JEST MOCK WARN: one or more of those deps are not resolved: ${depList.join(', ')}` + + 'These are optional dependencies but work together.' + + `\nIt's needed to mock ${mainDepToMock}` + + '\nPlease add them in your dependencies if you need them', + ); + } +}; -jest.mock('ally.js'); +try { + const jestAxe = require('jest-axe'); + expect.extend(jestAxe.toHaveNoViolations); +} catch (e) { + warnMessageOptionalDep('jest-axe'); +} + +try { + jest.mock('ally.js'); +} catch (e) { + warnMessageOptionalDep('ally.js'); +} -expect.extend(jestAxe.toHaveNoViolations); // add missing ResizeObserver class ResizeObserver { observe() { @@ -40,24 +66,6 @@ if (!global.self.TextEncoder) { global.self.TextEncoder = require('util').TextEncoder; global.self.TextDecoder = require('util').TextDecoder; } -// enzyme adapter configuration -let React; -try { - React = require('react'); -} catch (e) {} - -try { - const version = React && React.version; - if (version && version.startsWith('16.')) { - const configure = require('enzyme').configure; - const Adapter = require('enzyme-adapter-react-16'); - configure({ adapter: new Adapter() }); - } else if (version && version.startsWith('17.')) { - const configure = require('enzyme').configure; - const Adapter = require('@wojtekmaj/enzyme-adapter-react-17'); - configure({ adapter: new Adapter() }); - } -} catch (e) {} // Mock fetch try { @@ -88,16 +96,6 @@ try { console.error(e); } -try { - Object.defineProperty(global.self, 'crypto', { - value: { - randomUUID: () => '42', - }, - }); -} catch (e) { - console.error(e); -} - try { // Mock session storage delete window.sessionStorage; @@ -145,7 +143,11 @@ try { i18nextMock.addResources = () => {}; return i18nextMock; }); +} catch (e) { + warnMessageOptionalDep('i18next'); +} +try { jest.mock('react-i18next', () => { // from https://github.com/i18next/react-i18next/blob/master/example/test-jest/__mocks__/react-i18next.js const React = require('react'); @@ -195,7 +197,9 @@ try { Array.isArray(children) ? renderNodes(children) : renderNodes([children]), }; }); -} catch (e) {} +} catch (e) { + warnMessageOptionalDep('react-i18next', ['react-i18next', 'i18next', 'react']); +} try { jest.mock('@talend/design-system', () => { @@ -252,15 +256,14 @@ try { return mocks; }); -} catch {} - -try { - // in the case we unmock design-system we don't want id to be random - jest.mock('reakit/lib/Id/IdProvider', () => ({ - ...jest.requireActual('reakit/lib/Id/IdProvider'), - unstable_IdContext: jest.requireActual('react').createContext(() => 'id-42'), - })); -} catch {} +} catch { + warnMessageOptionalDep('@talend/design-system', [ + '@talend/design-system', + 'react', + 'prop-types', + 'classnames', + ]); +} // @floating-ui/react // https://github.com/floating-ui/floating-ui/issues/1908 diff --git a/yarn.lock b/yarn.lock index b04b0464af4..1a59bdf8b08 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5544,28 +5544,6 @@ dependencies: lodash "^4" -"@wojtekmaj/enzyme-adapter-react-17@^0.8.0": - version "0.8.0" - resolved "https://registry.yarnpkg.com/@wojtekmaj/enzyme-adapter-react-17/-/enzyme-adapter-react-17-0.8.0.tgz#138f404f82f502d152242c049e87d9621dcda4bd" - integrity sha512-zeUGfQRziXW7R7skzNuJyi01ZwuKCH8WiBNnTgUJwdS/CURrJwAhWsfW7nG7E30ak8Pu3ZwD9PlK9skBfAoOBw== - dependencies: - "@wojtekmaj/enzyme-adapter-utils" "^0.2.0" - enzyme-shallow-equal "^1.0.0" - has "^1.0.0" - prop-types "^15.7.0" - react-is "^17.0.0" - react-test-renderer "^17.0.0" - -"@wojtekmaj/enzyme-adapter-utils@^0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@wojtekmaj/enzyme-adapter-utils/-/enzyme-adapter-utils-0.2.0.tgz#dc2a8c14f92e502da28ea6b3fad96a082076d028" - integrity sha512-ZvZm9kZxZEKAbw+M1/Q3iDuqQndVoN8uLnxZ8bzxm7KgGTBejrGRoJAp8f1EN8eoO3iAjBNEQnTDW/H4Ekb0FQ== - dependencies: - function.prototype.name "^1.1.0" - has "^1.0.0" - object.fromentries "^2.0.0" - prop-types "^15.7.0" - "@xmldom/xmldom@^0.7.2": version "0.7.13" resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.7.13.tgz#ff34942667a4e19a9f4a0996a76814daac364cf3" @@ -5765,21 +5743,6 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" -airbnb-prop-types@^2.16.0: - version "2.16.0" - resolved "https://registry.yarnpkg.com/airbnb-prop-types/-/airbnb-prop-types-2.16.0.tgz#b96274cefa1abb14f623f804173ee97c13971dc2" - integrity sha512-7WHOFolP/6cS96PhKNrslCLMYAI8yB1Pp6u6XmxozQOiZbsI5ycglZr5cHhBFfuRcQQjzCMith5ZPZdYiJCxUg== - dependencies: - array.prototype.find "^2.1.1" - function.prototype.name "^1.1.2" - is-regex "^1.1.0" - object-is "^1.1.2" - object.assign "^4.1.0" - object.entries "^1.1.2" - prop-types "^15.7.2" - prop-types-exact "^1.2.0" - react-is "^16.13.1" - ajv-formats@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520" @@ -6058,16 +6021,6 @@ array-uniq@^1.0.1: resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" integrity sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q== -array.prototype.find@^2.1.1: - version "2.2.2" - resolved "https://registry.yarnpkg.com/array.prototype.find/-/array.prototype.find-2.2.2.tgz#e862cf891e725d8f2a10e5e42d750629faaabd32" - integrity sha512-DRumkfW97iZGOfn+lIXbkVrXL04sfYKX+EfOodo8XboR5sxPDVvOjZTF/rysusa9lmhmSOeD6Vp6RKQP+eP4Tg== - dependencies: - call-bind "^1.0.2" - define-properties "^1.2.0" - es-abstract "^1.22.1" - es-shim-unscopables "^1.0.0" - array.prototype.findlastindex@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.3.tgz#b37598438f97b579166940814e2c0493a4f50207" @@ -8961,42 +8914,6 @@ envinfo@^7.7.3: resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.10.0.tgz#55146e3909cc5fe63c22da63fb15b05aeac35b13" integrity sha512-ZtUjZO6l5mwTHvc1L9+1q5p/R3wTopcfqMW8r5t8SJSKqeVI/LtajORwRFEKpEFuekjD0VBjwu1HMxL4UalIRw== -enzyme-adapter-react-16@^1.15.7: - version "1.15.7" - resolved "https://registry.yarnpkg.com/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.15.7.tgz#a737e6d8e2c147e9da5acf957755be7634f76201" - integrity sha512-LtjKgvlTc/H7adyQcj+aq0P0H07LDL480WQl1gU512IUyaDo/sbOaNDdZsJXYW2XaoPqrLLE9KbZS+X2z6BASw== - dependencies: - enzyme-adapter-utils "^1.14.1" - enzyme-shallow-equal "^1.0.5" - has "^1.0.3" - object.assign "^4.1.4" - object.values "^1.1.5" - prop-types "^15.8.1" - react-is "^16.13.1" - react-test-renderer "^16.0.0-0" - semver "^5.7.0" - -enzyme-adapter-utils@^1.14.1: - version "1.14.1" - resolved "https://registry.yarnpkg.com/enzyme-adapter-utils/-/enzyme-adapter-utils-1.14.1.tgz#f30db15dafc22e0ccd44f5acc8d93be29218cdcf" - integrity sha512-JZgMPF1QOI7IzBj24EZoDpaeG/p8Os7WeBZWTJydpsH7JRStc7jYbHE4CmNQaLqazaGFyLM8ALWA3IIZvxW3PQ== - dependencies: - airbnb-prop-types "^2.16.0" - function.prototype.name "^1.1.5" - has "^1.0.3" - object.assign "^4.1.4" - object.fromentries "^2.0.5" - prop-types "^15.8.1" - semver "^5.7.1" - -enzyme-shallow-equal@^1.0.0, enzyme-shallow-equal@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/enzyme-shallow-equal/-/enzyme-shallow-equal-1.0.5.tgz#5528a897a6ad2bdc417c7221a7db682cd01711ba" - integrity sha512-i6cwm7hN630JXenxxJFBKzgLC3hMTafFQXflvzHgPmDhOBhxUWDe8AeRv1qp2/uWJ2Y8z5yLWMzmAfkTOiOCZg== - dependencies: - has "^1.0.3" - object-is "^1.1.5" - eol@^0.9.1: version "0.9.1" resolved "https://registry.yarnpkg.com/eol/-/eol-0.9.1.tgz#f701912f504074be35c6117a5c4ade49cd547acd" @@ -10280,7 +10197,7 @@ function-bind@^1.1.1: resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== -function.prototype.name@^1.1.0, function.prototype.name@^1.1.2, function.prototype.name@^1.1.5, function.prototype.name@^1.1.6: +function.prototype.name@^1.1.5, function.prototype.name@^1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.6.tgz#cdf315b7d90ee77a4c6ee216c3c3362da07533fd" integrity sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg== @@ -10713,7 +10630,7 @@ has-unicode@^2.0.1: resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" integrity sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ== -has@^1.0.0, has@^1.0.3: +has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== @@ -11620,7 +11537,7 @@ is-potential-custom-element-name@^1.0.1: resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5" integrity sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ== -is-regex@^1.1.0, is-regex@^1.1.4: +is-regex@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958" integrity sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg== @@ -13880,7 +13797,7 @@ object-inspect@^1.12.3, object-inspect@^1.9.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== -object-is@^1.1.2, object-is@^1.1.5: +object-is@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== @@ -13893,7 +13810,7 @@ object-keys@^1.1.1: resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== -object.assign@^4.0.3, object.assign@^4.1.0, object.assign@^4.1.2, object.assign@^4.1.4: +object.assign@^4.0.3, object.assign@^4.1.2, object.assign@^4.1.4: version "4.1.4" resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.4.tgz#9673c7c7c351ab8c4d0b516f4343ebf4dfb7799f" integrity sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ== @@ -13903,7 +13820,7 @@ object.assign@^4.0.3, object.assign@^4.1.0, object.assign@^4.1.2, object.assign@ has-symbols "^1.0.3" object-keys "^1.1.1" -object.entries@^1.1.2, object.entries@^1.1.5, object.entries@^1.1.6: +object.entries@^1.1.5, object.entries@^1.1.6: version "1.1.7" resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.7.tgz#2b47760e2a2e3a752f39dd874655c61a7f03c131" integrity sha512-jCBs/0plmPsOnrKAfFQXRG2NFjlhZgjjcBLSmTnEhU8U6vVTsVe8ANeQJCHTl3gSsI4J+0emOoCgoKlmQPMgmA== @@ -13912,7 +13829,7 @@ object.entries@^1.1.2, object.entries@^1.1.5, object.entries@^1.1.6: define-properties "^1.2.0" es-abstract "^1.22.1" -object.fromentries@^2.0.0, object.fromentries@^2.0.5, object.fromentries@^2.0.6: +object.fromentries@^2.0.6: version "2.0.7" resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.7.tgz#71e95f441e9a0ea6baf682ecaaf37fa2a8d7e616" integrity sha512-UPbPHML6sL8PI/mOqPwsH4G6iyXcCGzLin8KvEPenOZN5lpCNBZZQ+V62vdjB1mQHrmqGQt5/OJzemUA+KJmEA== @@ -13950,7 +13867,7 @@ object.hasown@^1.1.2: define-properties "^1.2.0" es-abstract "^1.22.1" -object.values@^1.1.0, object.values@^1.1.5, object.values@^1.1.6: +object.values@^1.1.0, object.values@^1.1.6: version "1.1.7" resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.7.tgz#617ed13272e7e1071b43973aa1655d9291b8442a" integrity sha512-aU6xnDFYT3x17e/f0IiiwlGPTy2jzMySGfUB4fq6z7CV8l85CWHDk5ErhyhpfDHhrOMwGFhSQkhMGHaIotA6Ng== @@ -15184,15 +15101,6 @@ prompts@^2.0.1, prompts@^2.4.0: kleur "^3.0.3" sisteransi "^1.0.5" -prop-types-exact@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/prop-types-exact/-/prop-types-exact-1.2.0.tgz#825d6be46094663848237e3925a98c6e944e9869" - integrity sha512-K+Tk3Kd9V0odiXFP9fwDHUYRyvK3Nun3GVyPapSIs5OBkITAm15W0CPFD/YKTkMUAbc0b9CUwRQp2ybiBIq+eA== - dependencies: - has "^1.0.3" - object.assign "^4.1.0" - reflect.ownkeys "^0.2.0" - prop-types-extra@^1.0.1, prop-types-extra@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/prop-types-extra/-/prop-types-extra-1.1.1.tgz#58c3b74cbfbb95d304625975aa2f0848329a010b" @@ -15201,7 +15109,7 @@ prop-types-extra@^1.0.1, prop-types-extra@^1.1.1: react-is "^16.3.2" warning "^4.0.0" -prop-types@15.7.2, prop-types@15.x, prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.0, prop-types@^15.7.2, prop-types@^15.8.1: +prop-types@15.7.2, prop-types@15.x, prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1: version "15.8.1" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== @@ -15595,7 +15503,7 @@ react-is@18.1.0: resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.1.0.tgz#61aaed3096d30eacf2a2127118b5b41387d32a67" integrity sha512-Fl7FuabXsJnV5Q1qIOQwx/sagGF18kogb4gpfcG4gjLBWO0WDiiz1ko/ExayuxE7InyQkBLkxRFG5oxY6Uu3Kg== -react-is@^16.10.2, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.3.2, react-is@^16.7.0, react-is@^16.8.6: +react-is@^16.10.2, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.3.2, react-is@^16.7.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== @@ -15774,17 +15682,7 @@ react-syntax-highlighter@^15.5.0: prismjs "^1.27.0" refractor "^3.6.0" -react-test-renderer@^16.0.0-0: - version "16.14.0" - resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.14.0.tgz#e98360087348e260c56d4fe2315e970480c228ae" - integrity sha512-L8yPjqPE5CZO6rKsKXRO/rVPiaCOy0tQQJbC+UjPNlobl5mad59lvPjwFsQHTvL03caVDIVr9x9/OSgDe6I5Eg== - dependencies: - object-assign "^4.1.1" - prop-types "^15.6.2" - react-is "^16.8.6" - scheduler "^0.19.1" - -react-test-renderer@^17.0.0, react-test-renderer@^17.0.2: +react-test-renderer@^17.0.2: version "17.0.2" resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-17.0.2.tgz#4cd4ae5ef1ad5670fc0ef776e8cc7e1231d9866c" integrity sha512-yaQ9cB89c17PUb0x6UfWRs7kQCorVdHlutU1boVPEsB8IDZH6n9tHxMacc3y0JoXOJUsZb/t/Mb8FUWMKaM7iQ== @@ -16149,11 +16047,6 @@ reflect.getprototypeof@^1.0.4: globalthis "^1.0.3" which-builtin-type "^1.1.3" -reflect.ownkeys@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/reflect.ownkeys/-/reflect.ownkeys-0.2.0.tgz#749aceec7f3fdf8b63f927a04809e90c5c0b3460" - integrity sha512-qOLsBKHCpSOFKK1NUOCGC5VyeufB6lEsFe92AL2bhIJsacZS1qdoOZSbPk3MYKuT2cFlRDnulKXuuElIrMjGUg== - refractor@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/refractor/-/refractor-3.6.0.tgz#ac318f5a0715ead790fcfb0c71f4dd83d977935a" @@ -16645,14 +16538,6 @@ saxes@^6.0.0: dependencies: xmlchars "^2.2.0" -scheduler@^0.19.1: - version "0.19.1" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.19.1.tgz#4f3e2ed2c1a7d65681f4c854fa8c5a1ccb40f196" - integrity sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - scheduler@^0.20.2: version "0.20.2" resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91" @@ -16731,7 +16616,7 @@ semver-compare@^1.0.0: resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" integrity sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow== -"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.6.0, semver@^5.7.0, semver@^5.7.1: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.6.0: version "5.7.2" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== From 35263dfcb1c1b3028a5cc2854568e9a1d5c8c549 Mon Sep 17 00:00:00 2001 From: Jean-Michel FRANCOIS Date: Fri, 20 Oct 2023 18:48:17 +0200 Subject: [PATCH 2/2] chore: fix stories in errors (#4942) * chore: remove stories around code that do not exists * chore: fix RHF/Select/Valdation error * fix: storybook * Add style for icons in storybook one to be able to use it in chromatic * Fix Icon stories * fix: story * fix customValidation * Fix call to ToggleSwitch --------- Co-authored-by: Sebastien LE MOUILLOUR <32456736+smouillour@users.noreply.github.com> Co-authored-by: smouillour --- .changeset/small-kiwis-end.md | 5 ++ .../components/src/Toggle/Toggle.stories.js | 61 ------------------- .../FacetedToolbar.component.js | 4 +- .../src/rhf/fields/Select/Select.stories.js | 10 ++- packages/forms/stories/SchemaCore.stories.tsx | 5 ++ .../forms/stories/SchemaFields.stories.tsx | 58 ++++++++++++++++++ packages/icons/.storybook/preview-head.html | 29 --------- packages/icons/stories/Icon.stories.tsx | 35 ++++++----- packages/icons/stories/Icon.tsx | 24 ++++++++ .../.storybook-templates/preview.js | 10 +-- 10 files changed, 126 insertions(+), 115 deletions(-) create mode 100644 .changeset/small-kiwis-end.md delete mode 100644 packages/icons/.storybook/preview-head.html diff --git a/.changeset/small-kiwis-end.md b/.changeset/small-kiwis-end.md new file mode 100644 index 00000000000..ac2b4b0c516 --- /dev/null +++ b/.changeset/small-kiwis-end.md @@ -0,0 +1,5 @@ +--- +'@talend/scripts-config-storybook-lib': patch +--- + +fix: icon url to support prefix diff --git a/packages/components/src/Toggle/Toggle.stories.js b/packages/components/src/Toggle/Toggle.stories.js index 6d623ea7299..e8304eeb02d 100644 --- a/packages/components/src/Toggle/Toggle.stories.js +++ b/packages/components/src/Toggle/Toggle.stories.js @@ -1,5 +1,3 @@ -import { useState } from 'react'; -import PropTypes from 'prop-types'; import { action } from '@storybook/addon-actions'; import Toggle from './Toggle.component'; @@ -31,33 +29,6 @@ const withLabel = { label: 'Some label', }; -const labelToggleProps = { - values: [ - { value: 'val1', label: 'Value 1' }, - { value: 'val2', label: 'Value 2' }, - { value: 'val3', label: 'Value 3' }, - ], -}; - -const InteractiveLabelToggle = ({ defaultValue = '', name, autoFocus }) => { - const [value, setValue] = useState(defaultValue); - - return ( - - ); -}; -InteractiveLabelToggle.propTypes = { - defaultValue: PropTypes.string, - autoFocus: PropTypes.bool, - name: PropTypes.string.isRequired, -}; - export default { title: 'Components/Form - Controls/Toggle', }; @@ -89,35 +60,3 @@ export const Default = () => (
); - -export const LabelToggle = () => ( -
-

Label Toggle

-
-

Non interactive two states

- -

Interactive

- -

Interactive autofocused

- -

Interactive with default selected value

- -

Disabled with selected value

- - -
-); diff --git a/packages/faceted-search/src/components/FacetedToolbar/FacetedToolbar.component.js b/packages/faceted-search/src/components/FacetedToolbar/FacetedToolbar.component.js index 8c11fa6e461..c7b96f13172 100644 --- a/packages/faceted-search/src/components/FacetedToolbar/FacetedToolbar.component.js +++ b/packages/faceted-search/src/components/FacetedToolbar/FacetedToolbar.component.js @@ -1,6 +1,6 @@ import PropTypes from 'prop-types'; -import { Form, ToggleSwitch } from '@talend/design-system'; +import { Form } from '@talend/design-system'; import { getTheme } from '@talend/react-components/lib/theme'; import { FACETED_MODE, USAGE_TRACKING_TAGS } from '../../constants'; @@ -11,7 +11,7 @@ const theme = getTheme(cssModule); const SwitchFacetedMode = ({ facetedMode, onChange, t }) => (
- diff --git a/packages/forms/src/rhf/fields/Select/Select.stories.js b/packages/forms/src/rhf/fields/Select/Select.stories.js index d7c297d471a..acda33aac47 100644 --- a/packages/forms/src/rhf/fields/Select/Select.stories.js +++ b/packages/forms/src/rhf/fields/Select/Select.stories.js @@ -104,7 +104,13 @@ export const Validation = props => {