// FE-ADMIN-DUS-001 to FE-ADMIN-DUS-027 import { render, screen, waitFor, within, fireEvent } from '../../../tests/helpers/render'; import userEvent from '@testing-library/user-event'; import { http, HttpResponse } from 'msw'; import { server } from '../../../tests/helpers/msw/server'; import { resetAllStores, seedStore } from '../../../tests/helpers/store'; import { buildAdmin } from '../../../tests/helpers/factories'; import { useAuthStore } from '../../store/authStore'; import { ToastContainer } from '../shared/Toast'; import DefaultUserSettingsTab from './DefaultUserSettingsTab'; // The tile preview would pull Leaflet into jsdom; the panel only needs it to render. vi.mock('../Map/MapView', () => ({ MapView: ({ tileUrl }: { tileUrl?: string }) =>
, })); const MAPBOX_STANDARD = 'mapbox://styles/mapbox/standard'; const MAPBOX_DARK = 'mapbox://styles/mapbox/dark-v11'; const MAPBOX_NAV_NIGHT = 'mapbox://styles/mapbox/navigation-night-v1'; const OFM_LIBERTY = 'https://tiles.openfreemap.org/styles/liberty'; const TILE_PLACEHOLDER = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'; /** Stateful stand-in for the admin defaults endpoint: PUT merges, null deletes. */ function stubDefaults(initial: Record = {}) { const state: Record = { ...initial }; const puts: Record[] = []; server.use( http.get('/api/admin/default-user-settings', () => HttpResponse.json(state)), http.put('/api/admin/default-user-settings', async ({ request }) => { const body = await request.json() as Record; puts.push(body); for (const [key, value] of Object.entries(body)) { if (value === null) delete state[key]; else state[key] = value; } return HttpResponse.json({ ...state }); }), ); return { puts, state }; } function withToast() { return render(<>); } /** The selected option button is the one drawn with the strong border token. */ function isActive(button: HTMLElement): boolean { return (button.style.border || '').includes('var(--text-primary)'); } /** * The reset link sits inside the field's own