Skip to content

[26557] Support minimum and maximum booking fare quantities - #545

Merged
MichaelReyes merged 2 commits into
developfrom
feature/26557
Nov 26, 2026
Merged

MichaelReyes merged 2 commits into
developfrom
feature/26557

Conversation

@MichaelReyes

Copy link
Copy Markdown
Contributor

Pull Request (PR) Checklist

PR Context

  • Type: Feature
  • Issue Link: Redmine #26557
  • Risk Factor: Medium — Changes both fare selectors and booking request validation. Existing single-fare behavior is preserved, with focused regression coverage.

Changes

Android previously dropped the minimum fare quantity and inconsistently enforced maximum quantities. This change supports the quick-booking API’s min and max constraints while keeping additional-passenger fares optional.

  • Added nullable min support and shared quantity rules.
  • Updated both selectors to start selected fares at their minimum, enforce maximums, and allow deselection.
  • Preserved existing behavior when bounds are absent and enforced single-fare selection across fare tabs.
  • Added pre-submission validation for offered fare IDs, duplicate selections, quantities, and single-fare restrictions.
  • Snapshotted selected fares to prevent later UI changes from altering pending requests.
  • Improved server-error handling, including empty or malformed error responses.
  • Added regression tests for quantity rules, request validation, payload stability, and error presentation.

Requests continue using fares with selected IDs and quantities. Fare-role validation remains server-owned, consistent with API PR #286.

Checklist for Reviewers

Documentation and Code Quality

  • KDocs Documentation: Shared quantity rules are documented; complete KDocs coverage remains for review.
  • Architectural Patterns: Retained existing MVVM, DataBinding, and request-service patterns.

Testing and Reliability

  • Unit Testing: Recorded 24 focused passing tests. Direct adapter click/tab tests and full older booking ViewModel integration coverage remain gaps.
  • Emulator and Real Device Testing: Tested on the existing Medium Phone emulator using waupacaStaging and waupacaRelease. Real-device testing was not performed.

Error Handling and Logging

  • Error Handling: Server validation messages are surfaced; empty or malformed HTTP error bodies fall back to a visible error.
  • Logging: Existing logging was retained. Production release request bodies are unavailable for exact payload inspection.

Testing Procedure

  • Recorded focused test results: 24 tests, zero failures, errors, or skips:
    • FareQuantityJsonTest: 5
    • DrtTicketViewModelTest: 10
    • DrtFareSelectionViewModelTest: 5
    • FareSelectionValidationTest: 4
  • Verified optional selection, min=1/max=3, min=2/max=5, absent and invalid bounds, duplicate/unknown IDs, single-fare restrictions, and stable request snapshots.
  • Captured the documented primary-plus-companion request in deterministic tests, confirming selected IDs/quantities and omission of unselected fares.
  • Production emulator observations confirmed optional passenger selection/deselection, a quantity cap of 3, correct totals, and retention of multiple selected fares.
  • Verified legacy single-fare switching offline. No production booking or payment was submitted.

Focused validation command:

./gradlew \
  :trip-kit-booking:testStagingUnitTest --tests '*FareQuantityJsonTest' \
  :TripKitAndroidUI:testStagingUnitTest --tests '*DrtTicketViewModelTest' \
  :tripgosdk:testStagingUnitTest \
  --tests '*DrtFareSelectionViewModelTest' \
  --tests '*FareSelectionValidationTest' \
  :app:assembleWaupacaStaging --offline

- Added nullable minimum quantity and shared fare quantity rules
- Updated both fare selectors to enforce bounds and allow optional deselection
- Validated selected fare IDs, quantities and single-fare restrictions before submission
- Snapshotted fare selections to prevent pending request mutation
- Improved handling of server validation errors
- Added regression tests for quantity constraints and booking payloads
@github-actions

Copy link
Copy Markdown

✅ Unit tests passed successfully!

Test results are available under the "Artifacts" section of this run in GitHub Actions.

Please ensure the code is reviewed before proceeding with the merge.

…controls

- Initialize required fares at their minimum and prevent decrementing below it
- Apply consistent minimum and maximum rules across both fare selectors
- Reject missing, zero and below-minimum required fares before submission
- Preserve optional fares, legacy behavior, pricing and request snapshots
- Handle conflicting singleFareOnly constraints without bypassing minimums
- Keep compact controls with separate 48dp touch targets
@github-actions

Copy link
Copy Markdown

❌ Unit tests failed!

@MichaelReyes, please review and fix the issues in the unit tests.

Test results are available under the "Artifacts" section of this run in GitHub Actions.

Let us know if you need any help.

@github-actions

Copy link
Copy Markdown

✅ Unit tests passed successfully!

Test results are available under the "Artifacts" section of this run in GitHub Actions.

Please ensure the code is reviewed before proceeding with the merge.

@MichaelReyes
MichaelReyes merged commit 8b94482 into develop Nov 26, 2026
1 of 2 checks passed
@MichaelReyes
MichaelReyes deleted the feature/26557 branch November 26, 2026 14:04
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