Skip to content

Remove skip and fix billing tests#3818

Merged
steven-tey merged 1 commit into
mainfrom
e2e-billing-tests
May 1, 2026
Merged

Remove skip and fix billing tests#3818
steven-tey merged 1 commit into
mainfrom
e2e-billing-tests

Conversation

@pepeladeira

@pepeladeira pepeladeira commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Tests
    • Enabled previously skipped billing upgrade flow tests with improved assertions and stricter UI element targeting.
    • Added test helper for billing upgrade flow that bypasses external payment processor redirects.
    • Standardized timeout handling across test suites.

@vercel

vercel Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
dub Ready Ready Preview Apr 27, 2026 11:15pm

Request Review

@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Test ID Addition
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page.tsx
Adds deterministic data-testid attribute to the billing plan column div element for test targeting.
Billing Test Infrastructure
apps/web/playwright/workspaces/billing-mocks.ts, apps/web/playwright/workspaces/billing-trial.spec.ts
Introduces new Playwright helper finishBillingUpgradeCheckoutWithoutStripeRedirect that applies mocked workspace state and navigates directly to success URL. Enables previously skipped tests with updated flow: now waits for POST /api/workspaces/:slug/billing/upgrade response, uses new mock helper, targets UI via testId, patches Stripe redirect behavior, and adjusts assertions and timeout constants.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • steven-tey

Poem

🐰 A path through billing flows we weave,

No Stripe redirects to deceive,

Test IDs placed with utmost care,

E2E tests await with flair,

Success URLs, mocks aligned—

Checkout testing, perfectly designed! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: enabling previously skipped billing tests and fixing their implementation to work with the new E2E testing approach.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 e2e-billing-tests

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 patches window.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

📥 Commits

Reviewing files that changed from the base of the PR and between bceda9a and bc1ee82.

📒 Files selected for processing (3)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page.tsx
  • apps/web/playwright/workspaces/billing-mocks.ts
  • apps/web/playwright/workspaces/billing-trial.spec.ts

Comment on lines +196 to +200
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)}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

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.

@steven-tey steven-tey merged commit 4488323 into main May 1, 2026
12 checks passed
@steven-tey steven-tey deleted the e2e-billing-tests branch May 1, 2026 21:30
@coderabbitai coderabbitai Bot mentioned this pull request May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants