Skip to content

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

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

test(SDKS-5126): improve integration tests across JS, Android, and iOS#56
pingidentity-gaurav wants to merge 3 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

Warning

Review limit reached

@pingidentity-gaurav, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 28 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0255a59d-5382-4f07-acb1-a978fc6b81bd

📥 Commits

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

📒 Files selected for processing (6)
  • PingTestRunner/__tests__/integration/push.test.ts
  • packages/binding/jest.config.js
  • packages/device-client/jest.config.js
  • packages/fido/jest.config.js
  • packages/oath/ios/RNPingOathCommon.swift
  • packages/push/jest.config.js
📝 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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch SDKS-5126

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-30 19:02 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>
return { mod, emittedHandlers };
}

async function loadPushWithRealHelpers(

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.

This seems to be duplicating existing loadPush RN mock setup. How about extracting it to mockReactNative helper?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Extracted the duplicated jest.doMock('react-native', ...) block into a mockReactNative helper called by both loadPush and loadPushWithRealHelpers.

@tsdamas tsdamas 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.

Changes are solid. Left a minor non-blocking comment. PR approved.

@rodrigoareis rodrigoareis 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.

Overall changes looks good. Just two minor comments that are not related to current changes.

},
],
],
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/__tests__/**'],

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.

Some jest.config.js files are missing options present in all other package configs:

packages/binding/jest.config.js, device-client/jest.config.js, fido/jest.config.js, push/jest.config.js are all missing three fields that every other existing package config (browser, external-idp, device-id, journey, etc.) includes:

// Missing in all 4 new files:
roots: ['<rootDir>/src'],
modulePathIgnorePatterns: ['<rootDir>/lib/'],
watchPathIgnorePatterns: ['<rootDir>/lib/'],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. These four packages are new in this PR so the omission is on us. Added roots, modulePathIgnorePatterns, and watchPathIgnorePatterns to all four configs (binding, device-client, fido, push) to match the rest of the monorepo.

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.

Move it to a private helpers section or place it before the Public MARK.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Moved resolveLoggerFromCore out of the Public entry points section into a new // MARK: - Private helpers section before // MARK: - Codec helpers.

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.57%. Comparing base (3e12dfa) to head (9abca37).
⚠️ Report is 59 commits behind head on main.

Files with missing lines Patch % Lines
packages/oath/ios/RNPingOathCommon.swift 0.00% 18 Missing ⚠️
packages/binding/ios/RNPingBindingCommon.swift 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #56      +/-   ##
============================================
- Coverage     51.39%   50.57%   -0.83%     
  Complexity       82       82              
============================================
  Files           189      167      -22     
  Lines         15597    14543    -1054     
  Branches        651      475     -176     
============================================
- Hits           8016     7355     -661     
+ Misses         7514     7161     -353     
+ Partials         67       27      -40     
Flag Coverage Δ
android 9.83% <ø> (-0.06%) ⬇️
ios 56.63% <0.00%> (-0.12%) ⬇️
javascript 66.32% <ø> (+2.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants