-
Notifications
You must be signed in to change notification settings - Fork 407
chore(e2e): E2e tests for trials #6607
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
Conversation
🦋 Changeset detectedLatest commit: 3aaf59b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
📝 WalkthroughWalkthroughAdds a changeset entry for a patch release of @clerk/testing mentioning updates to click events for trial-related labels. Adds integration tests in integration/tests/pricing-table.test.ts: a test that clicking a trial plan when signed out redirects to sign-in, and a (duplicated in the diff) test that starts a free trial subscription for a new user including the checkout/payment flow and cleanup. Updates Playwright page objects: expands the checkout action button matcher to include "start" and extends pricing table CTA matching to include "Start N-day free trial". Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (8)**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
integration/**📄 CodeRabbit inference engine (.cursor/rules/global.mdc)
Files:
integration/**/*📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Files:
integration/**/*.{test,spec}.{js,ts}📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Files:
**/*.{js,ts,tsx,jsx}📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Files:
**/*⚙️ CodeRabbit configuration file
Files:
🧬 Code graph analysis (1)integration/tests/pricing-table.test.ts (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). (4)
🔇 Additional comments (2)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
packages/testing/src/playwright/unstable/page-objects/checkout.ts (1)
35-35: Tighten selector to avoid accidental matches (e.g., “Get started”) and cover saved-card flowsUsing
/start/iis broad and can match “Get started” or similar non-primary CTAs in the drawer. Also, some flows expose a “Pay with test card” primary action, which the current regex won’t click.Refine the pattern to:
- Explicitly match “Start … free trial” (and common variants).
- Include “Pay with test card”.
- Keep “Subscribe” and “Pay $” paths.
Apply this diff:
- await self.root.getByRole('button', { name: /subscribe|pay\s\$|start/i }).click(); + await self.root + .getByRole('button', { + // Match exact subscribe, "Pay $..", saved-card CTA, and common trial CTAs. + name: /^(?:subscribe|pay\s\$\d|pay with test card|start(?:\s+\d+(?:[-‑–—]\s*)?day)?\s+free\s+trial|start\s+trial)$/i, + }) + .click();If you prefer extra resilience over a single regex, I can provide a small helper that iterates a list of candidate locators and clicks the first visible one.
packages/testing/src/playwright/unstable/page-objects/pricingTable.ts (2)
64-65: Expose trial CTA via getPlanCardCTA for consistencygetPlanCardCTA doesn’t currently include the trial CTA text you support in startCheckout. This makes the API uneven and forces tests to reach for getByText when dealing with trials.
Apply this diff to include trial CTAs and keep the regex future-proof against dash variations:
- return locators.footer(planSlug).getByRole('button', { - name: /get|switch|subscribe/i, - }); + return locators.footer(planSlug).getByRole('button', { + name: /get|switch|subscribe|start(?:\s+\d+(?:[-‑–—]\s*)?day)?\s+free\s+trial/i, + });
77-81: Broaden trial CTA regex to handle dash variants and non-day-count labelsThe pattern
/Start \d+-day free trial/iwill miss:
- Non-breaking or en dash characters (‑, –).
- Labels without a day count (e.g., “Start free trial”).
- Extra whitespace.
Apply this diff:
- const targetButtonName = - shouldSwitch === true - ? 'Switch to this plan' - : shouldSwitch === false - ? /subscribe/i - : /get|switch|subscribe|Start \d+-day free trial/i; + const targetButtonName = + shouldSwitch === true + ? 'Switch to this plan' + : shouldSwitch === false + ? /^subscribe$/i + : /get|switch|subscribe|start(?:\s+\d+(?:[-‑–—]\s*)?day)?\s+free\s+trial/i;This keeps the intent while reducing flakiness from typographical or content changes.
integration/tests/pricing-table.test.ts (2)
66-76: Assert on the checkout root rather than free text for stabilityChecking “Checkout” text can be brittle (copy changes, localization). Asserting on the drawer root is more robust.
Apply this diff:
- await u.po.signIn.waitForMounted(); - await expect(u.po.page.getByText('Checkout')).toBeHidden(); + await u.po.signIn.waitForMounted(); + await expect(u.po.checkout.root).toBeHidden();
258-306: Harden trial flow assertions and sequencing to reduce flakinessA few tweaks will make this e2e much more resilient:
- Prefer role-based queries for the CTA over raw text.
- Make the trial CTA regex tolerant (with/without day count).
- Wait for Stripe elements before filling the card.
- Soften the success assertion to handle copy changes across environments.
Apply this diff:
- // Verify trial plan is displayed with trial CTA - // Note: This assumes there's a plan with trial enabled in the test environment - // The button text should show "Start [X]-day free trial" for trial-enabled plans - await expect(u.po.page.getByText(/Start \d+-day free trial/i)).toBeVisible(); + // Verify trial plan is displayed with a trial CTA + await expect( + u.po.page.getByRole('button', { name: /start(?:\s+\d+(?:[-‑–—]\s*)?day)?\s+free\s+trial/i }), + ).toBeVisible(); - // Start checkout for a trial plan (assuming 'pro' has trial enabled in test env) + // Start checkout for a trial plan await u.po.pricingTable.startCheckout({ planSlug: 'trial' }); await u.po.checkout.waitForMounted(); - // Verify checkout shows trial details - await expect(u.po.checkout.root.getByText('Checkout')).toBeVisible(); - await expect(u.po.checkout.root.getByText('Free trial')).toBeVisible(); - await expect(u.po.checkout.root.getByText('Total Due after')).toBeVisible(); + // Verify checkout shows trial details + await expect(u.po.checkout.root.getByRole('heading', { name: /^checkout$/i })).toBeVisible(); + await expect(u.po.checkout.root.getByText(/free trial/i)).toBeVisible(); + await expect(u.po.checkout.root.getByText(/total\s+due\s+after/i)).toBeVisible(); - await u.po.checkout.fillTestCard(); + await u.po.checkout.waitForStripeElements(); + await u.po.checkout.fillTestCard(); await u.po.checkout.clickPayOrSubscribe(); - await expect(u.po.checkout.root.getByText(/Trial.*successfully.*started/i)).toBeVisible(); + // Trial start confirmation text can vary; accept either "Success" or a trial-specific message + await expect( + u.po.checkout.root.getByText(/success|trial.*(success|started)/i).first(), + ).toBeVisible(); await u.po.checkout.confirmAndContinue();Optional: if test capacity allows, you could mark this trial test as serial to minimize any cross-test resource contention, but given the unique user it should be fine as-is.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
.changeset/thick-onions-strive.md(1 hunks)integration/tests/pricing-table.test.ts(2 hunks)packages/testing/src/playwright/unstable/page-objects/checkout.ts(1 hunks)packages/testing/src/playwright/unstable/page-objects/pricingTable.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/testing/src/playwright/unstable/page-objects/pricingTable.tspackages/testing/src/playwright/unstable/page-objects/checkout.tsintegration/tests/pricing-table.test.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/testing/src/playwright/unstable/page-objects/pricingTable.tspackages/testing/src/playwright/unstable/page-objects/checkout.tsintegration/tests/pricing-table.test.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/testing/src/playwright/unstable/page-objects/pricingTable.tspackages/testing/src/playwright/unstable/page-objects/checkout.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/testing/src/playwright/unstable/page-objects/pricingTable.tspackages/testing/src/playwright/unstable/page-objects/checkout.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/testing/src/playwright/unstable/page-objects/pricingTable.tspackages/testing/src/playwright/unstable/page-objects/checkout.tsintegration/tests/pricing-table.test.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/testing/src/playwright/unstable/page-objects/pricingTable.tspackages/testing/src/playwright/unstable/page-objects/checkout.tsintegration/tests/pricing-table.test.ts
**/*
⚙️ CodeRabbit configuration file
If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.
Files:
packages/testing/src/playwright/unstable/page-objects/pricingTable.tspackages/testing/src/playwright/unstable/page-objects/checkout.tsintegration/tests/pricing-table.test.ts
.changeset/**
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/thick-onions-strive.md
integration/**
📄 CodeRabbit inference engine (.cursor/rules/global.mdc)
Framework integration templates and E2E tests should be placed under the integration/ directory
Files:
integration/tests/pricing-table.test.ts
integration/**/*
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
End-to-end tests and integration templates must be located in the 'integration/' directory.
Files:
integration/tests/pricing-table.test.ts
integration/**/*.{test,spec}.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Integration tests should use Playwright.
Files:
integration/tests/pricing-table.test.ts
🧬 Code graph analysis (1)
integration/tests/pricing-table.test.ts (1)
integration/testUtils/index.ts (1)
createTestUtils(24-86)
⏰ 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). (6)
- GitHub Check: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
.changeset/thick-onions-strive.md (1)
1-6: Changeset reads well and matches the scope of the PRPatch bump for @clerk/testing with a concise description of the trial-related click support. No API changes implied. All good.
Description
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit