Skip to content

test(iframe-manager): add unit tests with jsdom#625

Open
ryanbas21 wants to merge 1 commit intomainfrom
iframe-tests
Open

test(iframe-manager): add unit tests with jsdom#625
ryanbas21 wants to merge 1 commit intomainfrom
iframe-tests

Conversation

@ryanbas21
Copy link
Copy Markdown
Collaborator

@ryanbas21 ryanbas21 commented May 5, 2026

JIRA Ticket

https://pingidentity.atlassian.net/browse/SDKS-5028

Description

Adds some tests using jsdom for iframe-manager.

Summary by CodeRabbit

  • Tests

    • Added test suite for iframe manager parameter validation and redirect handling scenarios.
  • Refactor

    • Renamed polling method from poll() to pollStatus() in davinci client.
    • Reordered return type unions in davinci client methods for consistency.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

⚠️ No Changeset found

Latest commit: 61b4a8d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

The pull request renames the davinci client's polling helper method from poll() to pollStatus() across its public API declarations, reorders union types in start() and getNode() return values, and introduces a comprehensive test suite for the iframe-manager's getParamsByRedirect functionality covering input validation, iframe lifecycle, timeout handling, and cross-origin failures.

Changes

davinci-client API Updates

Layer / File(s) Summary
API Report Updates
packages/davinci-client/api-report/davinci-client.api.md, packages/davinci-client/api-report/davinci-client.types.api.md
Polling method renamed from poll(...) to pollStatus(...) with parameter type PollingCollector and return type Poller unchanged. Return union member ordering adjusted in start() and getNode() to ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode.

iframe-manager Testing

Layer / File(s) Summary
Test Utilities
packages/sdk-effects/iframe-manager/src/lib/iframe-manager.effects.test.ts
Local simulateIframeLoad() helper added to stub contentWindow.location.href and dispatch load events.
Input Validation Tests
packages/sdk-effects/iframe-manager/src/lib/iframe-manager.effects.test.ts
Test suite validates synchronous throws when successParams or errorParams are empty or undefined.
Iframe Lifecycle Tests
packages/sdk-effects/iframe-manager/src/lib/iframe-manager.effects.test.ts
Tests verify hidden iframe creation, src assignment, success/error param resolution, timeout rejection with DOM cleanup, intermediate redirects, about:blank load skipping, and cross-origin contentWindow access failures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • SteinGabriel
  • cerebrl

Poem

🐰 A poll becomes pollStatus, types align,
Iframe tests now cover every line!
Redirects trapped, timeouts betrayed,
Cross-origin fears all fade away. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding unit tests with jsdom for iframe-manager, which aligns with the substantial test file additions.
Description check ✅ Passed The description follows the template structure with JIRA ticket reference and a clear explanation of changes, meeting basic requirements despite being concise.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 iframe-tests

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 and usage tips.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented May 5, 2026

View your CI Pipeline Execution ↗ for commit 61b4a8d

Command Status Duration Result
nx run-many -t build --no-agents ✅ Succeeded 2s View ↗
nx affected -t build lint test typecheck e2e-ci ✅ Succeeded 2m 13s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-05 19:31:38 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 5, 2026

Open in StackBlitz

@forgerock/davinci-client

pnpm add https://pkg.pr.new/@forgerock/davinci-client@625

@forgerock/device-client

pnpm add https://pkg.pr.new/@forgerock/device-client@625

@forgerock/journey-client

pnpm add https://pkg.pr.new/@forgerock/journey-client@625

@forgerock/oidc-client

pnpm add https://pkg.pr.new/@forgerock/oidc-client@625

@forgerock/protect

pnpm add https://pkg.pr.new/@forgerock/protect@625

@forgerock/sdk-types

pnpm add https://pkg.pr.new/@forgerock/sdk-types@625

@forgerock/sdk-utilities

pnpm add https://pkg.pr.new/@forgerock/sdk-utilities@625

@forgerock/iframe-manager

pnpm add https://pkg.pr.new/@forgerock/iframe-manager@625

@forgerock/sdk-logger

pnpm add https://pkg.pr.new/@forgerock/sdk-logger@625

@forgerock/sdk-oidc

pnpm add https://pkg.pr.new/@forgerock/sdk-oidc@625

@forgerock/sdk-request-middleware

pnpm add https://pkg.pr.new/@forgerock/sdk-request-middleware@625

@forgerock/storage

pnpm add https://pkg.pr.new/@forgerock/storage@625

