diff --git a/tests/ui/maps.spec.js b/tests/ui/maps.spec.js index 16bcc61..615e768 100644 --- a/tests/ui/maps.spec.js +++ b/tests/ui/maps.spec.js @@ -100,3 +100,28 @@ test('M7: clicking map marker briefly highlights the corresponding entry card', // Within 500ms of click + delay, one journal-post should have is-highlighted await expect(page.locator('.journal-post.is-highlighted')).toBeVisible({ timeout: 1500 }); }); + +// ── M8: Home map has GPX journey source on active trip ──────────────────────── +test('M8: home map has a journey source after GPX settles (active trip)', async ({ page }) => { + // Requires travelling: true in user/config/site.yaml (set in Task 1). + // Requires GPX files attached to the active trip (italy-2026-demo has 7). + const errors = []; + page.on('pageerror', e => errors.push(e.message)); + + await page.goto('/'); + await expect(page.locator('#home-map canvas.maplibregl-canvas')).toBeVisible({ timeout: 10000 }); + await expect(page.locator('#home-map .maplibregl-marker').first()).toBeVisible({ timeout: 15000 }); + + await page.waitForFunction(function () { + return window.homeMap && + (window.homeMap.getSource('home-journey') !== undefined || + window.homeMap.getSource('home-gpx-0') !== undefined); + }, { timeout: 20000 }); + + const hasSource = await page.evaluate(function () { + return !!(window.homeMap.getSource('home-journey') || window.homeMap.getSource('home-gpx-0')); + }); + + expect(hasSource, 'Home map has a journey or GPX source').toBe(true); + expect(errors, 'No JS errors on home page').toHaveLength(0); +});