diff --git a/web/src/pages/org/depts/DeptsPage.test.tsx b/web/src/pages/org/depts/DeptsPage.test.tsx index 7a5cf518..6cd37c83 100644 --- a/web/src/pages/org/depts/DeptsPage.test.tsx +++ b/web/src/pages/org/depts/DeptsPage.test.tsx @@ -1,7 +1,7 @@ import '@douyinfe/semi-ui/react19-adapter'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { render, screen, within } from '@testing-library/react'; +import { render, screen, waitFor, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { MemoryRouter } from 'react-router'; import { afterEach, describe, expect, it } from 'vitest'; @@ -63,6 +63,15 @@ describe('DeptsPage', () => { await userEvent.click(within(row as HTMLElement).getByRole('button', { name: '更多' })); const remove = await screen.findByText('删除'); expect(remove.closest('[aria-disabled="true"]')).not.toBeNull(); + // 浮层「插入 → 定位 → 可见」靠 insertPortal 的 100ms 安全网定时器推进(jsdom 无布局、 + // ResizeObserver 空桩);链路未走完就结束测试,卸载后挂起定时器仍触发,偶发抛 unhandled + // error(CI 记录 nodeType of null)。aria-expanded 是链路最末端信号,等到它即耗尽挂起定时器。 + await waitFor(() => { + expect(within(row as HTMLElement).getByRole('button', { name: '更多' })).toHaveAttribute( + 'aria-expanded', + 'true', + ); + }); }); it('hides write controls for view-only accounts', async () => {