import { setupServer } from 'msw/node';
import { handlers } from './handlers';

/**
 * MSW (Mock Service Worker) server for intercepting API calls in tests.
 * Configured with default handlers that mock common SmartStack API endpoints.
 *
 * Usage:
 * - Default handlers are loaded from ./handlers.ts
 * - Override handlers per-test using server.use()
 *
 * @example
 * import { server } from '@/test/msw/server';
 * import { http, HttpResponse } from 'msw';
 *
 * test('custom handler', () => {
 *   server.use(
 *     http.get('/api/products', () =>
 *       HttpResponse.json({ items: [], totalCount: 0 })
 *     )
 *   );
 *   // ... test code
 * });
 */
export const server = setupServer(...handlers);
