Skip to content

chore(testing): Update util waitForStipeElements to accept a state #6204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2025

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Jun 27, 2025

Description

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

  • Bug Fixes

    • Improved test reliability by ensuring payment elements are correctly detected as hidden and then visible during payment failure and retry scenarios.
  • Tests

    • Updated tests to explicitly wait for payment elements to unmount and remount after a failed payment attempt, providing clearer validation of payment flow behavior.
  • Chores

    • Enhanced payment element helper to support waiting for elements to be either visible or hidden, enabling more precise test control.

@panteliselef panteliselef self-assigned this Jun 27, 2025
Copy link

changeset-bot bot commented Jun 27, 2025

🦋 Changeset detected

Latest commit: 099c591

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/testing Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link

vercel bot commented Jun 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2025 0:23am

Copy link
Contributor

coderabbitai bot commented Jun 27, 2025

📝 Walkthrough

Walkthrough

A patch was applied to the @clerk/testing package, specifically enhancing the waitForStripeElements helper to accept an optional state parameter, allowing it to wait for Stripe elements to be either 'visible' or 'hidden'. Corresponding updates were made in the test suite to utilize this new functionality, particularly in scenarios where the Stripe payment element unmounts and remounts after a failed payment attempt. The method signature for waitForStripeElements was updated to support this parameter, enabling more precise control over waiting for element visibility states during automated tests. No changes were made to exported or public entity declarations.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3929d76 and 099c591.

📒 Files selected for processing (2)
  • integration/tests/pricing-table.test.ts (1 hunks)
  • packages/testing/src/playwright/unstable/page-objects/checkout.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • integration/tests/pricing-table.test.ts
  • packages/testing/src/playwright/unstable/page-objects/checkout.ts
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between edc0bfd and 3929d76.

📒 Files selected for processing (3)
  • .changeset/eleven-days-sniff.md (1 hunks)
  • integration/tests/pricing-table.test.ts (1 hunks)
  • packages/testing/src/playwright/unstable/page-objects/checkout.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
`**/*.{js,ts,tsx,jsx}`: All code must pass ESLint checks with the project's configuration. Use Prettier for consistent code formatting.

**/*.{js,ts,tsx,jsx}: All code must pass ESLint checks with the project's configuration.
Use Prettier for consistent code formatting.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)

List of files the instruction was applied to:

  • integration/tests/pricing-table.test.ts
  • packages/testing/src/playwright/unstable/page-objects/checkout.ts
`**/*.{ts,tsx}`: Maintain comprehensive JSDoc comments for public APIs.

**/*.{ts,tsx}: Maintain comprehensive JSDoc comments for public APIs.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)

List of files the instruction was applied to:

  • integration/tests/pricing-table.test.ts
  • packages/testing/src/playwright/unstable/page-objects/checkout.ts
`**/*.{test,spec}.{js,ts,tsx,jsx}`: Unit tests are required for all new functionality.

**/*.{test,spec}.{js,ts,tsx,jsx}: Unit tests are required for all new functionality.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)

List of files the instruction was applied to:

  • integration/tests/pricing-table.test.ts
`integration/**`: Framework integration templates and E2E tests must be placed in the integration/ directory.

integration/**: Framework integration templates and E2E tests must be placed in the integration/ directory.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/global.mdc)

List of files the instruction was applied to:

  • integration/tests/pricing-table.test.ts
`**/*.ts`: Always define explicit return types for functions, especially public ...

**/*.ts: Always define explicit return types for functions, especially public APIs.
Use proper type annotations for variables and parameters where inference isn't clear.
Avoid any type; prefer unknown when type is uncertain, then narrow with type guards.
Use interface for object shapes that might be extended; use type for unions, primitives, and computed types.
Prefer readonly properties for immutable data structures.
Use private for internal implementation details, protected for inheritance, and public explicitly for clarity in public APIs.
Prefer composition and interfaces over deep inheritance chains; use mixins for shared behavior.
Use ES6 imports/exports consistently; avoid barrel files (index.ts re-exports) to prevent circular dependencies.
Use type-only imports (import type { ... }) where possible.
Use as const for literal types and the satisfies operator for type checking without widening.
Enable --incremental and --tsBuildInfoFile for faster builds.
Use ESLint with @typescript-eslint/recommended rules and Prettier for formatting.
Use lint-staged and Husky for pre-commit checks.
Use type-coverage to measure type safety.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/typescript.mdc)

List of files the instruction was applied to:

  • integration/tests/pricing-table.test.ts
  • packages/testing/src/playwright/unstable/page-objects/checkout.ts
`packages/**`: All publishable packages under the @clerk namespace must be located in the packages/ directory.

packages/**: All publishable packages under the @clerk namespace must be located in the packages/ directory.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/global.mdc)

List of files the instruction was applied to:

  • packages/testing/src/playwright/unstable/page-objects/checkout.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: dstaley
PR: clerk/javascript#6100
File: packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx:121-124
Timestamp: 2025-06-16T17:08:58.414Z
Learning: The @clerk/clerk-js package only supports browsers released in the last two years (since May 8, 2023), so modern CSS features like color-mix() are fully supported across all target browsers without requiring fallbacks.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/tasks/ForceOrganizationSelection.tsx:101-116
Timestamp: 2025-06-18T21:06:15.954Z
Learning: The Spinner component in packages/clerk-js has built-in accessibility attributes including aria-busy and aria-live='polite', making additional aria-label or screen reader text unnecessary for loading states.
.changeset/eleven-days-sniff.md (2)
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: dstaley
PR: clerk/javascript#6100
File: packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx:121-124
Timestamp: 2025-06-16T17:08:58.414Z
Learning: The @clerk/clerk-js package only supports browsers released in the last two years (since May 8, 2023), so modern CSS features like color-mix() are fully supported across all target browsers without requiring fallbacks.
integration/tests/pricing-table.test.ts (2)
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Unit tests are run with Jest and Vitest, integration tests with Playwright, and component testing with React Testing Library, demonstrating a layered testing strategy.
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
.changeset/eleven-days-sniff.md (1)

5-5: Verify helper function name consistency.

The changeset mentions waitForStripeElements but the actual implementation uses waitForStipeElements (missing 'r'). Ensure the documented name matches the actual function name in the codebase.

#!/bin/bash
# Description: Verify the actual function name used in the codebase
# Expected: Should find the function name and confirm spelling

# Search for both spellings to identify which is used
echo "Searching for waitForStripeElements (correct spelling):"
rg "waitForStripeElements" --type ts

echo -e "\nSearching for waitForStipeElements (missing 'r'):"
rg "waitForStipeElements" --type ts
integration/tests/pricing-table.test.ts (1)

312-314: Test logic correctly validates payment element lifecycle.

The test appropriately waits for the Stripe payment element to unmount (hidden) and then remount (visible) after a card decline error, which aligns with the expected behavior described in the PR objectives.

Note: If the method name waitForStipeElements is corrected to waitForStripeElements in the page object, this call site will need to be updated accordingly.

Copy link

pkg-pr-new bot commented Jun 27, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 099c591

@panteliselef panteliselef enabled auto-merge (squash) June 27, 2025 12:31
@panteliselef panteliselef merged commit 9fbce7d into main Jun 27, 2025
38 of 39 checks passed
@panteliselef panteliselef deleted the elef/update-wait-for-stripe-elements-util branch June 27, 2025 12:32
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.

3 participants