Files
qwen-code/packages/web-shell/client/components/ui/resizable.test.tsx
T
ytahdnand钉萁 df5470e430 feat(web-shell): Add workspace file browser and previews (#13878)
* feat(web-shell): Add workspace file browser and previews

* fix(web-shell): Restore source preview CI fixtures and notices

* fix(web-shell): Address file pane review blockers

* fix(web-shell): Resolve review regressions and strengthen file checks

---------

Co-authored-by: 钉萁 <[email protected]>
2026-10-13 09:38:47 +00:00

58 lines
1.8 KiB
TypeScript

// @vitest-environment jsdom
import { act, createRef, StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { Slot } from 'radix-ui';
import { expect, it, vi } from 'vitest';
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from './resizable';
it('forwards group, panel and slotted separator refs to DOM elements', async () => {
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true);
vi.stubGlobal(
'ResizeObserver',
class {
observe() {}
unobserve() {}
disconnect() {}
},
);
const container = document.createElement('div');
document.body.appendChild(container);
const root = createRoot(container);
const groupRef = createRef<HTMLDivElement>();
const panelRef = createRef<HTMLDivElement>();
const handleRef = createRef<HTMLDivElement>();
try {
await act(async () =>
root.render(
<StrictMode>
<ResizablePanelGroup ref={groupRef}>
<ResizablePanel ref={panelRef}>Preview</ResizablePanel>
<Slot.Root ref={handleRef}>
<ResizableHandle aria-label="Resize panes" />
</Slot.Root>
<ResizablePanel>Tree</ResizablePanel>
</ResizablePanelGroup>
</StrictMode>,
),
);
expect(groupRef.current).toBe(container.querySelector('[data-group]'));
expect(panelRef.current).toBe(container.querySelector('[data-panel]'));
expect(handleRef.current).toBe(
container.querySelector('[role="separator"]'),
);
expect(handleRef.current).toBeInstanceOf(HTMLDivElement);
act(() => root.unmount());
expect(groupRef.current).toBeNull();
expect(panelRef.current).toBeNull();
expect(handleRef.current).toBeNull();
} finally {
if (container.hasChildNodes()) act(() => root.unmount());
container.remove();
vi.unstubAllGlobals();
}
});