pierrejeambrun commented on code in PR #60591:
URL: https://github.com/apache/airflow/pull/60591#discussion_r2789018722


##########
airflow-core/src/airflow/ui/testsSetup.ts:
##########
@@ -17,13 +17,43 @@
  * under the License.
  */
 import "@testing-library/jest-dom/vitest";
+import axios from "axios";
+import httpAdapter from "axios/lib/adapters/http.js";
 import { cleanup } from "@testing-library/react";
 import type { HttpHandler } from "msw";
 import { setupServer, type SetupServerApi } from "msw/node";
 import { beforeEach, beforeAll, afterAll, afterEach, vi } from "vitest";
 
 import { handlers } from "src/mocks/handlers";
 
+// Ensure MSW can intercept axios requests in the happy-dom environment.
+// Axios picks the XHR adapter in browser-like environments; switch to http.
+axios.defaults.adapter = httpAdapter;
+
+const createLocalStorage = () => {
+  const store = new Map<string, string>();
+
+  return {
+    clear: () => store.clear(),
+    getItem: (key: string) => store.get(key) ?? null,
+    key: (index: number) => Array.from(store.keys())[index] ?? null,
+    removeItem: (key: string) => {
+      store.delete(key);
+    },
+    setItem: (key: string, value: string) => {
+      store.set(key, value);
+    },
+    get length() {
+      return store.size;
+    },
+  };
+};
+
+Object.defineProperty(globalThis, "localStorage", {
+  configurable: true,
+  value: createLocalStorage(),
+});
+

Review Comment:
   Not addressed 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to