Skip to content

v1.6.55 Expand Core API backend test coverage baseline#231

Open
roncodes wants to merge 300 commits into
mainfrom
dev-v1.6.55
Open

v1.6.55 Expand Core API backend test coverage baseline#231
roncodes wants to merge 300 commits into
mainfrom
dev-v1.6.55

Conversation

@roncodes

@roncodes roncodes commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

Continues the Core API backend coverage growth work for v1.6.55.

This branch expands Pest coverage across critical auth, organization, settings, report, middleware, filter, model, support, command, webhook, template, search, scheduling, provider, chat, cache, resource, file upload/download, image processing, SMS, database export, casts, request expansion, and authorization trait contracts. Production changes remain limited to fixes proven by executable tests.

Latest Coverage

  • Line coverage: 92.24% (18487 / 20043 statements)
  • Method coverage: 80.06% (2060 / 2573 methods)
  • Fully covered class coverage: 62.34% (245 / 393 classes, derived from class statement metrics because Clover omits coveredclasses)
  • Touched class coverage: 100.00% (393 / 393 classes executed at least once)

The earlier 0.00% class coverage reading was a summary/reporting issue. Clover does not emit an aggregate coveredclasses metric in this setup, so the summary now separates strict fully-covered classes from touched classes.

Coverage Added

  • Auth login, bootstrap, organization switching, verification, SMS verification send, password reset, password-reset throttling and stale-code cleanup, password change, impersonation, end-impersonation cleanup, and generic credential error contracts.
  • Google identity verifier success, falsey payload, exception logging, and debug HTTP relaxation contracts without live network calls.
  • Organization administration, 2FA settings, extension listing, public/invite lookup, user listing search/pagination, scoped update/delete failures, ownership transfer, member activation/deactivation/removal, invite, and leave-organization contracts.
  • Settings endpoint contracts for branding, filesystem, mail, queue, services, notification channels, platform API token rotation/revocation, external provider probes, admin overview counts, file-backed GCS/APN/Firebase metadata, APN/FCM credential-file persistence, and config-cache failure logging.
  • Report query validation, execution, export, download, audit log, resource, saved report, template query, validator exception wrapping, timeout responses, saved-report validation failures, saved export failure responses, and ExecuteReportQueryRequest custom validation message contracts.
  • ReportQueryConverter export success/failure paths, available export formats, structural query analysis, session company resolution from object and array values, remaining scalar operators, offset handling, and computed aggregate metadata extracted from groupBy aggregate definitions.
  • ReportQueryValidator basic-structure short circuiting, joined-table selected columns, joined field availability, operator-specific value errors, empty-value warnings, resource warnings, and cartesian join warnings.
  • Public chat channel coverage for missing update/delete responses, available-participant filtering with existing members excluded, attachment creation, missing-attachment rollback, and read-receipt insert failure responses.
  • Internal and public file upload/download contracts, including base64 ownership metadata, uploads-disk path normalization, resize preset and explicit crop/fit branches, storage failures, record creation failures, tenant-scoped downloads, missing identifier responses, and route-parameter download validation normalization.
  • Public comment controller contracts for subject resolution, parent inheritance, tenant-scoped lookup, update/delete missing-record responses, and query filters.
  • Route, request, resource response, filter pipeline, concrete filter, middleware, shared API controller behavior, shared API model behavior, and request authorization contracts.
  • Activity filter coverage for public route scoping and single-date created_at filtering.
  • Role and group controller coverage for typed validation and query exception response branches during create and update flows.
  • Shared API controller behavior edge contracts for fallback validation errors, QueryException create/update responses, bulk delete failures, internal delete resource responses, and delete scoping when company columns are unavailable.
  • QueryOptimizer edge contracts for expression-backed where clauses, nested/exists binding counts, raw and unknown where signatures, and optimization validation rejection paths.
  • API model cache coverage for tenant-scoped keys, lock-timeout fallback reads, direct callback fallback, disabled-cache bypasses, invalidation failure handling, and tenant scope resolution from session, authenticated user, and request input.
  • Shared support coverage for utility helpers, auth support, notification registry, push notifications, data purging, foreign key metadata discovery for MySQL/Postgres/unsupported drivers, expansions, query optimization, directive parsing, resource transformers, socket cluster payloads, telemetry, template strings, phone parsing, two-factor auth, IP metadata lookup, dry-run database execution, public ID generation, and package namespace detection.
  • Additional Utils coverage for storefront URL file ingestion, owner/file metadata persistence, storage writes, SQL debug formatting, query-builder interpolation, default mail sender fallback, model country fallback through the active company session, and failed database connectivity detection.
  • Model coverage for users, companies, files, reports, templates, transactions, verification codes, invites, settings, authorization models, chat models, scheduling models, schedule availability scopes/relationship keys, API/webhook models, Alert relationship/state/notification edge contracts, and operational records.
  • Notification coverage for test push APN message construction, custom payload propagation, and configured action metadata.
  • Console coverage for permissions, purge, recovery, scheduled reports, queue health, database, sandbox, seed, backup, telemetry, install notification, admin maintenance commands, and AssignAdminRoles failure reporting.
  • User cache service coverage for multi-company invalidation, active session-company invalidation, cache forget failures, Redis scan failures, and non-leaking error logging.
  • File resolver service coverage for remote download exception logging, public-id attach success, unsupported identifier failure, and null-model failure behavior.
  • SMS service coverage for AWS SNS, SMPP, and custom HTTP routing selection, formatted phone normalization, mutable routing/default provider contracts, static send routing, and lazy AWS SNS client creation.

