Add GPS trip reports and route maps

This commit is contained in:
2026-08-01 00:56:19 +02:00
parent cb0ac06091
commit e501895e56
12 changed files with 817 additions and 21 deletions
+12
View File
@@ -357,6 +357,7 @@ describe("authentication boundary", () => {
expect((await app.inject({ method: "GET", url: "/api/mobile/devices" })).statusCode).toBe(401);
expect((await app.inject({ method: "GET", url: "/api/mobile/bluetooth" })).statusCode).toBe(401);
expect((await app.inject({ method: "GET", url: "/api/trips" })).statusCode).toBe(401);
const bluetooth = await app.inject({ method: "GET", url: "/api/mobile/bluetooth", headers: { cookie } });
expect(bluetooth.statusCode).toBe(200);
expect(bluetooth.json()).toMatchObject({ powered: expect.any(Boolean), discoverable: expect.any(Boolean) });
@@ -407,6 +408,17 @@ describe("authentication boundary", () => {
shortcuts: []
});
const trips = await app.inject({ method: "GET", url: "/api/trips", headers: { cookie } });
expect(trips.statusCode).toBe(200);
const trip = trips.json<{ trips: Array<{ id: number; peakSpeedKph: number; pointCount: number }> }>().trips[0];
expect(trip).toMatchObject({ peakSpeedKph: 42.5, pointCount: 1 });
const tripDetail = await app.inject({ method: "GET", url: `/api/trips/${trip!.id}`, headers: { cookie } });
expect(tripDetail.statusCode).toBe(200);
expect(tripDetail.json()).toMatchObject({
points: [expect.objectContaining({ latitude: 55.6761, longitude: 12.5683 })],
pins: expect.arrayContaining([expect.objectContaining({ type: "peak-speed", speedKph: 42.5 })])
});
const devices = await app.inject({ method: "GET", url: "/api/mobile/devices", headers: { cookie } });
expect(devices.json()).toMatchObject({ devices: [{ id: deviceId, name: "Owner phone", revokedAt: null }] });
expect((await app.inject({ method: "DELETE", url: `/api/mobile/devices/${deviceId}`, headers: webHeaders })).statusCode).toBe(204);