Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions dashboard/src/ui/VirtualList.dom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,29 @@ const MOUNT_CEILING = 250;
/**
* Give jsdom a viewport the virtualizer can measure.
*
* TanStack Virtual sizes the scroll element with `offsetWidth`/`offsetHeight`
* (`getRect` in `@tanstack/virtual-core`), which jsdom always reports as zero,
* not `clientHeight` or `getBoundingClientRect`. It also needs a
* `ResizeObserver` to exist on the window, which jsdom does not provide.
* TanStack Virtual sizes the scroll element with `clientWidth`/`clientHeight`
* from virtual-core 3.19.6 (`offsetWidth`/`offsetHeight` before), which jsdom
* always reports as zero, not `getBoundingClientRect`. Both pairs are stubbed
* so the helper holds across that change. It also needs a `ResizeObserver` to
* exist on the window, which jsdom does not provide.
*/
function installViewport(height: number, width = 900): () => void {
const names = ['offsetHeight', 'offsetWidth'] as const;
const sizes = {
offsetHeight: height,
clientHeight: height,
offsetWidth: width,
clientWidth: width,
} as const;
const names = Object.keys(sizes) as (keyof typeof sizes)[];
const saved = names.map(
(name) => [name, Object.getOwnPropertyDescriptor(HTMLElement.prototype, name)] as const,
);
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
configurable: true,
get: () => height,
});
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
configurable: true,
get: () => width,
});
for (const name of names) {
Object.defineProperty(HTMLElement.prototype, name, {
configurable: true,
get: () => sizes[name],
});
}

vi.stubGlobal(
'ResizeObserver',
Expand Down
3 changes: 3 additions & 0 deletions dashboard/src/workspaces/brain/BrainRegistryList.dom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ describe('Brain exact registry list', () => {
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue(DOMRect.fromRect({ width: 384, height: 80 }));
vi.spyOn(HTMLElement.prototype, 'offsetHeight', 'get').mockReturnValue(640);
vi.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(384);
// virtual-core 3.19.6 reads the scroll element's client size instead of offset size.
vi.spyOn(Element.prototype, 'clientHeight', 'get').mockReturnValue(640);
vi.spyOn(Element.prototype, 'clientWidth', 'get').mockReturnValue(384);
mount(150);
const list = await screen.findByLabelText('150 registered projects');
const mounted = within(list).queryAllByRole('button');
Expand Down
2 changes: 1 addition & 1 deletion plugin/chatgpt-extension/embedded/server.mjs

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading