diff --git a/packages/core/content-type-builder/admin/src/components/AttributeOptions/tests/__snapshots__/index.test.js.snap b/packages/core/content-type-builder/admin/src/components/AttributeOptions/tests/__snapshots__/index.test.js.snap index 88264ac545..d2f972406b 100644 --- a/packages/core/content-type-builder/admin/src/components/AttributeOptions/tests/__snapshots__/index.test.js.snap +++ b/packages/core/content-type-builder/admin/src/components/AttributeOptions/tests/__snapshots__/index.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AttributeOptions renders and matches the snapshot 1`] = ` +exports[` renders and matches the snapshot 1`] = ` .c26 { border: 0; -webkit-clip: rect(0 0 0 0); @@ -216,7 +216,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = `

- Select a field for your collection type + Select a field

- Text + text
- Small or long text like title or description + A type for modeling data
@@ -403,7 +403,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - Email + email
- Email field with validations format + A type for modeling data
@@ -472,7 +472,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - Rich text + richtext
- A rich text editor with formatting options + A type for modeling data
@@ -535,7 +535,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - Password + password
- Password field with encryption + A type for modeling data
@@ -602,7 +602,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - Number + number
- Numbers (integer, float, decimal) + A type for modeling data
@@ -671,7 +671,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - Enumeration + enumeration
- List of values, then pick one + A type for modeling data
@@ -736,7 +736,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - Date + date
- A date picker with hours, minutes and seconds + A type for modeling data
@@ -805,7 +805,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - Media + media
- Files like images, videos, etc + A type for modeling data
@@ -872,7 +872,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - Boolean + boolean
- Yes or no, 1 or 0, true or false + A type for modeling data
@@ -941,7 +941,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - JSON + json
- Data in JSON format + A type for modeling data
@@ -1006,7 +1006,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - Relation + relation
- Refers to a Collection Type + A type for modeling data
@@ -1069,7 +1069,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - UID + uid
- Unique identifier + A type for modeling data
@@ -1146,7 +1146,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - Component + component
- Group of fields that you can repeat or reuse + A type for modeling data
@@ -1213,7 +1213,7 @@ exports[`AttributeOptions renders and matches the snapshot 1`] = ` - Dynamic zone + dynamiczone
- Dynamically pick component when editing content + A type for modeling data
diff --git a/packages/core/content-type-builder/admin/src/components/AttributeOptions/tests/index.test.js b/packages/core/content-type-builder/admin/src/components/AttributeOptions/tests/index.test.js index d24d6865d2..8b927ce234 100644 --- a/packages/core/content-type-builder/admin/src/components/AttributeOptions/tests/index.test.js +++ b/packages/core/content-type-builder/admin/src/components/AttributeOptions/tests/index.test.js @@ -1,15 +1,8 @@ -import { render, screen, getByText, fireEvent } from '@testing-library/react'; -import { createMemoryHistory } from 'history'; import React from 'react'; -import { Router } from 'react-router-dom'; -import { lightTheme, darkTheme } from '@strapi/design-system'; -import LanguageProvider from '../../../../../../admin/admin/src/components/LanguageProvider'; -import Theme from '../../../../../../admin/admin/src/components/Theme'; -import ThemeToggleProvider from '../../../../../../admin/admin/src/components/ThemeToggleProvider'; -import en from '../../../../../../admin/admin/src/translations/en.json'; +import { render, screen, getByText, fireEvent } from '@testing-library/react'; +import { lightTheme, ThemeProvider } from '@strapi/design-system'; +import { IntlProvider } from 'react-intl'; import FormModalNavigationProvider from '../../FormModalNavigationProvider'; -import pluginEn from '../../../translations/en.json'; -import getTrad from '../../../utils/getTrad'; import AttributeOptions from '../index'; const mockAttributes = [ @@ -30,62 +23,38 @@ const mockAttributes = [ ['component', 'dynamiczone'], ]; -const makeApp = () => { - const history = createMemoryHistory(); - const messages = { - en: Object.keys(pluginEn).reduce( - (acc, current) => { - acc[getTrad(current)] = pluginEn[current]; +const App = ( + + + + + + + +); - return acc; - }, - { ...en } - ), - }; - - const localeNames = { en: 'English' }; - - return ( - - - - - - - - - - - - ); -}; - -describe('AttributeOptions', () => { +describe('', () => { it('renders and matches the snapshot', () => { - const App = makeApp(); const { container } = render(App); expect(container).toMatchSnapshot(); }); - it('shows the simple tabs', async () => { - const App = makeApp(); + it('shows the simple tabs', () => { render(App); - const tabs = screen.getByLabelText('Attribute type tabs'); - const defaultTab = await getByText(tabs, 'Default'); - const customTab = await getByText(tabs, 'Custom'); + const defaultTab = screen.getByRole('tab', { selected: true }); + const customTab = screen.getByRole('tab', { selected: false }); expect(defaultTab).toBeVisible(); expect(customTab).toBeVisible(); }); - it('defaults to the default tab', async () => { - const App = makeApp(); + it('defaults to the default tab', () => { render(App); const comingSoonText = screen.queryByText('Coming soon'); @@ -93,17 +62,16 @@ describe('AttributeOptions', () => { expect(comingSoonText).toEqual(null); }); - it('switches to the custom tab', async () => { - const App = makeApp(); + it('switches to the custom tab', () => { render(App); const customTab = screen.getByRole('tab', { selected: false }); fireEvent.click(customTab); - const button = screen.getByRole('tab', { selected: true }); - const customTabActive = await getByText(button, 'Custom'); + const customTabSelected = screen.getByRole('tab', { selected: true }); + const customTabText = getByText(customTabSelected, 'Custom'); const comingSoonText = screen.getByText('Coming soon'); - expect(customTabActive).not.toBe(null); + expect(customTabText).not.toBe(null); expect(comingSoonText).toBeVisible(); }); });