Remove skip and fix billing tests#3818
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe changes add test infrastructure and UI identifiers to support Playwright E2E testing of the billing upgrade flow without relying on Stripe redirects. Previously skipped tests are enabled with updated assertions, API response handling, and navigation logic. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/web/playwright/workspaces/billing-trial.spec.ts (1)
37-37: Remove the redundant Stripe stub patch call.
installBillingCheckoutMocks(...)already patcheswindow.Stripe, so Line 37 is duplicate in this flow.♻️ Proposed cleanup
await installBillingCheckoutMocks(page, { slug, baseURL: dashboardOrigin, }); - await patchStripeRedirectStubForE2E(page);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/playwright/workspaces/billing-trial.spec.ts` at line 37, Remove the redundant call to patchStripeRedirectStubForE2E(page) because installBillingCheckoutMocks(...) already patches window.Stripe; locate the invocation of patchStripeRedirectStubForE2E in the billing-trial.spec.ts test flow and delete that single await patchStripeRedirectStubForE2E(page); line so only installBillingCheckoutMocks(...) remains to set up the Stripe stub.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web/playwright/workspaces/billing-mocks.ts`:
- Around line 196-200: The mock DB state is always set to a Business/monthly
trial by applyMockTrialToWorkspace while page.goto uses the caller-provided
plan/period, causing potential test drift; update applyMockTrialToWorkspace to
accept plan and period (or add a new helper like
applyMockTrialToWorkspaceWithPlan) and use those values when creating the mocked
workspace/trial, then update the caller in billing-mocks.ts to pass the decoded
plan and period from options (const { plan, period } = options) so the mock
state and the URL
(page.goto(`${origin}/${slug}?upgraded=true&plan=${encodeURIComponent(plan)}&period=${encodeURIComponent(period)}`))
remain consistent.
---
Nitpick comments:
In `@apps/web/playwright/workspaces/billing-trial.spec.ts`:
- Line 37: Remove the redundant call to patchStripeRedirectStubForE2E(page)
because installBillingCheckoutMocks(...) already patches window.Stripe; locate
the invocation of patchStripeRedirectStubForE2E in the billing-trial.spec.ts
test flow and delete that single await patchStripeRedirectStubForE2E(page); line
so only installBillingCheckoutMocks(...) remains to set up the Stripe stub.
🪄 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: 9c36c04d-fa50-4d9f-8024-4fe9d9633aba
📒 Files selected for processing (3)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page.tsxapps/web/playwright/workspaces/billing-mocks.tsapps/web/playwright/workspaces/billing-trial.spec.ts
| const { slug, baseURL, plan = "pro", period = "monthly" } = options; | ||
| const origin = baseURL.replace(/\/$/, ""); | ||
| await applyMockTrialToWorkspace(slug); | ||
| await page.goto( | ||
| `${origin}/${slug}?upgraded=true&plan=${encodeURIComponent(plan)}&period=${encodeURIComponent(period)}`, |
There was a problem hiding this comment.
Mocked DB state can diverge from the success URL plan/period.
Line 198 always applies Business/monthly trial state, while Line 200 encodes caller-provided plan/period. That mismatch can mask billing regressions in E2E.
🔧 Proposed fix
export async function finishBillingUpgradeCheckoutWithoutStripeRedirect(
page: Page,
options: {
slug: string;
baseURL: string;
plan?: string;
period?: string;
},
) {
const { slug, baseURL, plan = "pro", period = "monthly" } = options;
const origin = baseURL.replace(/\/$/, "");
await applyMockTrialToWorkspace(slug);
+ await prisma.project.update({
+ where: { slug },
+ data: {
+ plan,
+ planPeriod: period,
+ },
+ });
await page.goto(
`${origin}/${slug}?upgraded=true&plan=${encodeURIComponent(plan)}&period=${encodeURIComponent(period)}`,
{ waitUntil: "load" },
);
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web/playwright/workspaces/billing-mocks.ts` around lines 196 - 200, The
mock DB state is always set to a Business/monthly trial by
applyMockTrialToWorkspace while page.goto uses the caller-provided plan/period,
causing potential test drift; update applyMockTrialToWorkspace to accept plan
and period (or add a new helper like applyMockTrialToWorkspaceWithPlan) and use
those values when creating the mocked workspace/trial, then update the caller in
billing-mocks.ts to pass the decoded plan and period from options (const { plan,
period } = options) so the mock state and the URL
(page.goto(`${origin}/${slug}?upgraded=true&plan=${encodeURIComponent(plan)}&period=${encodeURIComponent(period)}`))
remain consistent.
Summary by CodeRabbit