Fix overnight E2E test: use nearby waypoints, scope locators to sidebar

The test used waypoints 300km apart causing BRouter timeouts. Switched
to nearby Berlin waypoints for fast route computation. Scoped all
locators to the sidebar to avoid strict mode violations from map
elements matching the same text.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-04-11 01:02:02 +02:00
parent b6bca0229b
commit f90571fc2c
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9

View file

@ -240,29 +240,29 @@ test.describe("Planner", () => {
const sessionResp = await request.post("/api/sessions", { data: {} }); const sessionResp = await request.post("/api/sessions", { data: {} });
const { url } = await sessionResp.json(); const { url } = await sessionResp.json();
// Create session with 3 waypoints // Create session with 3 nearby waypoints (short route for fast BRouter response)
await page.goto(`${url}?waypoints=${encodeURIComponent(JSON.stringify([ await page.goto(`${url}?waypoints=${encodeURIComponent(JSON.stringify([
{ lat: 52.520, lon: 13.405 }, { lat: 52.520, lon: 13.405 },
{ lat: 51.840, lon: 12.243 }, { lat: 52.516, lon: 13.377 },
{ lat: 50.980, lon: 11.028 }, { lat: 52.510, lon: 13.390 },
]))}`); ]))}`);
await expect(page.locator(".leaflet-container")).toBeVisible({ timeout: 10000 }); await expect(page.locator(".leaflet-container")).toBeVisible({ timeout: 10000 });
await expect(page.getByText("Connected")).toBeVisible({ timeout: 15000 }); await expect(page.getByText("Connected")).toBeVisible({ timeout: 15000 });
await expect(page.getByText("Waypoints (3)")).toBeVisible({ timeout: 5000 }); await expect(page.getByText("Waypoints (3)")).toBeVisible({ timeout: 5000 });
// Wait for route to compute — match the header summary which has "km ·" // Wait for route to compute — the header summary shows distance
await expect(page.getByText(/\d+\.\d+ km ·/)).toBeVisible({ timeout: 20000 }); const sidebar = page.locator("aside");
await expect(sidebar.getByText(/\d+\.\d+ km/)).toBeVisible({ timeout: 20000 });
// Hover waypoint 2 to reveal controls, click the overnight toggle (moon icon) // Hover waypoint 2 to reveal controls, click the overnight toggle (moon icon)
const waypointRows = page.locator("li").filter({ has: page.locator("span.rounded-full") }); const waypointRows = sidebar.locator("li").filter({ has: page.locator("span.rounded-full") });
const secondRow = waypointRows.nth(1); const secondRow = waypointRows.nth(1);
await secondRow.hover(); await secondRow.hover();
const moonButton = secondRow.getByTitle(/overnight/i); const moonButton = secondRow.getByTitle(/overnight/i);
await moonButton.click(); await moonButton.click();
// Day breakdown should appear in the sidebar // Day breakdown should appear in the sidebar
const sidebar = page.locator("aside");
await expect(sidebar.getByText("Day 1")).toBeVisible({ timeout: 5000 }); await expect(sidebar.getByText("Day 1")).toBeVisible({ timeout: 5000 });
await expect(sidebar.getByText("Day 2")).toBeVisible({ timeout: 5000 }); await expect(sidebar.getByText("Day 2")).toBeVisible({ timeout: 5000 });
}); });