test(SDKS-5126): improve integration tests across JS, Android, and iOS#56
test(SDKS-5126): improve integration tests across JS, Android, and iOS#56pingidentity-gaurav wants to merge 3 commits into
Conversation
…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>
|
Warning Review limit reached
Next review available in: 28 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughUpdates 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. ChangesBridge contracts and integration test alignment
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
PingTestRunner/__tests__/integration/push.test.ts (1)
192-230: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: extract the shared
react-nativemock to avoid drift.
loadPushWithRealHelpersduplicates the entirereact-nativemock block (Lines 201-219) already defined inloadPush(Lines 142-160). The two loaders now differ only in theNativeRNPingPushfactory. Extracting the commonjest.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
📒 Files selected for processing (19)
.github/workflows/js-unit-tests.ymlPingTestRunner/__tests__/integration/device-client.test.tsPingTestRunner/__tests__/integration/external-idp.test.tsPingTestRunner/__tests__/integration/native-spec-contracts.test.tsPingTestRunner/__tests__/integration/oath.test.tsPingTestRunner/__tests__/integration/push.test.tsPingTestRunner/jest.setup.jspackages/binding/android/build.gradlepackages/binding/android/src/test/java/com/pingidentity/rnbinding/RNPingBindingTest.ktpackages/binding/ios/RNPingBindingCommon.swiftpackages/binding/ios/Tests/RNPingBindingCommonTests.swiftpackages/binding/jest.config.jspackages/device-client/jest.config.jspackages/fido/jest.config.jspackages/oath/android/src/test/java/com/pingidentity/rnoath/RNPingOathCommonTest.ktpackages/oath/ios/RNPingOathCommon.swiftpackages/oath/ios/Tests/RNPingOathCommonTests.swiftpackages/push/jest.config.jspackages/types/jest.config.js
|
- 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( |
There was a problem hiding this comment.
This seems to be duplicating existing loadPush RN mock setup. How about extracting it to mockReactNative helper?
There was a problem hiding this comment.
Good catch. Extracted the duplicated jest.doMock('react-native', ...) block into a mockReactNative helper called by both loadPush and loadPushWithRealHelpers.
tsdamas
left a comment
There was a problem hiding this comment.
Changes are solid. Left a minor non-blocking comment. PR approved.
rodrigoareis
left a comment
There was a problem hiding this comment.
Overall changes looks good. Just two minor comments that are not related to current changes.
| }, | ||
| ], | ||
| ], | ||
| collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/__tests__/**'], |
There was a problem hiding this comment.
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/'],
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Move it to a private helpers section or place it before the Public MARK.
There was a problem hiding this comment.
Done. Moved resolveLoggerFromCore out of the Public entry points section into a new // MARK: - Private helpers section before // MARK: - Codec helpers.
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
{ type, error }) to matchPingErrorsubclass shape ({ type, code })coverageDirectory/collectCoverageFrom/coverageReportersto 5 jest configs (binding,device-client,fido,push,types) so CI lcov artifacts are generatedcontinue-on-error: falseonjs-unit-testsjob - failures no longer silently pass CInative-spec-contracts.test.tswith 3 missing packages (rn-device-client,rn-external-idp,rn-push) and 2 missing fido methods for compile-time method-name drift detectionrn-device-clientandrn-pushinjest.setup.jspush.test.tsandexternal-idp.test.tsusingjest.requireActualso realfromNative*helpers run against controlled native mocksbindinggetAllKeys (5 tests),oathencodeCredential + generateCodeWithValidity (9 tests)serializeUserKeyin binding iOS andencodeCredential/encodeCodeInfohelpers in oath iOS; add XCTest field-name assertions for both (20 tests) - verified withxcodebuild build-for-testingSummary by CodeRabbit
Bug Fixes
Tests
type/codepayloads.Chores