/*
 * Copyright (c) 2023-2025 Datalayer, Inc.
 * Distributed under the terms of the Modified BSD License.
 */
// Test setup for unit tests
// Add any global test configuration here
// Define webpack globals that are expected by some dependencies
global.__webpack_public_path__ = '';
// Native FormData and fetch should work in Node.js 20+
// Define other globals that might be needed
global.global = globalThis;
// Mock DragEvent and other DOM APIs not available in jsdom
class MockDragEvent extends Event {
    dataTransfer = null;
    constructor(type, init) {
        super(type, init);
        this.dataTransfer = init?.dataTransfer || null;
    }
}
// Mock DataTransfer if not available
class MockDataTransfer {
    dropEffect = 'none';
    effectAllowed = 'uninitialized';
    files = [];
    items = [];
    types = [];
    clearData(format) { }
    getData(format) {
        return '';
    }
    setData(format, data) { }
    setDragImage(image, x, y) { }
}
// Add missing DOM APIs to global scope
global.DragEvent = MockDragEvent;
global.DataTransfer = MockDataTransfer;
// Mock window.matchMedia
Object.defineProperty(window, 'matchMedia', {
    writable: true,
    value: (query) => ({
        matches: false,
        media: query,
        onchange: null,
        addListener: () => { }, // deprecated
        removeListener: () => { }, // deprecated
        addEventListener: () => { },
        removeEventListener: () => { },
        dispatchEvent: () => { },
    }),
});
// Mock Jupyter-related modules to prevent import errors
import { vi } from 'vitest';
vi.mock('@datalayer/jupyter-react', () => ({
    useJupyter: () => ({
        defaultKernel: null,
        serviceManager: null,
    }),
    JupyterReactTheme: ({ children }) => children,
    CollaborationProviderBase: class CollaborationProviderBase {
    },
    CollaborationStatus: {
        IDLE: 'idle',
        CONNECTING: 'connecting',
        CONNECTED: 'connected',
        DISCONNECTED: 'disconnected',
    },
}));
vi.mock('@jupyter/web-components', () => ({}));
vi.mock('@jupyter/ydoc', () => ({
    YNotebook: class YNotebook {
    },
}));
vi.mock('y-websocket', () => ({
    WebsocketProvider: class WebsocketProvider {
        constructor() { }
        connect() { }
        disconnect() { }
        destroy() { }
    },
}));
