Skip to content

test: improve protect e2e tests - #756

Merged
ancheetah merged 2 commits into
mainfrom
SDKS-5240-protect-e2e
Aug 13, 2026
Merged

test: improve protect e2e tests#756
ancheetah merged 2 commits into
mainfrom
SDKS-5240-protect-e2e

Conversation

@ancheetah

@ancheetah ancheetah commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

JIRA Ticket

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

  • Updates Protect e2e tests for davinci, journey, and protect apps.
  • Requires riskData assertions instead of asserting them conditionally
  • Removes any assertions of login failure/success
  • Migrates Protect flows from old tenant to new tenant

Note: Maybe we can consider removing the protect app and its suites now since protect is tested through the davinci-app and journey-app.

Summary by CodeRabbit

  • Tests
    • Updated Protect end-to-end coverage for DaVinci and Journey flows.
    • Added validation for returned risk data and improved request handling.
  • Chores
    • Consolidated Protect testing by removing the standalone demo application and dedicated test suite.
    • Updated project configuration and dependencies to support the revised test structure.
    • Refreshed DaVinci client API documentation to reflect current type definitions.

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8970b3a

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

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

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 Plus

Run ID: a0aef88c-14eb-4731-a822-3c9eb21aacc1

📥 Commits

Reviewing files that changed from the base of the PR and between 895d492 and 8970b3a.

⛔ Files ignored due to path filters (3)
  • e2e/protect-app/public/typescript.svg is excluded by !**/*.svg
  • e2e/protect-app/public/vite.svg is excluded by !**/*.svg
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (25)
  • .changeset/config.json
  • AGENTS.md
  • e2e/protect-app/.gitignore
  • e2e/protect-app/eslint.config.mjs
  • e2e/protect-app/package.json
  • e2e/protect-app/public/callback.html
  • e2e/protect-app/src/index.html
  • e2e/protect-app/src/protect-native.html
  • e2e/protect-app/src/protect-native.ts
  • e2e/protect-app/src/style.css
  • e2e/protect-app/tsconfig.app.json
  • e2e/protect-app/tsconfig.json
  • e2e/protect-app/tsconfig.spec.json
  • e2e/protect-app/vite-env.d.ts
  • e2e/protect-app/vite.config.ts
  • e2e/protect-suites/eslint.config.mjs
  • e2e/protect-suites/package.json
  • e2e/protect-suites/playwright.config.ts
  • e2e/protect-suites/src/protect-native.test.ts
  • e2e/protect-suites/src/utils/demo-user.ts
  • e2e/protect-suites/tsconfig.e2e.json
  • e2e/protect-suites/tsconfig.json
  • packages/davinci-client/api-report/davinci-client.api.md
  • packages/davinci-client/api-report/davinci-client.types.api.md
  • tsconfig.json
💤 Files with no reviewable changes (23)
  • e2e/protect-app/public/callback.html
  • .changeset/config.json
  • e2e/protect-suites/tsconfig.e2e.json
  • e2e/protect-suites/src/utils/demo-user.ts
  • e2e/protect-app/eslint.config.mjs
  • e2e/protect-app/tsconfig.spec.json
  • e2e/protect-app/tsconfig.app.json
  • e2e/protect-app/src/index.html
  • e2e/protect-suites/src/protect-native.test.ts
  • tsconfig.json
  • e2e/protect-app/src/style.css
  • e2e/protect-app/src/protect-native.html
  • AGENTS.md
  • e2e/protect-app/vite.config.ts
  • e2e/protect-app/.gitignore
  • e2e/protect-app/vite-env.d.ts
  • e2e/protect-suites/tsconfig.json
  • e2e/protect-suites/package.json
  • e2e/protect-suites/playwright.config.ts
  • e2e/protect-app/src/protect-native.ts
  • e2e/protect-app/package.json
  • e2e/protect-app/tsconfig.json
  • e2e/protect-suites/eslint.config.mjs

📝 Walkthrough

Walkthrough

Protect E2E tests now capture risk data from authentication callbacks and validate its format. The journey client is added to the journey suite. Standalone Protect projects are removed. DaVinci API reports reorder existing union members.

Changes

Protect E2E consolidation

