Skip to content

Commit

Permalink
feat(plasma-{b2c, web}): portal prop test added
Browse files Browse the repository at this point in the history
  • Loading branch information
denivladislav committed Aug 9, 2024
1 parent 1d2d2e9 commit 6f37f67
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import type { FC, PropsWithChildren } from 'react';
import { useRef } from 'react';
import { createGlobalStyle } from 'styled-components';
import { standard as standardTypo } from '@salutejs/plasma-typo';
import { mount, CypressTestDecorator, getComponent } from '@salutejs/plasma-cy-utils';
Expand Down Expand Up @@ -69,6 +70,16 @@ describe('plasma-b2c: Autocomplete', () => {
</CypressTestDecorator>
);

function DemoWithPortal() {
const portalRef = useRef(null);

return (
<div id="parentId" ref={portalRef}>
<Autocomplete label="Label" leftHelper="Helper Text" suggestions={suggestions} portal={portalRef} />
</div>
);
}

it('default', () => {
cy.viewport(1000, 500);

Expand Down Expand Up @@ -449,6 +460,17 @@ describe('plasma-b2c: Autocomplete', () => {
cy.get('.popover-root').should('be.visible');
});

it('prop: portal', () => {
mount(
<CypressTestDecoratorWithTypo>
<DemoWithPortal />
</CypressTestDecoratorWithTypo>,
);

// Проверяем, что Popover лежит выше в DOM, чем без portal
cy.get('[id=parentId] > div').eq(1).find('div').and('have.class', 'popover-root');
});

it('keyboard interactions', () => {
cy.viewport(1000, 500);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import type { FC, PropsWithChildren } from 'react';
import { useRef } from 'react';
import { createGlobalStyle } from 'styled-components';
import { standard as standardTypo } from '@salutejs/plasma-typo';
import { mount, CypressTestDecorator, getComponent } from '@salutejs/plasma-cy-utils';
Expand Down Expand Up @@ -69,6 +70,16 @@ describe('plasma-web: Autocomplete', () => {
</CypressTestDecorator>
);

function DemoWithPortal() {
const portalRef = useRef(null);

return (
<div id="parentId" ref={portalRef}>
<Autocomplete label="Label" leftHelper="Helper Text" suggestions={suggestions} portal={portalRef} />
</div>
);
}

it('default', () => {
cy.viewport(1000, 500);

Expand Down Expand Up @@ -449,6 +460,17 @@ describe('plasma-web: Autocomplete', () => {
cy.get('.popover-root').should('be.visible');
});

it('prop: portal', () => {
mount(
<CypressTestDecoratorWithTypo>
<DemoWithPortal />
</CypressTestDecoratorWithTypo>,
);

// Проверяем, что Popover лежит выше в DOM, чем без portal
cy.get('[id=parentId] > div').eq(1).find('div').and('have.class', 'popover-root');
});

it('keyboard interactions', () => {
cy.viewport(1000, 500);

Expand Down

0 comments on commit 6f37f67

Please sign in to comment.