Skip to content

No tests for the iOS PaymentDelegate or the Android sheet-result paths #64

Open

Description

@jkasprzyk17

Problem

The most intricate lifecycle code has no native tests:

  • iOS PaymentDelegate (HybridPaymentHandler.swift:494-635): onAuthorize success, failure, rejection and 25 s timeout; a late result after the timeout; didFinish while authorizing (finishedWhileAuthorizing); a second attempt after failure; cancel before authorization; shipping-method change.
  • Android HybridPaymentHandler (HybridPaymentHandler.kt:164-373): RESULT_OK with and without data; RESULT_CANCELED; RESULT_ERROR with a status; an unknown code; no current activity; the authorizePayment timeout against a late result.

The existing tests cover PendingPayment, the presenter, builders and mappers. JS coverage is 99%, but all of it runs against a mocked native module. Past lifecycle bugs (#5, #6, #29, #30, #54) were all in this area.

Suggested fix

Extract the delegate's decisions into pure functions, then test them. For example:

  • authorizationResult(for: PaymentResult) -> PKPaymentAuthorizationResult
  • onDidFinish(state) -> action
  • handleSheetResult(resultCode, data) -> PaymentResult

Acceptance criteria

  • Each transition listed above has an XCTest or JUnit test.

Testing

  • xcodebuild test … -scheme NitroPay-Unit-Tests
  • ./gradlew :gmisoftware_react-native-pay:testDebugUnitTest

From the v0.1.0 production-readiness audit (130df37).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions