import type { PropsWithChildren } from 'react'; import React, { useEffect } from 'react'; import { render } from '@testing-library/react'; import type { ImageProps, MenuProps } from 'antd'; import { AutoComplete, Cascader, ColorPicker, DatePicker, Drawer, Dropdown, Image, Menu, Modal, Popconfirm, Popover, Select, Tooltip, Tour, TreeSelect, } from 'antd'; import { waitFakeTimer } from '../../../tests/utils'; import type { ZIndexConsumer, ZIndexContainer } from '../hooks/useZIndex'; import { consumerBaseZIndexOffset, containerBaseZIndexOffset, useZIndex } from '../hooks/useZIndex'; import zIndexContext from '../zindexContext'; const WrapWithProvider: React.FC> = ({ children, containerType, }) => { const [, contextZIndex] = useZIndex(containerType); return {children}; }; const containerComponent: Record< ZIndexContainer, React.FC> > = { Modal: ({ children, ...restProps }) => ( {children} ), Drawer: ({ children, ...restProps }) => ( {children} ), Popover: ({ children, ...restProps }) => ( {children} ), Popconfirm: ({ children, ...restProps }) => ( {children} ), Tooltip: ({ children, ...restProps }) => ( {children} ), Tour: ({ children, ...restProps }) => ( ), }; const options = [ { label: 'Option 1', value: '1', }, { label: 'Option 2', value: '2', }, ]; const items: MenuProps['items'] = [ { label: 'Test', key: 'SubMenu', children: [ { type: 'group', label: 'Item 1', children: [ { label: 'Option 1', key: 'setting:1', }, { label: 'Option 2', key: 'setting:2', }, ], }, { type: 'group', label: 'Item 2', children: [ { label: 'Option 3', key: 'setting:3', }, { label: 'Option 4', key: 'setting:4', }, ], }, ], }, ]; const consumerComponent: Record> = { SelectLike: ({ rootClassName, ...props }) => ( <> , }); await waitFakeTimer(); expect(document.querySelector('.ant-modal-wrap')).toHaveStyle({ zIndex: '2000', }); expect(document.querySelector('.ant-select-dropdown')).toHaveStyle({ zIndex: '2050', }); instance.destroy(); await waitFakeTimer(); // Clean up for static method document.body.innerHTML = ''; jest.useRealTimers(); }); });