The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Revert "Remove skip and fix billing tests" (#3846)
Steven Tey0496f0be18e9
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page.tsxindex 4ece8f458f..73e978a919 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page.tsx@@ -188,7 +188,6 @@ export default function WorkspaceBillingUpgradePage() {return (<divkey={plan.name}- data-testid={`billing-upgrade-column-${plan.name.toLowerCase()}`}className={cn("relative top-0 flex h-full flex-col gap-6 bg-white p-5 lg:p-3 xl:p-5","max-lg:rounded-xl max-lg:border max-lg:border-neutral-200",diff --git a/apps/web/playwright/workspaces/billing-mocks.ts b/apps/web/playwright/workspaces/billing-mocks.tsindex 171a24154a..0458125237 100644--- a/apps/web/playwright/workspaces/billing-mocks.ts+++ b/apps/web/playwright/workspaces/billing-mocks.ts@@ -180,28 +180,6 @@ export async function finishOnboardingCheckoutWithoutStripeRedirect();}-/**- * After a mocked billing upgrade POST from dashboard settings (non-onboarding success_url),- * skip `redirectToCheckout` — same rationale as {@link finishOnboardingCheckoutWithoutStripeRedirect}.- */-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 page.goto(- `${origin}/${slug}?upgraded=true&plan=${encodeURIComponent(plan)}&period=${encodeURIComponent(period)}`,- { waitUntil: "load" },- );-}-/*** Intercepts the upgrade API so the dev server never calls Stripe, and* intercepts Hosted Checkout navigation so Stripe never loads a fake session iddiff --git a/apps/web/playwright/workspaces/billing-trial.spec.ts b/apps/web/playwright/workspaces/billing-trial.spec.tsindex ef3c40b87a..cac657d0d8 100644--- a/apps/web/playwright/workspaces/billing-trial.spec.ts+++ b/apps/web/playwright/workspaces/billing-trial.spec.ts@@ -3,27 +3,28 @@ import { expect, test } from "@playwright/test";import {applyMockTrialToWorkspace,captureWorkspaceBillingTrialSnapshot,- finishBillingUpgradeCheckoutWithoutStripeRedirect,installBillingCheckoutMocks,- patchStripeRedirectStubForE2E,restoreWorkspaceBillingTrialSnapshot,type BillingMockTrialWorkspaceSnapshot,} from "./billing-mocks";-const STEP_NAV_TIMEOUT = 60_000;+function matchesDashboardOrigin(url: URL, baseURL: string) {+ const base = new URL(baseURL);+ return url.hostname === base.hostname && url.port === base.port;+}-test.describe("Billing trial checkout", () => {+test.skip("Billing trial checkout", () => {test("select Pro, success redirect, trial state and UI", async ({page,baseURL,}) => {- test.setTimeout(120_000);-const dashboardOrigin = baseURL ?? "http://app.localhost:8888";+ // Discover the workspace created during onboardingconst res = await page.request.get("/api/workspaces");expect(res.ok()).toBeTruthy();const workspaces = (await res.json()) as { plan: string; slug: string }[];+ // find the free workspace (from onboarding-dub-links.spec.ts)const freeWorkspace = workspaces.find((w) => w.plan === "free");if (!freeWorkspace) {throw new Error("No free workspace found");@@ -34,52 +35,39 @@ test.describe("Billing trial checkout", () => {slug,baseURL: dashboardOrigin,});- await patchStripeRedirectStubForE2E(page);await page.goto(`/${slug}/settings/billing/upgrade`);await expect(page.getByRole("heading", { name: "Plans", exact: true }),- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });+ ).toBeVisible({ timeout: 30_000 });- const proColumn = page.getByTestId("billing-upgrade-column-pro");- const upgradeButton = proColumn.getByRole("button", { name: "Upgrade" }).or(- proColumn.getByRole("button", {+ // CTA: billing may show "Upgrade" or checkout trial copy from UpgradePlanButton.+ const upgradeButton = page.getByRole("button", { name: "Upgrade" }).or(+ page.getByRole("button", {name: new RegExp(`Start ${DUB_TRIAL_PERIOD_DAYS}-day trial`),}),);- await expect(upgradeButton).toBeVisible({ timeout: STEP_NAV_TIMEOUT });- await expect(upgradeButton).toBeEnabled({ timeout: STEP_NAV_TIMEOUT });+ await expect(upgradeButton.first()).toBeVisible();+ await upgradeButton.first().click();- const billingUpgradePost = page.waitForResponse(- (r) =>- r.request().method() === "POST" &&- r.url().includes(`/api/workspaces/${slug}/billing/upgrade`),- { timeout: STEP_NAV_TIMEOUT },+ await page.waitForURL(+ (u) => {+ const url = new URL(u);+ return (+ matchesDashboardOrigin(url, dashboardOrigin) &&+ url.searchParams.get("upgraded") === "true"+ );+ },+ { timeout: 30_000, waitUntil: "domcontentloaded" },);- await upgradeButton.click();-- const upgradeRes = await billingUpgradePost;- if (!upgradeRes.ok()) {- throw new Error(- `billing/upgrade failed: HTTP ${upgradeRes.status()} ${await upgradeRes.text()}`,- );- }-- await finishBillingUpgradeCheckoutWithoutStripeRedirect(page, {- slug,- baseURL: dashboardOrigin,- plan: "pro",- period: "monthly",- });-await expect.poll(async () => {- const r = await page.request.get(`/api/workspaces/${slug}`);- if (!r.ok()) return null;- const body = (await r.json()) as { trialEndsAt?: string | null };+ const res = await page.request.get(`/api/workspaces/${slug}`);+ if (!res.ok()) return null;+ const body = (await res.json()) as { trialEndsAt?: string | null };return body.trialEndsAt ?? null;},{@@ -93,17 +81,17 @@ test.describe("Billing trial checkout", () => {page.getByRole("heading", {name: /Dub Pro looks good on you/i,}),- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });+ ).toBeVisible({ timeout: 15_000 });await page.getByRole("button", { name: "View dashboard" }).click();await expect(page.getByText("Free trial", { exact: true })).toBeVisible({- timeout: STEP_NAV_TIMEOUT,+ timeout: 15_000,});});});-test.describe("Free trial user navigation", () => {+test.skip("Free trial user navigation", () => {let slug: string;let workspaceId: string;let preMockTrialWorkspace: BillingMockTrialWorkspaceSnapshot | undefined;@@ -131,14 +119,12 @@ test.describe("Free trial user navigation", () => {await page.goto(`/${slug}/settings/billing`);await expect(page.getByText(/Trial ends on/)).toBeVisible({- timeout: STEP_NAV_TIMEOUT,+ timeout: 15_000,});await expect(page.getByRole("button", { name: "Start paid plan" }),- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });- await expect(page.getByRole("link", { name: "View plans" })).toBeVisible({- timeout: STEP_NAV_TIMEOUT,- });+ ).toBeVisible();+ await expect(page.getByRole("link", { name: "View plans" })).toBeVisible();});test("upgrade page shows Activate plan for current Pro plan", async ({@@ -148,10 +134,10 @@ test.describe("Free trial user navigation", () => {await expect(page.getByRole("heading", { name: "Plans", exact: true }),- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });+ ).toBeVisible({ timeout: 30_000 });await expect(page.getByRole("button", { name: "Activate plan" }),- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });+ ).toBeVisible();});test("activating plan from billing page shows upgraded modal", async ({@@ -159,9 +145,8 @@ test.describe("Free trial user navigation", () => {}) => {await page.route((url) =>- String(url).includes(- `/api/workspaces/${workspaceId}/billing/activate-paid-plan`,- ),+ url.pathname ===+ `/api/workspaces/${workspaceId}/billing/activate-paid-plan`,async (route) => {if (route.request().method() !== "POST") return route.continue();await route.fulfill({@@ -174,18 +159,22 @@ test.describe("Free trial user navigation", () => {await page.goto(`/${slug}/settings/billing`);+ // Open the confirmation modalawait page.getByRole("button", { name: "Start paid plan" }).click();await expect(page.getByRole("heading", { name: "Plan start confirmation" }),- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });+ ).toBeVisible();await expect(page.getByText("You'll be charged today and your trial will end."),- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });+ ).toBeVisible();+ // Confirm — triggers the mocked activate-paid-plan POST.+ // Two "Start paid plan" buttons exist: the page-level CTA and the modal confirm.await page.getByRole("button", { name: "Start paid plan" }).last().click();+ // Upgraded modal appears when ?upgraded=true lands in the URLawait expect(- page.getByRole("heading", { name: /Dub Business looks good on you/i }),- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });+ page.getByRole("heading", { name: /Dub Pro looks good on you/i }),+ ).toBeVisible({ timeout: 15_000 });});});