Skip to content

Conversation

@wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Nov 17, 2025

Description

Adding new integration instance for protect service. A follow up PR to #7227

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Introduced an initial dynamic Protect loader with support for enabling and rolling out Protect.
    • Added an environment preset to simplify testing with the Protect service.
  • Tests

    • Added tests verifying loader behavior for enabled, disabled, and unspecified rollout scenarios; moved setup/teardown into per-test scope.
  • Chores

    • Updated changeset description to clarify dynamic loader and rollout wording.

@changeset-bot
Copy link

changeset-bot bot commented Nov 17, 2025

⚠️ No Changeset found

Latest commit: 77273b9

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 changesets to release 22 packages
Name Type
@clerk/clerk-js Minor
@clerk/shared Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/types Patch
@clerk/vue Patch
@clerk/localizations Patch

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

@vercel
Copy link

vercel bot commented Nov 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Nov 17, 2025 9:50pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 17, 2025

Walkthrough

Introduces an initial Clerk Protect dynamic loader and related types via a changeset, adds a new test environment preset (withProtectService), inserts sample keys, and restructures integration tests to validate loader injection behavior for different protect_config.loader rollout values.

Changes

Cohort / File(s) Change Summary
Changeset
\.changeset/beige-sloths-provide.md
Rewrote the changeset description to state the introduction of an initial Clerk Protect dynamic loader and related types to support dynamic enabling and rollout.
Environment preset
integration/presets/envs.ts
Added withProtectService environment preset that clones the base preset, sets id: 'withProtectService', and maps private/public keys from the with-protect-service entry; exported alongside existing presets.
Protect service tests
integration/tests/protect-service.test.ts
Restructured tests for per-test setup/teardown under the Protect env; added tests asserting loader injection when protect_config.loader.rollout = 1.0, and no injection when rollout = 0.00 or when protect_config.loader is absent.
Keys sample
integration/.keys.json.sample
Added a new top-level "with-protect-service" key with pk and sk; adjusted JSON punctuation to maintain valid syntax.

Sequence Diagram(s)

sequenceDiagram
  participant Test as Test Runner
  participant Env as Mock Config Service
  participant Browser as Browser Page
  participant Clerk as Clerk JS Loader

  Note over Test,Env: configure protect_config.loader rollout
  Test->>Env: set protect_config.loader = { rollout: X }
  Test->>Browser: navigate to app page
  Browser->>Clerk: load Clerk JS
  Clerk-->>Browser: evaluate protect_config.loader
  alt rollout == 1.0
    Clerk->>Browser: inject protect loader element
    Browser-->>Test: detect loader element (count > 0)
  else rollout == 0.00 or not set
    Clerk-->>Browser: do not inject loader
    Browser-->>Test: detect no loader element (count == 0)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review integration/tests/protect-service.test.ts for async/await correctness, scope of per-test setup/teardown, and that assertions run inside test bodies.
  • Verify integration/presets/envs.ts follows existing preset cloning/key mapping conventions.
  • Check integration/.keys.json.sample for valid JSON punctuation and correct key names.

Poem

🐇 I hopped into code at first light,
A tiny loader tucked in tight.
Tests counted rollouts, watched the gate,
Whether on or off, we celebrate.
✨🛡️

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a new test instance for the protect service, which is reflected across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/with-protect-service

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4274498 and 77273b9.

📒 Files selected for processing (1)
  • integration/.keys.json.sample (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
integration/.keys.json.sample (1)

61-65: LGTM! JSON structure is valid and follows existing conventions.

The new with-protect-service entry is correctly formatted with no trailing comma after the last property. The format and naming convention are consistent with all other entries in this sample file.


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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 17, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7242

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7242

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7242

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7242

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7242

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7242

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7242

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@7242

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7242

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7242

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7242

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7242

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7242

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7242

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@7242

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7242

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7242

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7242

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7242

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7242

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7242

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7242

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7242

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7242

commit: 77273b9

Copy link
Contributor

@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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7be8f45 and 17c288b.

📒 Files selected for processing (3)
  • .changeset/beige-sloths-provide.md (1 hunks)
  • integration/presets/envs.ts (2 hunks)
  • integration/tests/protect-service.test.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
integration/tests/protect-service.test.ts (2)
integration/testUtils/index.ts (1)
  • createTestUtils (24-86)
integration/presets/index.ts (1)
  • appConfigs (15-32)
🪛 LanguageTool
.changeset/beige-sloths-provide.md

[grammar] ~6-~6: Ensure spelling is correct
Context: ...pes to support dynamically enabling and rollout out protect in the environment.

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (33)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (5)
integration/presets/envs.ts (1)

221-221: LGTM!

The export is correctly added to the envs object, making the new environment preset available for use in tests.

integration/tests/protect-service.test.ts (4)

20-27: LGTM!

The test suite correctly uses the new withProtectService environment preset and is properly configured for parallel execution with appropriate teardown.


29-47: LGTM!

The test properly verifies that a loader script is added when protect_config.loaders is configured with a rollout of 1.0. The per-test setup ensures proper isolation for parallel execution.


49-70: LGTM!

The test correctly verifies that no loader script is added when the rollout percentage is 0, even when the loader configuration is present. This is a valuable edge case test.


72-80: LGTM!

The test correctly verifies the baseline scenario where no loader is added when protect_config.loaders is not configured. The comment on lines 78-79 is helpful for understanding Playwright's behavior.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@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: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2e1c613 and 4274498.

📒 Files selected for processing (1)
  • integration/.keys.json.sample (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
integration/.keys.json.sample (1)

62-65: LGTM! New test instance entry follows the established pattern.

The new "with-protect-service" entry is consistent with existing entries and properly formatted for the sample configuration file.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Member

@jacekradko jacekradko left a comment

Choose a reason for hiding this comment

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

:shipit:

@wobsoriano wobsoriano enabled auto-merge (squash) November 17, 2025 21:53
@wobsoriano wobsoriano merged commit 51c3c4c into main Nov 17, 2025
45 checks passed
@wobsoriano wobsoriano deleted the rob/with-protect-service branch November 17, 2025 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants