Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(app): fix fetchWithToken test

synoetd157d690ee33
diff --git a/js/app/packages/core/util/fetchWithToken.spec.ts b/js/app/packages/core/util/fetchWithToken.spec.ts
index 3640f418e4..07e7fced8c 100644
--- a/js/app/packages/core/util/fetchWithToken.spec.ts
+++ b/js/app/packages/core/util/fetchWithToken.spec.ts
@@ -2,7 +2,15 @@
* @vitest-environment happy-dom
*/
-import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
+import {
+ afterEach,
+ beforeAll,
+ beforeEach,
+ describe,
+ expect,
+ test,
+ vi,
+} from 'vitest';
import { fetchWithToken, unsetTokenPromise } from './fetchWithToken';
import { err, ok } from './maybeResult';
@@ -26,6 +34,23 @@ describe('fetchWithToken', () => {
vi.clearAllMocks();
});
+ beforeAll(() => {
+ // Mock window.matchMedia for tests
+ Object.defineProperty(window, 'matchMedia', {
+ writable: true,
+ value: (query: string) => ({
+ matches: false,
+ media: query,
+ onchange: null,
+ addListener: () => {},
+ removeListener: () => {},
+ addEventListener: () => {},
+ removeEventListener: () => {},
+ dispatchEvent: () => true,
+ }),
+ });
+ });
+
test('successful request', async () => {
const result = await fetchWithToken<{ data: string }>(
'https://localhost/api/data'