Skip to content

Improve Fleet-Ops server test coverage - #277

Draft
roncodes wants to merge 536 commits into
mainfrom
feature/fleetops-server-coverage-100
Draft

Improve Fleet-Ops server test coverage#277
roncodes wants to merge 536 commits into
mainfrom
feature/fleetops-server-coverage-100

Conversation

@roncodes

@roncodes roncodes commented Jul 19, 2026

Copy link
Copy Markdown
Member

Summary

This is a progressive backend-only coverage PR for Fleet-Ops ./server.

  • Wires backend coverage reporting into the Composer workflow with a 100% fail-under gate.
  • Expands categorized server tests under server/tests/Unit/... and server/tests/Feature/... instead of adding more flat root-level coverage files.
  • Adds coverage for exports, imports, value objects, events, exceptions, registries, analytics options, mail, notifications, provider registration contracts, driver model helpers, internal driver controller helpers, and LiveController operations monitor snapshot behavior.
  • Extends the shared test bootstrap with additive shims so controller error branches (response()->apiError(...)) and job dispatch branches (Job::dispatch/dispatchIf) are reachable under test — previously these fatally errored and structurally blocked coverage on nearly every controller.
  • Covers the API DriverController protected helper methods, the self-contained route/order driving-simulation methods (no-route and successful-dispatch branches), and the driver-lookup/organization not-found error branches via an in-memory SQLite fixture.

Latest Local Coverage

Fresh host run from COMPOSER_PROCESS_TIMEOUT=0 composer coverage:baseline:

Metric Coverage Covered / Total
Lines 94.32% 32,155 / 34,090 statements
Methods 82.10% 3,564 / 4,341 methods
Classes 43.39% 246 / 567 classes

Coverage gate verification:

  • php scripts/coverage-summary.php coverage/clover.xml --fail-under=100 correctly fails while coverage is below 100%.
  • The fail-under gate remains red by design until backend line coverage reaches 100%.

Latest Progress

  • Structural blockers resolved via injectability refactors (option 2): the geometry engine now resolves through Brick's GeometryEngineRegistry (GEOS fallback preserved), the geocoder accepts a container-bound client (fleetops.geocoder), and all TIMESTAMPDIFF/NOW()/LEAST raw SQL goes through new driver-aware Utils::sql* helpers — a real portability win (analytics now run on sqlite).
  • Auth::can permission gates are now covered for real with seeded spatie permissions — UpdateDriverRequest::authorize and driver-ping authorization included, retiring the oldest documented blocker.
  • Zone/ServiceArea centroid and location accessors, Place::createFromReverseGeocodingLookup, PlaceSearch google branches, and the on-time/top-driver analytics are all newly covered.

Validation

Run on the host runtime (asdf PHP 8.4 with Xdebug, XDEBUG_MODE=coverage), no Docker:

  • php -l server/tests/Feature/Http/Api/DriverControllerHelpersTest.php
  • php scripts/pest-runner.php server/tests/Feature/Http/Api/DriverControllerHelpersTest.php
  • vendor/bin/php-cs-fixer fix --using-cache=no --sequential server/tests/Feature/Http/Api/DriverControllerHelpersTest.php scripts/pest-bootstrap.php
  • composer test:lint
  • composer test:unit
  • COMPOSER_PROCESS_TIMEOUT=0 composer coverage:baseline
  • php scripts/coverage-summary.php coverage/clover.xml --fail-under=100
  • git diff --check
  • git diff --cached --check

Current Lowest Coverage Targets

Next backend coverage slices, from the fresh local Clover report:

File Coverage
server/src/Support/Analytics/OnTimeDelivery.php 58.33%
server/src/Support/ResolvesOrderServiceStops.php 62.64%
server/src/Http/Controllers/Internal/v1/LiveController.php 62.73%
server/src/Support/Ai/Capabilities/OperationalQueryCapability.php 63.43%
server/src/Http/Controllers/Internal/v1/SearchController.php 64.26%

Notes

  • This PR is intentionally still progressive and remains below the 100% final target.
  • Local validation is run before every push so broken test slices are not published.
  • Coverage work is pushed in batches of a few validated commits so progress is not stranded locally.
  • The largest remaining uncovered surfaces are the big API/Internal Order and Driver controllers; many of their error/dispatch branches are now reachable thanks to the bootstrap shim additions.

roncodes and others added 30 commits July 29, 2026 01:44
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant