mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-11-07 06:19:43 -10:00
* 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]>
58 lines
1.8 KiB
TypeScript
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();
|
|
}
|
|
});
|