Layer / File(s) Summary
Journey Protect validation and project wiring
e2e/journey-suites/package.json, e2e/journey-suites/tsconfig.json, e2e/journey-suites/src/protect.test.ts
Adds the journey client dependency and project reference. The test captures typed Protect callback data and validates the R/o/ risk-data format.
DaVinci Protect flow validation
e2e/davinci-app/server-configs.ts, e2e/davinci-suites/src/protect.test.ts
Updates the AutoCollectors comment, flow identifiers, and navigation URLs. The tests capture risk data from matching requests and validate its format.
Standalone Protect project removal
e2e/protect-app/*, e2e/protect-suites/*, AGENTS.md, tsconfig.json, .changeset/config.json
Removes the standalone Protect app and suite, their configuration, project references, and related repository documentation and Changesets entries.
DaVinci API report alignment
packages/davinci-client/api-report/*
Reorders existing DaVinci node-state union members without changing their types or fields.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Mergeability Score: ⚪ Minimal · up to 8970b

This PR updates end-to-end test coverage and removes the standalone Protect test app without supplied evidence of a current correctness or production-impact risk; no actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested reviewers: cerebrl, ryanbas21, steingabriel

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: improving Protect end-to-end tests.
Description check ✅ Passed The description includes the Jira ticket and a clear summary of test updates, assertions, flow migration, and removed login assertions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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-5240-protect-e2e

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.

@nx-cloud

nx-cloud Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 8970b3a

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

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-13 16:17:57 UTC

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@e2e/journey-suites/src/protect.test.ts`:
- Around line 24-30: Move request.postDataJSON() in each request listener after
checking that the method is POST and the URL targets /authenticate (or the
listener’s existing target), so unrelated requests are filtered before body
parsing. Apply this in e2e/journey-suites/src/protect.test.ts:24-30, both
customHTMLTemplate and customForm listeners in
e2e/davinci-suites/src/protect.test.ts:26-34 and 71-79, and
e2e/protect-suites/src/protect-native.test.ts:28-34; preserve the existing
payload validation and handling after the filter.

In `@e2e/protect-suites/playwright.config.ts`:
- Line 3: Correct the copyright headers: in
e2e/protect-suites/playwright.config.ts lines 3-3, use the repository-standard
year range without the extra space and change the wording to “All rights
reserved.”; in e2e/protect-suites/src/protect-native.test.ts lines 3-3, change
“All right reserved.” to “All rights reserved.”
🪄 Autofix

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 Plus

Run ID: e5a96dcf-86f5-4a09-8559-8f80beae67df

📥 Commits

Reviewing files that changed from the base of the PR and between ef9a7ee and 895d492.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • e2e/davinci-app/server-configs.ts
  • e2e/davinci-suites/src/protect.test.ts
  • e2e/journey-suites/package.json
  • e2e/journey-suites/src/protect.test.ts
  • e2e/journey-suites/tsconfig.json
  • e2e/protect-suites/package.json
  • e2e/protect-suites/playwright.config.ts
  • e2e/protect-suites/src/protect-native.test.ts

Comment on lines 24 to +30
page.on('request', (request) => {
if (request.url().includes('/authenticate') && request.method() === 'POST') {
try {
const postData = request.postData();
if (postData) {
const body = JSON.parse(postData);
const callbacks = body.callbacks || [];
for (const callback of callbacks) {
if (callback.type === 'PingOneProtectEvaluationCallback') {
const inputs = callback.input || [];
for (const input of inputs) {
if (input.name === 'IDToken1signals' && input.value) {
protectSignalsData = input.value;
}
}
}
}
}
} catch {
// Ignore parsing errors
const method = request.method();
const requestUrl = request.url();
const payload = request.postDataJSON();

// Only process POST requests with JSON payloads
if (method === 'POST' && payload && requestUrl.includes('/authenticate')) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

For the Playwright version declared in this repository, does Request.postDataJSON() throw when the request body is not valid JSON?

💡 Result:

Yes, the Request.postDataJSON method in Playwright throws an error if the request body is present but cannot be parsed as valid JSON [1]. Internally, the method first checks if the request has body data [1]. If it does, and the Content-Type is not application/x-www-form-urlencoded, it attempts to parse the data using JSON.parse [1]. If this parsing fails, it explicitly throws an Error with the message "POST data is not a valid JSON object: " followed by the content of the request body [1]. This behavior is confirmed by Playwright's internal source code [1] and its test suite, which includes test cases explicitly verifying that the method throws an exception when provided with invalid JSON [2].

Citations:


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- Playwright declarations ---'
rg -n --hidden -S '"@?playwright/test"|"playwright"|playwright' \
  package.json package-lock.json yarn.lock pnpm-lock.yaml \
  e2e 2>/dev/null | head -200 || true

printf '%s\n' '--- Target listener implementations ---'
for f in \
  e2e/journey-suites/src/protect.test.ts \
  e2e/davinci-suites/src/protect.test.ts \
  e2e/protect-suites/src/protect-native.test.ts
do
  echo "--- $f ---"
  sed -n '1,115p' "$f"
done

Repository: ForgeRock/ping-javascript-sdk

Length of output: 15908


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from urllib.request import urlopen

url = "https://raw.githubusercontent.com/microsoft/playwright/v1.59.1/packages/playwright-core/src/client/network.ts"
text = urlopen(url, timeout=10).read().decode()
needle = "postDataJSON()"
start = text.index(needle)
print(text[start:start + 900])
PY

printf '%s\n' '--- Exact lockfile resolution ---'
sed -n '11115,11130p' pnpm-lock.yaml
sed -n '16035,16045p' pnpm-lock.yaml

Repository: ForgeRock/ping-javascript-sdk

Length of output: 2453


Filter each request before parsing its body.

request.postDataJSON() can throw when an unrelated request has a non-empty, invalid JSON body. Check the method and target URL before calling it in all four listeners:

  • e2e/journey-suites/src/protect.test.ts
  • e2e/davinci-suites/src/protect.test.ts (customHTMLTemplate and customForm)
  • e2e/protect-suites/src/protect-native.test.ts
📍 Affects 3 files
  • e2e/journey-suites/src/protect.test.ts#L24-L30 (this comment)
  • e2e/davinci-suites/src/protect.test.ts#L26-L34
  • e2e/davinci-suites/src/protect.test.ts#L71-L79
  • e2e/protect-suites/src/protect-native.test.ts#L28-L34
🤖 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 `@e2e/journey-suites/src/protect.test.ts` around lines 24 - 30, Move
request.postDataJSON() in each request listener after checking that the method
is POST and the URL targets /authenticate (or the listener’s existing target),
so unrelated requests are filtered before body parsing. Apply this in
e2e/journey-suites/src/protect.test.ts:24-30, both customHTMLTemplate and
customForm listeners in e2e/davinci-suites/src/protect.test.ts:26-34 and 71-79,
and e2e/protect-suites/src/protect-native.test.ts:28-34; preserve the existing
payload validation and handling after the filter.

Comment thread e2e/protect-suites/playwright.config.ts Outdated
@pkg-pr-new

pkg-pr-new Bot commented Aug 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

@forgerock/davinci-client

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

@forgerock/device-client

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

@forgerock/journey-client

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

@forgerock/oidc-client

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

@forgerock/protect

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

@forgerock/recognize

pnpm add https://pkg.pr.new/@forgerock/recognize@756

@forgerock/sdk-types

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

@forgerock/sdk-utilities

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

@forgerock/iframe-manager

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

@forgerock/sdk-logger

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

@forgerock/sdk-oidc

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

@forgerock/sdk-request-middleware

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

@forgerock/storage

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

commit: 8970b3a

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Deployed 0472f84 to https://ForgeRock.github.io/ping-javascript-sdk/pr-756/0472f8475e039a74e7155a3e18e0caa2fc66fc30 branch gh-pages in ForgeRock/ping-javascript-sdk

@codecov-commenter

codecov-commenter commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 24.11%. Comparing base (eafe277) to head (8970b3a).
⚠️ Report is 104 commits behind head on main.

❌ Your project status has failed because the head coverage (24.11%) is below the target coverage (40.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #756      +/-   ##
==========================================
+ Coverage   18.07%   24.11%   +6.03%     
==========================================
  Files         155      162       +7     
  Lines       24398    25787    +1389     
  Branches     1203     1686     +483     
==========================================
+ Hits         4410     6218    +1808     
+ Misses      19988    19569     -419     

see 18 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

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Size Analysis

📦 Bundle Size Analysis

🆕 New Packages

🆕 @forgerock/journey-client - 92.6 KB (new)
🆕 @forgerock/journey-client - 0.0 KB (new)
🆕 @forgerock/device-client - 10.0 KB (new)
🆕 @forgerock/device-client - 0.0 KB (new)

➖ No Changes

@forgerock/davinci-client - 59.1 KB
@forgerock/sdk-types - 9.1 KB
@forgerock/sdk-logger - 1.6 KB
@forgerock/iframe-manager - 3.2 KB
@forgerock/sdk-oidc - 5.7 KB
@forgerock/storage - 1.5 KB
@forgerock/sdk-request-middleware - 4.6 KB
@forgerock/sdk-utilities - 18.6 KB
@forgerock/oidc-client - 35.4 KB
@forgerock/recognize - 4284.4 KB
@forgerock/protect - 144.6 KB


15 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

@ancheetah
ancheetah force-pushed the SDKS-5240-protect-e2e branch from 895d492 to 834c344 Compare August 12, 2026 20:32
@ancheetah
ancheetah merged commit f7d4c9b into main Aug 13, 2026
9 checks passed
@ancheetah
ancheetah deleted the SDKS-5240-protect-e2e branch August 13, 2026 19:08
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.

4 participants