mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
6c7e7b7df4
Pins ^4.12.2 and wraps its Group/Panel/Separator API behind two styled handles: an 8px gutter for the gap between cards and a 1px hairline. 4.x rather than the 2.x/3.x used by six sibling examples because only 4.x accepts PIXEL size constraints, and the layout's bounds are pixels. Three v4 behaviours the consumers depend on, each with a test: - The API is RENAMED from 2.x/3.x: PanelGroup->Group, direction->orientation, PanelResizeHandle->Separator, autoSaveId->useDefaultLayout. Most material online, including shadcn's Resizable block, targets the old names and will not compile. - data-testid is DERIVED from a Panel's id and overwrites any passed in, so a panel's id is its query handle. Getting this wrong makes every [data-testid$='-panel'] query silently match nothing. - Separator refuses flex-grow/flex-shrink overrides, so shrink-0 would be dead. Adds a jsdom ResizeObserver stub, without which every test rendering a Group throws. Note for anyone adding a dependency here: declare it in package.json and run 'pnpm install --lockfile-only' from the REPO ROOT. This example pins pnpm 10.10.0 while the root pins 10.33.4, so 'pnpm add' from this directory makes corepack switch versions and the older pnpm re-resolves the entire workspace lockfile.
16 lines
430 B
TypeScript
16 lines
430 B
TypeScript
/**
|
|
* jsdom implements no layout, so it ships no ResizeObserver. react-resizable-panels
|
|
* constructs one on mount, so without this stub every test that renders a Group
|
|
* throws "ResizeObserver is not defined".
|
|
*/
|
|
class ResizeObserverStub {
|
|
observe() {}
|
|
unobserve() {}
|
|
disconnect() {}
|
|
}
|
|
|
|
if (!("ResizeObserver" in globalThis)) {
|
|
globalThis.ResizeObserver =
|
|
ResizeObserverStub as unknown as typeof ResizeObserver;
|
|
}
|