commit: 61b4a8d

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.68%. Comparing base (5d6747a) to head (61b4a8d).
⚠️ Report is 90 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #625       +/-   ##
===========================================
- Coverage   70.90%   53.68%   -17.23%     
===========================================
  Files          53       42       -11     
  Lines        2021     3709     +1688     
  Branches      377      485      +108     
===========================================
+ Hits         1433     1991      +558     
- Misses        588     1718     +1130     

see 94 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Deployed c5d68a7 to https://ForgeRock.github.io/ping-javascript-sdk/pr-625/c5d68a77646ff8bf086e9cf931b5aa1e64c46bec branch gh-pages in ForgeRock/ping-javascript-sdk

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

📦 Bundle Size Analysis

📦 Bundle Size Analysis

🚨 Significant Changes

🔻 @forgerock/device-client - 0.0 KB (-10.0 KB, -100.0%)
🔻 @forgerock/journey-client - 0.0 KB (-91.9 KB, -100.0%)

➖ No Changes

@forgerock/device-client - 10.0 KB
@forgerock/davinci-client - 48.6 KB
@forgerock/oidc-client - 25.2 KB
@forgerock/sdk-utilities - 11.2 KB
@forgerock/sdk-types - 7.9 KB
@forgerock/protect - 144.6 KB
@forgerock/journey-client - 91.9 KB
@forgerock/storage - 1.5 KB
@forgerock/sdk-oidc - 4.8 KB
@forgerock/sdk-request-middleware - 4.5 KB
@forgerock/sdk-logger - 1.6 KB
@forgerock/iframe-manager - 2.4 KB


14 packages analyzed • Baseline from latest main build

Legend

🆕 New package
🔺 Size increased
🔻 Size decreased
➖ No change

ℹ️ How bundle sizes are calculated
  • Current Size: Total gzipped size of all files in the package's dist directory
  • Baseline: Comparison against the latest build from the main branch
  • Files included: All build outputs except source maps and TypeScript build cache
  • Exclusions: .map, .tsbuildinfo, and .d.ts.map files