Production Fixes

  • Clarified coverage summary output for Clover class metrics.
  • Fixed ReportQueryValidator manual join relationship checks so registry relationship lists match joins by relationship name, relationship table, keyed maps, or default join table while still rejecting explicit bad join keys.
  • Added the missing UserRemovedFromCompany import in the internal company controller.
  • Reordered chat receipt, chat message, policy, role, and group controller exception handling so validation/query errors reach their specific response branches.
  • Fixed API model tenant checks for update, read, and bulk delete by detecting the base company_uuid column before applying qualified constraints.
  • Normalized requested relationship names before load() so snake-case API relation params resolve to camel-case Eloquent relations.
  • Fixed session attribute exclusion handling in fillSessionAttributes().
  • Hardened malformed two-factor auth session tokens so invalid encrypted payloads fail as invalid sessions.
  • Treated MNT as a zero-decimal Stripe amount currency.
  • Fixed policy lookup guard normalization and nullable return contracts.
  • Fixed runtime expansion registration behavior.
  • Fixed Blade expansion target facade resolution by root-qualifying the Illuminate Blade facade namespace.
  • Restored foreign key checks before failed data purge rollback and rethrow.
  • Fixed chat log subject resolution for unregistered subject model types.
  • Fixed multi-organization user removal to set the next active company UUID correctly.
  • Fixed basic auth middleware response handling and OPTIONS credential validation.
  • Fixed notification definition-name dispatch subject context.
  • Fixed category parent filtering to use the existing parentCategory relationship.
  • Fixed timezone country lookup to filter the loaded Countries collection instead of passing closures through the cache-backed service proxy.
  • Fixed HasSubject morph relation keys so the relationship reads the same subject_uuid column written by setSubject().
  • Fixed notification channel save handling so stale APN private-key path/file and Firebase credential-file values are not reintroduced after cleanup.
  • Fixed base64 image size detection in Utils::getImageSizeFromString() by reading normalized image bytes with getimagesizefromstring().
  • Fixed API model filter operator handling so _notIn, _isNull, _isNotNull, and related mixed-case operator suffixes dispatch through their intended query branches.
  • Fixed internal user updates so unavailable role assignments are rejected before mutable user fields are persisted.
  • Fixed User::setUserInfoFromRequest() to call the existing request-enrichment helper instead of a missing method.
  • Fixed malformed policy pipe parsing so mismatched opening and closing quotes are handled by the fallback split branch.
  • Fixed internal base64 image resizing by routing image reads through ImageService::read() instead of accessing the protected image manager from the controller.
  • Fixed package namespace discovery so monorepo server/src paths fall back cleanly when the package root has no composer.json.
  • Fixed QueryOptimizer expression signature normalization so Illuminate raw expressions are handled without unsafe string casting.
  • Added a Google verifier client factory hook so provider success and failure contracts can be tested without live Google requests.
  • Ignored the generated .fleetbase-id telemetry test file.
  • Added protected factory/fetch hooks where needed to test external integrations without live network, cloud credentials, or websocket connections.

Validation

  • /usr/local/bin/composer lint
  • ./vendor/bin/pest tests/Unit/Http/CompanyControllerTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Http/AuthControllerVerificationCodeTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Http/AuthControllerLoginBootstrapTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Http/GroupControllerTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Http/RoleControllerTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Http/ConcreteFilterContractsTest.php --filter "activity filter respects admin override" --colors=always
  • ./vendor/bin/pest tests/Unit/Traits/HasApiControllerBehaviorTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Support/DataPurgerTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Http/ChatChannelControllerTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Http/ReportControllerTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Http/SettingControllerSaveConfigTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Models/OperationalModelsTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Services/AvailabilityServiceTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/NotificationsAndMailTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Services/UserCacheServiceTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Services/FileResolverServiceTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/MultiProviderSmsServiceTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Support/UtilsTest.php --colors=always
  • ./vendor/bin/pest tests/Unit/Observers/WebhookEventsObserverTest.php --colors=always
  • /usr/local/bin/composer test:unit
  • PATH=/Users/ron/.asdf/shims:$PATH XDEBUG_MODE=coverage /usr/local/bin/composer coverage:baseline
  • php scripts/coverage-summary.php coverage/clover.xml
  • git diff --check

Notes:

  • composer without the asdf PATH still resolves php to /opt/homebrew/Cellar/php/8.3.13_1/bin/php, which has no coverage driver. Coverage succeeds when /Users/ron/.asdf/shims is first in PATH.
  • Full unit run passed with existing deprecation/warning output from current dependencies.

roncodes added 30 commits July 19, 2026 07:19
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