Skip to content

test(SDKS-5126): improve integration tests across JS, Android, and iOS#56

Open
pingidentity-gaurav wants to merge 2 commits into
mainfrom
SDKS-5126
Open

test(SDKS-5126): improve integration tests across JS, Android, and iOS#56
pingidentity-gaurav wants to merge 2 commits into
mainfrom
SDKS-5126

Conversation

@pingidentity-gaurav

@pingidentity-gaurav pingidentity-gaurav commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix 12 failing Jest integration tests - assertions updated from raw native error shape ({ type, error }) to match PingError subclass shape ({ type, code })
  • Add missing coverageDirectory/collectCoverageFrom/coverageReporters to 5 jest configs (binding, device-client, fido, push, types) so CI lcov artifacts are generated
  • Flip continue-on-error: false on js-unit-tests job - failures no longer silently pass CI
  • Extend native-spec-contracts.test.ts with 3 missing packages (rn-device-client, rn-external-idp, rn-push) and 2 missing fido methods for compile-time method-name drift detection
  • Add global mocks for rn-device-client and rn-push in jest.setup.js
  • Add encode/decode round-trip tests in push.test.ts and external-idp.test.ts using jest.requireActual so real fromNative* helpers run against controlled native mocks
  • Add Android Robolectric field-name assertions: binding getAllKeys (5 tests), oath encodeCredential + generateCodeWithValidity (9 tests)
  • Extract serializeUserKey in binding iOS and encodeCredential/encodeCodeInfo helpers in oath iOS; add XCTest field-name assertions for both (20 tests) - verified with xcodebuild build-for-testing

Summary by CodeRabbit

  • Bug Fixes

    • Improved OATH code-generation payload encoding to use a centralized encoder, aligning response field formats (including numeric conversions).
  • Tests

    • Expanded integration and contract tests for device client, external identity provider, push, and native error/field mapping.
    • Updated error-shape assertions to validate standardized type/code payloads.
    • Added additional compile-time bridge contract typings and strengthened serialization expectations.
  • Chores

    • Updated CI to fail on unit test errors instead of continuing.
    • Enabled code coverage reporting across multiple packages’ Jest configurations.

…S layers

- Fix 12 failing Jest integration tests: assertions now use .code instead of .error to match PingError subclass shape
- Add missing coverage config (collectCoverageFrom, coverageDirectory, coverageReporters) to 5 jest.config.js files so CI lcov artifacts are generated
- Flip continue-on-error to false on js-unit-tests job so failures are no longer silently swallowed
- Extend native-spec-contracts.test.ts with 3 missing packages and 2 fido methods for compile-time drift detection
- Add global mocks for rn-device-client and rn-push in jest.setup.js
- Add encode/decode round-trip tests in push.test.ts and external-idp.test.ts using jest.requireActual
- Add Android Robolectric field-name assertions for binding getAllKeys (5 tests) and oath encodeCredential/generateCodeWithValidity (9 tests)
- Extract serializeUserKey helper in binding iOS and encodeCredential/encodeCodeInfo helpers in oath iOS; add XCTest field-name assertions for both (20 tests total)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5df05984-0279-4a19-9f7c-7c9187fe304b

📥 Commits

Reviewing files that changed from the base of the PR and between 9b73f3b and dc68449.

📒 Files selected for processing (2)
  • PingTestRunner/__tests__/integration/native-spec-contracts.test.ts
  • packages/oath/android/src/test/java/com/pingidentity/rnoath/RNPingOathCommonTest.kt
🚧 Files skipped from review as they are similar to previous changes (2)
  • PingTestRunner/tests/integration/native-spec-contracts.test.ts
  • packages/oath/android/src/test/java/com/pingidentity/rnoath/RNPingOathCommonTest.kt

📝 Walkthrough

Walkthrough

Updates bridge serialization helpers and contract tests for binding and oath modules, expands native-spec compile-time checks and Jest mocks, normalizes integration rejection assertions to mapped error codes, and adds Jest coverage configuration plus workflow gating changes.

Changes

Bridge contracts and integration test alignment

Layer / File(s) Summary
Test infrastructure and coverage
.github/workflows/js-unit-tests.yml, PingTestRunner/jest.setup.js, packages/binding/android/build.gradle, packages/binding/jest.config.js, packages/device-client/jest.config.js, packages/fido/jest.config.js, packages/push/jest.config.js, packages/types/jest.config.js
Changes JS unit test failure handling, adds coverage output settings to Jest configs, adds native module mocks to Jest setup, and adds the Android coroutine test dependency.
Native spec mock contracts
PingTestRunner/__tests__/integration/native-spec-contracts.test.ts
Extends compile-time mocked-method checks for device-client, external-idp, fido, and push native specs.
Binding UserKey bridge serialization
packages/binding/android/src/test/java/com/pingidentity/rnbinding/RNPingBindingTest.kt, packages/binding/ios/RNPingBindingCommon.swift, packages/binding/ios/Tests/RNPingBindingCommonTests.swift
Adds serializeUserKey on iOS and bridge-key contract tests on iOS and Android for UserKey serialization.
Oath encoding contracts
packages/oath/ios/RNPingOathCommon.swift, packages/oath/ios/Tests/RNPingOathCommonTests.swift, packages/oath/android/src/test/java/com/pingidentity/rnoath/RNPingOathCommonTest.kt
Adds shared OATH code-info encoding on iOS and contract tests on iOS and Android for credential and code-info bridge field mappings.
Integration error shapes and real bridge helpers
PingTestRunner/__tests__/integration/device-client.test.ts, PingTestRunner/__tests__/integration/external-idp.test.ts, PingTestRunner/__tests__/integration/oath.test.ts, PingTestRunner/__tests__/integration/push.test.ts
Updates rejection assertions to mapped code fields, adds real-helper loaders for push and external-idp, and adds decode/field-validation coverage for native bridge helpers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • george-bafaloukas-forgerock
  • tsdamas
  • witrisna

