/
sdds
/
plasma
Обзор
Документация
Войти
/
sdds
/
plasma
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
dev
packages/plasma-web/src/components/TextArea/TextArea.component-test.tsx
188 строк
6 KB
Krivonos Aleksandr
feat: migrate TextArea tests to new-hope
19 мар 2026, 12:02
19 мар 2026, 12:02
b04df8e
Код
Авторство
О чём код?
import React from 'react'; import type { FC, PropsWithChildren } from 'react'; import { createGlobalStyle } from 'styled-components'; import { standard as standardTypo } from '@salutejs/plasma-typo'; import { mount, CypressTestDecorator, getComponent, SpaceMe, PadMe } from '@salutejs/plasma-cy-utils'; import { IconEye } from '@salutejs/plasma-icons'; const StandardTypoStyle = createGlobalStyle(standardTypo); describe('plasma-web: TextArea', () => { const TextArea = getComponent('TextArea'); const TextS = getComponent('TextS'); const CypressTestDecoratorWithTypo: FC<PropsWithChildren> = ({ children }) => ( <CypressTestDecorator> <StandardTypoStyle /> {children} </CypressTestDecorator> ); const propsDefault = { placeholder: 'Оставьте ваш комментарий [placeholder]', leftHelper: 'Максимум 300 символов', rightHelper: '125 слов', }; /* * INFO: Необходимо исключить эту ошибку, т.к. это проблема в Cypress: * https://github.com/cypress-io/cypress/issues/8418#issuecomment-992564877 */ beforeEach(() => { cy.on('uncaught:exception', (err) => { if (err.toString().match(/ResizeObserver loop limit exceeded/)) { return false; } }); }); it(':success, :warning, :error', () => { mount( <CypressTestDecoratorWithTypo> <TextArea value="Value" placeholder="Placeholder" helperText="Helper text" status="success" /> <SpaceMe /> <TextArea value="Value" placeholder="Placeholder" helperText="Helper text" status="warning" /> <SpaceMe /> <TextArea value="Value" placeholder="Placeholder" helperText="Helper text" status="error" /> </CypressTestDecoratorWithTypo>, ); cy.matchImageSnapshot(); }); it(':clear, :success, :warning, :error', () => { mount( <CypressTestDecoratorWithTypo> <TextArea value="Value" label="Placeholder" labelPlacement="inner" helperText="Helper text" status="success" appearance="clear" hasDivider /> <SpaceMe /> <TextArea placeholder="Placeholder" helperText="Helper text" status="warning" appearance="clear" hasDivider /> <SpaceMe /> <TextArea value="Value" placeholder="Placeholder" helperText="Helper text" status="error" appearance="clear" hasDivider /> </CypressTestDecoratorWithTypo>, ); cy.matchImageSnapshot(); }); it('_size :empty', () => { mount( <CypressTestDecoratorWithTypo> <TextArea size="xl" {...propsDefault} /> <SpaceMe /> <TextArea size="l" {...propsDefault} /> <SpaceMe /> <TextArea size="m" {...propsDefault} /> <SpaceMe /> <TextArea size="s" {...propsDefault} /> <SpaceMe /> <TextArea size="xs" {...propsDefault} /> </CypressTestDecoratorWithTypo>, ); cy.viewport(500, 812); cy.matchImageSnapshot(); }); it('_size', () => { const props = { value: 'Ваш сервис - пушка', ...propsDefault, }; mount( <CypressTestDecoratorWithTypo> <TextArea size="xl" {...props} /> <SpaceMe /> <TextArea size="l" {...props} /> <SpaceMe /> <TextArea size="m" {...props} /> <SpaceMe /> <TextArea size="s" {...props} /> <SpaceMe /> <TextArea size="xs" {...props} /> </CypressTestDecoratorWithTypo>, ); cy.viewport(500, 812); cy.matchImageSnapshot(); }); it('_size with content', () => { const props = { value: 'Ваш сервис - пушка', contentRight: <IconEye color="inherit" size="s" />, ...propsDefault, }; mount( <CypressTestDecoratorWithTypo> <TextArea size="xl" {...props} /> <SpaceMe /> <TextArea size="l" {...props} /> <SpaceMe /> <TextArea size="m" {...props} /> <SpaceMe /> <TextArea size="s" {...props} /> <SpaceMe /> <TextArea size="xs" {...props} /> </CypressTestDecoratorWithTypo>, ); cy.viewport(500, 812); cy.matchImageSnapshot(); }); describe('with hint', () => { const sizes = ['xs', 's', 'm', 'l', 'xl']; const cases = [{ labelPlacement: 'outer' }, { labelPlacement: 'inner' }]; sizes.forEach((size) => { it(`_size:${size}`, () => { mount( <CypressTestDecoratorWithTypo> {cases.map((props) => ( <div style={{ margin: '0 3rem' }}> <TextArea value="Value" placeholder="Placeholder" label="Title" size={size} height="2.5rem" hintText="Подсказка к полю" hintTrigger="click" {...props} /> <SpaceMe /> </div> ))} </CypressTestDecoratorWithTypo>, ); cy.get('.popover-wrapper').first().click(); cy.matchImageSnapshot(); }); }); }); });