Add PostgreSQL + BRouter to CI E2E tests

CI now runs the full stack for E2E tests:
- PostgreSQL as a service container + schema push via drizzle
- BRouter JAR + Berlin segment (E10_N50) with caching
- Both cached across runs (BRouter JAR + segment)

Removed all skip/workaround logic from tests — all 20 E2E tests
now run in CI with real services.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-03-24 23:58:01 +01:00
parent cd6f6a6f18
commit b71117e4ca
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
3 changed files with 73 additions and 58 deletions

View file

@ -2,38 +2,17 @@ import { test, expect } from "@playwright/test";
/**
* Integration tests that require the full dev stack:
* - PostgreSQL (for auth and routes)
* - PostgreSQL (for sessions)
* - BRouter (for route computation)
*
* Run with: pnpm dev:full (in another terminal), then pnpm test:e2e
* These tests are skipped in CI unless services are available.
* In CI, these services are started by the workflow.
* Locally, run `pnpm dev:full` first.
*/
const JOURNAL = "http://localhost:3000";
const PLANNER = "http://localhost:3001";
// Helper: check if DB is available (checks Planner API)
async function isDbAvailable(): Promise<boolean> {
try {
const resp = await fetch(`${PLANNER}/api/sessions`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({}),
});
return resp.ok; // 201 = DB available, 503 = DB unavailable
} catch {
return false;
}
}
test.describe("Integration: Journal ↔ Planner handoff", () => {
test.beforeAll(async () => {
const dbAvailable = await isDbAvailable();
test.skip(!dbAvailable, "Database not available — run pnpm dev:full");
});
test("GPX import → view route → export GPX", async ({ request }) => {
// This tests the API flow without needing WebAuthn
const gpx = `<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="test" xmlns="http://www.topografix.com/GPX/1/1">
<wpt lat="52.52" lon="13.405"><name>Berlin</name></wpt>
@ -45,7 +24,6 @@ test.describe("Integration: Journal ↔ Planner handoff", () => {
</trkseg></trk>
</gpx>`;
// Create a planner session with GPX
const sessionResp = await request.post(`${PLANNER}/api/sessions`, {
data: { gpx },
});
@ -57,25 +35,6 @@ test.describe("Integration: Journal ↔ Planner handoff", () => {
});
test.describe("Integration: BRouter routing", () => {
test.beforeAll(async () => {
try {
const resp = await fetch(`${PLANNER}/api/route`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
waypoints: [
{ lat: 52.516, lon: 13.377 },
{ lat: 52.515, lon: 13.351 },
],
profile: "trekking",
}),
});
test.skip(!resp.ok, "BRouter not available — start with pnpm dev:full");
} catch {
test.skip(true, "BRouter not available");
}
});
test("computes route between Berlin waypoints", async ({ request }) => {
const response = await request.post(`${PLANNER}/api/route`, {
data: {
@ -108,7 +67,6 @@ test.describe("Integration: BRouter routing", () => {
const geojson = await response.json();
const coords = geojson.features[0].geometry.coordinates;
// Route should pass near the middle waypoint (52.516, 13.377)
const nearMiddle = coords.some(
(c: number[]) =>
Math.abs(c[1] - 52.516) < 0.005 && Math.abs(c[0] - 13.377) < 0.005,

View file

@ -6,18 +6,6 @@ test.describe("Planner", () => {
await expect(page).toHaveTitle("trails.cool Planner");
await expect(page.getByText("Collaborative route planning")).toBeVisible();
});
});
// Tests that require PostgreSQL — skip in CI
test.describe("Planner (requires DB)", () => {
test.beforeEach(async ({ request }) => {
try {
const resp = await request.post("/api/sessions", { data: {} });
if (!resp.ok()) test.skip();
} catch {
test.skip();
}
});
test("can create a session via API", async ({ request }) => {
const response = await request.post("/api/sessions", { data: {} });