Poem

🐇 Hop hop, the bridge sings clear,
code and helpers now appear.
User keys and OATH codes align,
Tests and mocks all intertwine.
A tidy trail from native to JS,
This bunny nods: “Looks solid, yes!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.20% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: broader test improvements across JS, Android, and iOS.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch SDKS-5126

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
PingTestRunner/__tests__/integration/push.test.ts (1)

192-230: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: extract the shared react-native mock to avoid drift.

loadPushWithRealHelpers duplicates the entire react-native mock block (Lines 201-219) already defined in loadPush (Lines 142-160). The two loaders now differ only in the NativeRNPingPush factory. Extracting the common jest.doMock('react-native', ...) setup into a small helper keeps the two paths in sync if the mocked RN surface changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PingTestRunner/__tests__/integration/push.test.ts` around lines 192 - 230,
The `loadPushWithRealHelpers` function duplicates the identical
`jest.doMock('react-native', ...)` mock setup that already exists in the
`loadPush` function. Extract this common mock configuration into a separate
helper function and call it from both `loadPush` and `loadPushWithRealHelpers`
to eliminate duplication and prevent the mocks from drifting if the React Native
surface being mocked changes in the future.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/oath/android/src/test/java/com/pingidentity/rnoath/RNPingOathCommonTest.kt`:
- Around line 751-766: The test method
encodeCredential_doesNotSerializeSecretField currently only asserts that the
"secret" field is not serialized to the bridge. Add an additional assertion
immediately after the existing assertFalse call for "secret" to also verify that
the "secretKey" field is not present in the map, using the same assertFalse
pattern with an appropriate error message indicating that secretKey must not be
serialized to the bridge.

In `@PingTestRunner/__tests__/integration/native-spec-contracts.test.ts`:
- Around line 157-183: The comment on the _PushMockedMethods type declaration
states "all 22 bridge methods," but the actual Pick<PushSpec> type currently
includes only 21 methods. Count the methods listed in the _PushMockedMethods
Pick type and update the comment to reflect the actual number of methods being
mocked instead of 22.

---

Nitpick comments:
In `@PingTestRunner/__tests__/integration/push.test.ts`:
- Around line 192-230: The `loadPushWithRealHelpers` function duplicates the
identical `jest.doMock('react-native', ...)` mock setup that already exists in
the `loadPush` function. Extract this common mock configuration into a separate
helper function and call it from both `loadPush` and `loadPushWithRealHelpers`
to eliminate duplication and prevent the mocks from drifting if the React Native
surface being mocked changes in the future.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7dbd235e-2aaa-4e61-af2e-6d5b46a3b041

📥 Commits

Reviewing files that changed from the base of the PR and between cd653e3 and 9b73f3b.

📒 Files selected for processing (19)
  • .github/workflows/js-unit-tests.yml
  • PingTestRunner/__tests__/integration/device-client.test.ts
  • PingTestRunner/__tests__/integration/external-idp.test.ts
  • PingTestRunner/__tests__/integration/native-spec-contracts.test.ts
  • PingTestRunner/__tests__/integration/oath.test.ts
  • PingTestRunner/__tests__/integration/push.test.ts
  • PingTestRunner/jest.setup.js
  • packages/binding/android/build.gradle
  • packages/binding/android/src/test/java/com/pingidentity/rnbinding/RNPingBindingTest.kt
  • packages/binding/ios/RNPingBindingCommon.swift
  • packages/binding/ios/Tests/RNPingBindingCommonTests.swift
  • packages/binding/jest.config.js
  • packages/device-client/jest.config.js
  • packages/fido/jest.config.js
  • packages/oath/android/src/test/java/com/pingidentity/rnoath/RNPingOathCommonTest.kt
  • packages/oath/ios/RNPingOathCommon.swift
  • packages/oath/ios/Tests/RNPingOathCommonTests.swift
  • packages/push/jest.config.js
  • packages/types/jest.config.js

Comment thread PingTestRunner/__tests__/integration/native-spec-contracts.test.ts
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://ForgeRock.github.io/ping-react-native-sdk/docs-preview/pr-56/

Built to branch gh-pages at 2026-06-24 15:47 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

- Fix comment drift: "22 bridge methods" -> "21" in native-spec-contracts.test.ts
- Also assert secretKey is absent from oath credential bridge payload (alongside secret)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant