Extract duration helper + add distance/duration tests (audit H5) #4

Merged
ronnyandre merged 1 commit from test/duration-distance-coverage into fix/audit-quick-wins 2026-06-02 23:26:40 +02:00
Owner

Stacks on #3. Starts working through docs/audit-2026-06.md at H5 (test coverage).

Refactor

  • New src/lib/duration.ts (durationMinutesBetween) extracts the fromZonedTime duration math that was duplicated in flights.ts and import-fr24.ts; both call sites now share it with their existing null/fallback behavior preserved.
  • Fixes a latent bug: an unparseable date previously produced NaN and could be stored as the duration — now returns null.

Tests (suite 23 → 40)

  • duration.test.ts: same-tz, cross-tz westbound, overnight with/without arrDate, DST spring-forward (Oslo 01:30→03:30 = 60 real min), and missing/invalid-tz/invalid-date null cases.
  • distance.test.ts: degree distances, symmetry, JFK→LHR ≈ 5540 km, antipodal, kmToMiles.

Still open under H5: dashboard aggregation and the ICAO-over-IATA path (need pure-reducer extraction or a test-DB harness).

Verified: pnpm typecheck, pnpm lint, pnpm test (40/40) all pass.

Note: base is fix/audit-quick-wins; retarget to main once #3 merges.

Stacks on #3. Starts working through `docs/audit-2026-06.md` at **H5 (test coverage)**. **Refactor** - New `src/lib/duration.ts` (`durationMinutesBetween`) extracts the `fromZonedTime` duration math that was duplicated in `flights.ts` and `import-fr24.ts`; both call sites now share it with their existing null/fallback behavior preserved. - Fixes a latent bug: an unparseable date previously produced `NaN` and could be stored as the duration — now returns `null`. **Tests** (suite 23 → 40) - `duration.test.ts`: same-tz, cross-tz westbound, overnight with/without `arrDate`, DST spring-forward (Oslo 01:30→03:30 = 60 real min), and missing/invalid-tz/invalid-date null cases. - `distance.test.ts`: degree distances, symmetry, JFK→LHR ≈ 5540 km, antipodal, `kmToMiles`. **Still open under H5:** dashboard aggregation and the ICAO-over-IATA path (need pure-reducer extraction or a test-DB harness). Verified: `pnpm typecheck`, `pnpm lint`, `pnpm test` (40/40) all pass. > Note: base is `fix/audit-quick-wins`; retarget to `main` once #3 merges.
- Extract the fromZonedTime duration math (duplicated in flights.ts and
  import-fr24.ts) into src/lib/duration.ts (durationMinutesBetween); both
  call sites now share it, preserving their existing null/fallback behavior
- Fix latent bug: an unparseable date previously yielded NaN and could be
  stored as the duration; now returns null
- Add duration.test.ts: same-tz, cross-tz westbound, overnight with/without
  arrDate, DST spring-forward, and missing/invalid-input null cases
- Add distance.test.ts for haversineKm and kmToMiles
- Suite grows 23 -> 40 tests; update docs/audit-2026-06.md H5 status

Stacks on fix/audit-quick-wins (PR #3).
ronnyandre merged commit ecec3d937b into fix/audit-quick-wins 2026-06-02 23:26:40 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ronnyandre/fliary!4
No description provided.