From c46fd304468fa2605fe3816ffc464afacb4e91ba Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Wed, 7 May 2025 17:07:56 +0530 Subject: [PATCH] Fix JS test cases failing because of latest version of @tanstack/react-virtual. --- web/regression/javascript/setup-jest.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/web/regression/javascript/setup-jest.js b/web/regression/javascript/setup-jest.js index 736df3fbb..ee2825e48 100644 --- a/web/regression/javascript/setup-jest.js +++ b/web/regression/javascript/setup-jest.js @@ -66,21 +66,7 @@ document.createRange = () => { return range; }; -// for virtual tables, height should exist. Element.prototype.getBoundingClientRect = jest.fn(function () { - if (this.classList?.contains('pgrt')) { - return { - width: 400, - height: 400, - top: 0, - left: 0, - bottom: 0, - right: 0, - x: 0, - y: 0, - toJSON: () => {}, - }; - } return { width: 0, height: 0, @@ -94,6 +80,16 @@ Element.prototype.getBoundingClientRect = jest.fn(function () { }; }); + +// for virtual tables, height and width should exist. +// https://github.com/TanStack/virtual/issues/641#issuecomment-2851908893 +Object.defineProperty(HTMLElement.prototype, 'offsetHeight', { + value: 800 +}); +Object.defineProperty(HTMLElement.prototype, 'offsetWidth', { + value: 800 +}); + Object.defineProperty(global.SVGElement.prototype, 'getBBox', { writable: true, value: jest.fn().mockReturnValue({