test: fix M2 timing — wait for first marker before counting

Markers are added in map.on('load') which fires after the canvas
becomes visible; the old check was racy. Add an explicit waitFor
so M2 reliably passes with demo data loaded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vgmzx8VTTTmCskSpQtsLTr
This commit is contained in:
2026-06-19 23:17:05 +02:00
parent 6c378d77ca
commit 3fbba7672d
+2 -1
View File
@@ -17,7 +17,8 @@ test('M1: /map page renders MapLibre GL canvas without JS errors', async ({ page
test('M2: /map page has at least one dot marker', async ({ page }) => { test('M2: /map page has at least one dot marker', async ({ page }) => {
await page.goto('/trips/japan-korea-2026/map'); await page.goto('/trips/japan-korea-2026/map');
await expect(page.locator('canvas.maplibregl-canvas')).toBeVisible({ timeout: 10000 }); await expect(page.locator('canvas.maplibregl-canvas')).toBeVisible({ timeout: 10000 });
// Custom DOM markers are rendered as .maplibregl-marker elements // Markers are added in map.on('load') — wait for first to appear in the DOM
await expect(page.locator('.maplibregl-marker').first()).toBeVisible({ timeout: 15000 });
const markerCount = await page.locator('.maplibregl-marker').count(); const markerCount = await page.locator('.maplibregl-marker').count();
expect(markerCount, 'At least one marker present').toBeGreaterThan(0); expect(markerCount, 'At least one marker present').toBeGreaterThan(0);
}); });