Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Stub floating-ui positioning in unit tests (#82493)

Nemanja Glumac2980fd7f2971
diff --git a/frontend/test/jest-setup-env.js b/frontend/test/jest-setup-env.js
index eb391e474f8..0f23b20d42d 100644
--- a/frontend/test/jest-setup-env.js
+++ b/frontend/test/jest-setup-env.js
@@ -2,6 +2,24 @@ import "@testing-library/jest-dom";
import { cleanup } from "@testing-library/react";
import fetchMock from "fetch-mock";
+// jsdom has no layout, so popover positioning computes nothing useful while
+// costing getComputedStyle calls and an extra re-render per position update.
+jest.mock("@floating-ui/dom", () => ({
+ ...jest.requireActual("@floating-ui/dom"),
+ computePosition: (_reference, _floating, options = {}) =>
+ Promise.resolve({
+ x: 0,
+ y: 0,
+ placement: options.placement ?? "bottom",
+ strategy: options.strategy ?? "absolute",
+ middlewareData: {},
+ }),
+ autoUpdate: (_reference, _floating, update) => {
+ update();
+ return () => {};
+ },
+}));
+
// Mock clipboard API for tests
Object.assign(navigator, {
clipboard: {