🔄 Updated automatically on each push to this PR

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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/davinci-client/api-report/davinci-client.api.md`:
- Line 273: The public API renamed the method from poll to pollStatus (seen as
pollStatus: (collector: PollingCollector) => Poller), which is breaking; restore
backwards compatibility by adding a transitional alias named poll that delegates
to pollStatus (e.g., implement a poll method or export a poll symbol that
calls/returns pollStatus(collector)), keep both signatures matching
PollingCollector => Poller, mark the alias as deprecated in source comments, and
then regenerate the API report so the exported contract includes both poll and
pollStatus.

In `@packages/sdk-effects/iframe-manager/src/lib/iframe-manager.effects.test.ts`:
- Around line 50-61: The test "throws synchronously when successParams or
errorParams is undefined" only exercises the successParams-undefined branch;
update the tests for iFrameManager().getParamsByRedirect to either (a) split
into two assertions or add a second it block: one that passes successParams:
undefined and a second that passes errorParams: undefined (both with other
required fields like url/timeout) and assert they throw 'successParams and
errorParams must be provided'; alternatively rename the existing test to
accurately reflect it only covers successParams if you prefer separate coverage.
Use the manager variable and getParamsByRedirect symbol to locate the test to
modify.
🪄 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: 8a86d644-55d0-4f24-b007-d93fe6c9959c

📥 Commits

Reviewing files that changed from the base of the PR and between eedcca7 and 61b4a8d.

📒 Files selected for processing (4)
  • packages/davinci-client/api-report/davinci-client.api.md
  • packages/davinci-client/api-report/davinci-client.types.api.md
  • packages/sdk-effects/iframe-manager/src/lib/iframe-manager.effects.test.ts
  • packages/sdk-effects/iframe-manager/vite.config.ts

update: <T extends SingleValueCollectors | MultiSelectCollector | ObjectValueCollectors | AutoCollectors>(collector: T) => Updater<T>;
validate: (collector: SingleValueCollectors | ObjectValueCollectors | MultiValueCollectors | AutoCollectors) => Validator;
poll: (collector: PollingCollector) => Poller;
pollStatus: (collector: PollingCollector) => Poller;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Public API rename is breaking without a compatibility bridge.

Renaming poll to pollStatus changes the exported client contract and will break existing integrations unless you provide a transitional alias (or explicitly gate this behind a major-version release plan).

Suggested compatibility bridge (in source, then regenerate API report)
- pollStatus: (collector: PollingCollector) => Poller;
+ pollStatus: (collector: PollingCollector) => Poller;
+ /** `@deprecated` Use pollStatus instead. */
+ poll: (collector: PollingCollector) => Poller;
🤖 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 `@packages/davinci-client/api-report/davinci-client.api.md` at line 273, The
public API renamed the method from poll to pollStatus (seen as pollStatus:
(collector: PollingCollector) => Poller), which is breaking; restore backwards
compatibility by adding a transitional alias named poll that delegates to
pollStatus (e.g., implement a poll method or export a poll symbol that
calls/returns pollStatus(collector)), keep both signatures matching
PollingCollector => Poller, mark the alias as deprecated in source comments, and
then regenerate the API report so the exported contract includes both poll and
pollStatus.

Comment on lines +50 to +61
it('throws synchronously when successParams or errorParams is undefined', () => {
const manager = iFrameManager();
expect(() =>
manager.getParamsByRedirect({
url: 'https://example.com',
timeout: 1000,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
successParams: undefined as any,
errorParams: ['error'],
}),
).toThrow('successParams and errorParams must be provided');
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Test name is misleading and the errorParams: undefined case is missing.

The description says "successParams or errorParams is undefined" but the test body only exercises successParams: undefined. errorParams: undefined is never passed, so the guard for that branch is untested.

🛠️ Proposed fix: cover both `undefined` cases
-    it('throws synchronously when successParams or errorParams is undefined', () => {
-      const manager = iFrameManager();
-      expect(() =>
-        manager.getParamsByRedirect({
-          url: 'https://example.com',
-          timeout: 1000,
-          // eslint-disable-next-line `@typescript-eslint/no-explicit-any`
-          successParams: undefined as any,
-          errorParams: ['error'],
-        }),
-      ).toThrow('successParams and errorParams must be provided');
-    });
+    it('throws synchronously when successParams is undefined', () => {
+      const manager = iFrameManager();
+      expect(() =>
+        manager.getParamsByRedirect({
+          url: 'https://example.com',
+          timeout: 1000,
+          // eslint-disable-next-line `@typescript-eslint/no-explicit-any`
+          successParams: undefined as any,
+          errorParams: ['error'],
+        }),
+      ).toThrow('successParams and errorParams must be provided');
+    });
+
+    it('throws synchronously when errorParams is undefined', () => {
+      const manager = iFrameManager();
+      expect(() =>
+        manager.getParamsByRedirect({
+          url: 'https://example.com',
+          timeout: 1000,
+          successParams: ['code'],
+          // eslint-disable-next-line `@typescript-eslint/no-explicit-any`
+          errorParams: undefined as any,
+        }),
+      ).toThrow('successParams and errorParams must be provided');
+    });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('throws synchronously when successParams or errorParams is undefined', () => {
const manager = iFrameManager();
expect(() =>
manager.getParamsByRedirect({
url: 'https://example.com',
timeout: 1000,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
successParams: undefined as any,
errorParams: ['error'],
}),
).toThrow('successParams and errorParams must be provided');
});
it('throws synchronously when successParams is undefined', () => {
const manager = iFrameManager();
expect(() =>
manager.getParamsByRedirect({
url: 'https://example.com',
timeout: 1000,
// eslint-disable-next-line `@typescript-eslint/no-explicit-any`
successParams: undefined as any,
errorParams: ['error'],
}),
).toThrow('successParams and errorParams must be provided');
});
it('throws synchronously when errorParams is undefined', () => {
const manager = iFrameManager();
expect(() =>
manager.getParamsByRedirect({
url: 'https://example.com',
timeout: 1000,
successParams: ['code'],
// eslint-disable-next-line `@typescript-eslint/no-explicit-any`
errorParams: undefined as any,
}),
).toThrow('successParams and errorParams must be provided');
});
🤖 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 `@packages/sdk-effects/iframe-manager/src/lib/iframe-manager.effects.test.ts`
around lines 50 - 61, The test "throws synchronously when successParams or
errorParams is undefined" only exercises the successParams-undefined branch;
update the tests for iFrameManager().getParamsByRedirect to either (a) split
into two assertions or add a second it block: one that passes successParams:
undefined and a second that passes errorParams: undefined (both with other
required fields like url/timeout) and assert they throw 'successParams and
errorParams must be provided'; alternatively rename the existing test to
accurately reflect it only covers successParams if you prefer separate coverage.
Use the manager variable and getParamsByRedirect symbol to locate the test to
modify.

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.

2 participants