Skip to content

Follow-up: harden buildVehiclePopupData tests and guard against null activeTrip #508

Description

@aaronbrethorst

Follow-up from PR #503, which added focused tests for buildVehiclePopupData (closing #501).

Two optional improvements were identified during review but are out of scope for that narrowly-scoped test PR:

  1. Source-asymmetry test. buildVehiclePopupData sources nextDestination from activeTrip.tripHeadsign while vehicleId/lastUpdateTime/predicted come from vehicle. The current tests exercise this mapping but use all-distinct values, so a future source-swap bug (e.g. nextDestination: vehicle.tripHeadsign) would only be caught incidentally. Add a test where vehicle and activeTrip share field names with different values, asserting each field resolves from the correct argument.

  2. Null activeTrip guard (code concern). buildVehiclePopupData assumes activeTrip, vehicle, and stopsMap are non-null. At the call sites (OpenStreetMapProvider.svelte.js and the Google equivalent), activeTrip comes from activeTripMap.get(...) and could in principle be undefined, in which case activeTrip.tripHeadsign throws. Consider adding a guard or documenting the precondition.

Neither is blocking; tracking here so they aren't lost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions