import { renderToStaticMarkup } from "react-dom/server"; import { describe, expect, it } from "vitest"; import { UserWorldMap } from "./user-world-map"; describe("UserWorldMap", () => { it("renders an accessible linked marker, text fallback, and open-data attribution", () => { const markup = renderToStaticMarkup(); expect(markup).toContain('role="group"'); expect(markup).toContain('class="map-marker-target"'); expect(markup).toContain("Latest approximate location for registered users"); expect(markup).toContain('href="/admin/users/11111111-1111-4111-8111-111111111111"'); expect(markup).toContain("Dani (Steve)"); expect(markup).toContain("Alex (AlexMC)"); expect(markup).toContain("2 users near Mountain View, California, US"); expect(markup).toMatch(/]*>2<\/text>/); expect(markup).toContain('
'); expect(markup).not.toContain('id="map-location-list" open'); expect(markup).toContain("Mountain View, California, US"); expect(markup).toContain("Comcast Cable Communications, LLC"); expect(markup).toContain("AS7922"); expect(markup).toContain("Residential"); expect(markup).toContain("Proton AG"); expect(markup).toContain(">Proxy/VPN<"); expect(markup).toContain(">Yes<"); expect(markup).toContain(">No<"); expect(markup).toContain("World overview"); expect(markup).toContain("Interactive OpenStreetMap"); expect(markup).toContain("OpenStreetMap, which receives your IP address"); expect(markup).toContain("map-marker-tooltip"); expect(markup).toContain('id="map-overview-panel"'); expect(markup).not.toContain("tile.openstreetmap.org"); expect(markup).toContain("Natural Earth, public domain"); expect(markup).toContain("2 without coordinates"); const countryPaths = [...markup.matchAll(/ match[1] ?? ""); expect(countryPaths.length).toBeGreaterThan(100); for (const path of countryPaths) { const subpaths = path.split("M").slice(1); for (const subpath of subpaths) { const xCoordinates = [...subpath.matchAll(/(?:^|L)(-?\d+(?:\.\d+)?),/g)].map((match) => Number(match[1])); for (let index = 1; index < xCoordinates.length; index += 1) { expect(Math.abs(xCoordinates[index]! - xCoordinates[index - 1]!)).toBeLessThan(500); } } } }); });