Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Locate Playwright UI controls with test IDs instead of labels. (#4469)

Kiran K6228bd511108
diff --git a/apps/web/app/(ee)/partners.dub.co/(auth-login-register)/(generic)/login/page.tsx b/apps/web/app/(ee)/partners.dub.co/(auth-login-register)/(generic)/login/page.tsx
index 482d47ed0f..47d322f01f 100644
--- a/apps/web/app/(ee)/partners.dub.co/(auth-login-register)/(generic)/login/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(auth-login-register)/(generic)/login/page.tsx
@@ -1,4 +1,5 @@
import { SSO_LOGIN_PROGRAMS } from "@/lib/auth/sso-login-programs";
+import { testIds } from "@/lib/e2e/test-ids";
import { getProgram } from "@/lib/fetchers/get-program";
import { AuthAlternativeBanner } from "@/ui/auth/auth-alternative-banner";
import LoginForm from "@/ui/auth/login/login-form";
@@ -70,7 +71,10 @@ export default async function LoginPage(props: {
<div className="relative w-full">
<AuthLayout showTerms="partners" className={cn(programSlug && "pt-20")}>
<div className="w-full max-w-sm">
- <h1 className="text-center text-xl font-semibold">
+ <h1
+ className="text-center text-xl font-semibold"
+ data-testid={testIds.auth.loginHeading}
+ >
Log in to your Dub Partner account
</h1>
<div className="mt-8">
diff --git a/apps/web/app/(ee)/partners.dub.co/(auth-login-register)/(generic)/register/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(auth-login-register)/(generic)/register/page-client.tsx
index e8392e0be9..44db26211c 100644
--- a/apps/web/app/(ee)/partners.dub.co/(auth-login-register)/(generic)/register/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(auth-login-register)/(generic)/register/page-client.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import { emailSchema } from "@/lib/zod/schemas/auth";
import { ApplicationAnalytics } from "@/ui/application-analytics";
import { AuthAlternativeBanner } from "@/ui/auth/auth-alternative-banner";
@@ -86,7 +87,10 @@ function Verify() {
<AuthLayout>
<div className="w-full max-w-sm">
<div className="flex flex-col items-center gap-1 text-center">
- <h3 className="text-center text-xl font-semibold">
+ <h3
+ className="text-center text-xl font-semibold"
+ data-testid={testIds.auth.verifyEmailHeading}
+ >
Verify your email address
</h3>
<p className="text-base font-medium text-neutral-500">
diff --git a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx
index 4a60b725e2..cf8d0b956b 100644
--- a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx
@@ -1,6 +1,7 @@
"use client";
import { parseActionError } from "@/lib/actions/parse-action-errors";
+import { testIds } from "@/lib/e2e/test-ids";
import { onboardPartnerAction } from "@/lib/actions/partners/onboard-partner";
import { getValidInternalRedirectPath } from "@/lib/middleware/utils/is-valid-internal-redirect";
import {
@@ -131,7 +132,10 @@ export function OnboardingForm({
</label>
<label>
- <span className="text-sm font-medium text-neutral-800">
+ <span
+ className="text-sm font-medium text-neutral-800"
+ data-testid={testIds.partnerOnboarding.profileImage}
+ >
Profile image
</span>
<div className="flex items-center gap-5">
@@ -164,7 +168,10 @@ export function OnboardingForm({
</label>
<label>
- <span className="text-sm font-medium text-neutral-800">
+ <span
+ className="text-sm font-medium text-neutral-800"
+ data-testid={testIds.partnerOnboarding.aboutYou}
+ >
About you
<span className="font-normal text-neutral-500"> (optional)</span>
</span>
@@ -192,7 +199,10 @@ export function OnboardingForm({
<LayoutGroup>
<div>
- <span className="text-sm font-medium text-neutral-800">
+ <span
+ className="text-sm font-medium text-neutral-800"
+ data-testid={testIds.partnerOnboarding.profileType}
+ >
Profile Type
</span>
<div className="mt-1.5">
@@ -272,6 +282,7 @@ export function OnboardingForm({
text="Continue"
className="mt-1.5"
loading={isPending || isSubmitting || isSubmitSuccessful}
+ data-testid={testIds.partnerOnboarding.continue}
/>
</motion.div>
</LayoutGroup>
diff --git a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/page.tsx b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/page.tsx
index 1533344d57..d4929a8af5 100644
--- a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/page.tsx
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { getSession } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { Suspense } from "react";
@@ -6,7 +7,10 @@ import { OnboardingForm } from "./onboarding-form";
export default function PartnerOnboarding() {
return (
<div className="mx-auto flex w-full max-w-[430px] flex-col items-center md:mt-4">
- <h1 className="animate-slide-up-fade text-center text-xl font-semibold [--offset:8px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]">
+ <h1
+ className="animate-slide-up-fade text-center text-xl font-semibold [--offset:8px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]"
+ data-testid={testIds.partnerOnboarding.profile}
+ >
Create your partner profile
</h1>
<div className="animate-slide-up-fade w-full pt-8 [--offset:10px] [animation-delay:500ms] [animation-duration:1s] [animation-fill-mode:both]">
diff --git a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/payouts/page.tsx b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/payouts/page.tsx
index 240b9acd60..254e91395d 100644
--- a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/payouts/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/payouts/page.tsx
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { getSession } from "@/lib/auth";
import { getPartnerPayoutMethods } from "@/lib/payouts/get-partner-payout-methods";
import { prisma } from "@/lib/prisma";
@@ -86,6 +87,7 @@ async function PayoutRSC() {
/>
<Link
href="/programs"
+ data-testid={testIds.partnerOnboarding.skip}
className="mt-6 block text-center text-sm font-medium text-neutral-500 transition-colors hover:text-neutral-800"
>
I'll complete this later
diff --git a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/payouts/payout-provider.tsx b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/payouts/payout-provider.tsx
index fa458669c4..ff4edaad5d 100644
--- a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/payouts/payout-provider.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/payouts/payout-provider.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import { getValidInternalRedirectPath } from "@/lib/middleware/utils/is-valid-internal-redirect";
import { ConnectPayoutButton } from "@/ui/partners/payouts/connect-payout-button";
import Link from "next/link";
@@ -63,6 +64,7 @@ export function PayoutProvider({
<Link
href="/programs"
+ data-testid={testIds.partnerOnboarding.skip}
className="text-sm font-medium text-neutral-500 transition-colors hover:text-neutral-800"
>
I'll complete this later
diff --git a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/platforms/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/platforms/page-client.tsx
index 7a4e94d1fe..34ab3d2987 100644
--- a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/platforms/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/platforms/page-client.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import { getValidInternalRedirectPath } from "@/lib/middleware/utils/is-valid-internal-redirect";
import { PartnerProps } from "@/lib/types";
import { PartnerPlatformsForm } from "@/ui/partners/partner-platforms-form";
@@ -27,6 +28,7 @@ export function OnboardingPlatformsPageClient({
/>
<Link
href="/onboarding/payouts"
+ data-testid={testIds.partnerOnboarding.skip}
className="text-sm font-medium text-neutral-500 transition-colors hover:text-neutral-800"
>
I'll complete this later
diff --git a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/platforms/page.tsx b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/platforms/page.tsx
index b0350d19d2..a318ca23e1 100644
--- a/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/platforms/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/platforms/page.tsx
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { getSession } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { buildSocialPlatformLookup } from "@/lib/social-utils";
@@ -12,7 +13,10 @@ import { OnboardingPlatformsPageClient } from "./page-client";
export default function OnboardingPlatformsPage() {
return (
<div className="mx-auto flex w-full max-w-[430px] flex-col text-center md:mt-4">
- <h1 className="animate-slide-up-fade text-center text-xl font-semibold [--offset:8px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]">
+ <h1
+ className="animate-slide-up-fade text-center text-xl font-semibold [--offset:8px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]"
+ data-testid={testIds.partnerOnboarding.platforms}
+ >
Your social and web platforms
</h1>
diff --git a/apps/web/app/app.dub.co/(auth-marketing)/register/page-client.tsx b/apps/web/app/app.dub.co/(auth-marketing)/register/page-client.tsx
index 28d3b4c0ff..b2e37eec39 100644
--- a/apps/web/app/app.dub.co/(auth-marketing)/register/page-client.tsx
+++ b/apps/web/app/app.dub.co/(auth-marketing)/register/page-client.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import { AuthAlternativeBanner } from "@/ui/auth/auth-alternative-banner";
import {
RegisterProvider,
@@ -57,7 +58,10 @@ function Verify() {
<>
<div className="w-full max-w-sm">
<div className="flex flex-col items-center gap-1 text-center">
- <h3 className="text-center text-xl font-semibold">
+ <h3
+ className="text-center text-xl font-semibold"
+ data-testid={testIds.auth.verifyEmailHeading}
+ >
Verify your email address
</h3>
<p className="text-base font-medium text-neutral-500">
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
index b5f8083c0e..5c99466911 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
@@ -1,6 +1,7 @@
"use client";
import { clientAccessCheck } from "@/lib/client-access-check";
+import { testIds } from "@/lib/e2e/test-ids";
import { MEGA_WORKSPACE_LINKS_LIMIT } from "@/lib/constants/misc";
import useGroupsCount from "@/lib/swr/use-groups-count";
import { useLinkTagsCount } from "@/lib/swr/use-link-tags-count";
@@ -261,7 +262,10 @@ export default function PlanUsage() {
) : trialEndsAt != null &&
isWorkspaceBillingTrialActive(trialEndsAt) ? (
<div className="mx-1 mt-1 flex items-center justify-center rounded-lg bg-blue-50/50 px-3 py-2">
- <p className="text-xs font-medium text-blue-600">
+ <p
+ className="text-xs font-medium text-blue-600"
+ data-testid={testIds.billing.trialBanner}
+ >
Trial ends on{" "}
<span className="font-semibold">
{new Date(trialEndsAt).toLocaleDateString("en-US", {
@@ -317,6 +321,7 @@ export default function PlanUsage() {
className="h-9"
disabled={Boolean(permissionsError)}
onClick={() => setShowStartPaidPlanModal(true)}
+ data-testid={testIds.billing.startPaidPlan}
/>
</DynamicTooltipWrapper>
) : showPendingCancellation ? (
@@ -358,6 +363,11 @@ export default function PlanUsage() {
}
variant="secondary"
className="h-9"
+ data-testid={
+ isWorkspaceBillingTrialActive(trialEndsAt)
+ ? testIds.billing.viewPlans
+ : undefined
+ }
/>
</Link>
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.tsx
index 0d25529119..3f691e2d9d 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
@@ -1,6 +1,7 @@
"use client";
import { clientAccessCheck } from "@/lib/client-access-check";
+import { testIds } from "@/lib/e2e/test-ids";
import { isEligibleForTrial } from "@/lib/stripe/is-eligible-for-trial";
import useWorkspace from "@/lib/swr/use-workspace";
import { PageContent } from "@/ui/layout/page-content";
@@ -183,7 +184,7 @@ export default function WorkspaceBillingUpgradePage() {
Billing
</Link>
<ChevronRight className="text-content-muted size-2.5 shrink-0 [&_*]:stroke-2" />
- <h1>Plans</h1>
+ <h1 data-testid={testIds.billing.plansHeading}>Plans</h1>
</div>
}
controls={
@@ -340,6 +341,7 @@ export default function WorkspaceBillingUpgradePage() {
) : (
<UpgradePlanButton
plan={plan.name.toLowerCase()}
+ data-testid={testIds.billing.planCta(plan.name)}
tier={planTier > 1 ? planTier : undefined}
period={period}
disabled={
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/form.tsx
index ce1b644236..e58fb94724 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/form.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/form.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import { AddEditDomainForm } from "@/ui/domains/add-edit-domain-form";
import { useSearchParams } from "next/navigation";
import { useOnboardingProduct } from "../../../use-onboarding-product";
@@ -18,6 +19,8 @@ export function Form() {
}}
enableDomainConfig={false}
initialDomain={`${workspaceSlug}.com`}
+ submitTestId={testIds.onboarding.addDomain}
+ domainInputTestId={testIds.onboarding.domainInput}
/>
);
}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/page.tsx
index f8e6c70005..f77d83be2c 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/page.tsx
@@ -1,9 +1,11 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { StepPage } from "../../step-page";
import { Form } from "./form";
export default function Custom() {
return (
<StepPage
+ headingTestId={testIds.onboarding.stepDomainCustom}
title="Connect a custom domain"
description={
<a
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/default-domain-selector.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/default-domain-selector.tsx
index 3daefe4e4b..30924d84f7 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/default-domain-selector.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/default-domain-selector.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import { OnboardingStep } from "@/lib/onboarding/types";
import {
Bolt,
@@ -77,6 +78,7 @@ export function DefaultDomainSelector() {
: undefined
}
cta="Connect domain"
+ testId={testIds.onboarding.connectDomain}
/>
{product === "partners" && (
<DomainOption
@@ -131,7 +133,11 @@ export function DefaultDomainSelector() {
</div>
{product === "links" && (
<div className="mx-auto mt-8 w-full max-w-sm">
- <LaterButton next="plan" className="mt-4" />
+ <LaterButton
+ next="plan"
+ className="mt-4"
+ data-testid={testIds.onboarding.skipDomain}
+ />
</div>
)}
</>
@@ -148,6 +154,7 @@ function DomainOption({
bannerIcon: BannerIcon,
bannerText,
bannerVariant = "default",
+ testId,
}: {
step: OnboardingStep;
icon: string;
@@ -161,6 +168,7 @@ function DomainOption({
bannerIcon?: Icon;
bannerText?: string;
bannerVariant?: "default" | "recommended";
+ testId?: string;
}) {
const plausible = usePlausible();
const { continueTo, isLoading, isSuccessful } = useOnboardingProgress();
@@ -233,6 +241,7 @@ function DomainOption({
}}
loading={isLoading || isSuccessful}
text={cta}
+ data-testid={testId}
/>
</div>
</div>
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/page.tsx
index beba4253ce..f638e0ad94 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/page.tsx
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { StepPage } from "../step-page";
import { DefaultDomainSelector } from "./default-domain-selector";
@@ -11,6 +12,7 @@ export default async function Domain({
return (
<StepPage
+ headingTestId={testIds.onboarding.stepDomain}
title="Add a custom domain"
description={
isPartners ? (
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/page.tsx
index ba00f99c29..80ea0ffac9 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/page.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import { DubProductIcon } from "@dub/ui";
import { capitalize } from "@dub/utils";
import { LaterButton } from "../../later-button";
@@ -14,6 +15,7 @@ export default function Plan() {
return (
<StepPage
+ headingTestId={testIds.onboarding.stepPlan}
title={
<>
Choose your{" "}
@@ -57,6 +59,7 @@ export default function Plan() {
<LaterButton
next="success"
className="underline-offset-4 hover:underline"
+ data-testid={testIds.onboarding.freePlan}
>
Start for free, pick a plan later
</LaterButton>
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/plan-selector.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/plan-selector.tsx
index 1a0fd25b84..d7f7d0bae5 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/plan-selector.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/plan-selector.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import X from "@/ui/shared/icons/x";
import { UpgradePlanButton } from "@/ui/workspaces/upgrade-plan-button";
import {
@@ -171,7 +172,7 @@ export function PlanSelector({ product }: { product: OnboardingProduct }) {
plan={plan.name.toLowerCase()}
period={period}
className="h-10 rounded-lg shadow-sm"
- data-testid={`onboarding-plan-cta-${plan.name.toLowerCase()}`}
+ data-testid={testIds.onboarding.planCta(plan.name)}
/>
)}
<button
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/page.tsx
index faa7a9b26a..9234a64eda 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/page.tsx
@@ -1,9 +1,11 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { StepPage } from "../step-page";
import { ProductSelector } from "./product-selector";
export default function Products() {
return (
<StepPage
+ headingTestId={testIds.onboarding.stepProducts}
title="What do you want to do with Dub?"
description="Choose how you'll use Dub to grow your business"
className="max-w-none"
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/product-selector.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/product-selector.tsx
index 27e3521c11..dec4069c32 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/product-selector.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/product-selector.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import { MarkdownDescription } from "@/ui/shared/markdown-description";
import { Button, DubProductIcon } from "@dub/ui";
import { capitalize } from "@dub/utils";
@@ -103,6 +104,7 @@ function ProductOption({
}}
loading={isLoading || isSuccessful}
text={cta}
+ data-testid={testIds.onboarding.productCta(product)}
/>
</div>
</div>
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/form.tsx
index 1259375c69..eb38b7bf5e 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/form.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/form.tsx
@@ -2,6 +2,7 @@
import { parseActionError } from "@/lib/actions/parse-action-errors";
import { onboardProgramAction } from "@/lib/actions/partners/onboard-program";
+import { testIds } from "@/lib/e2e/test-ids";
import useWorkspace from "@/lib/swr/use-workspace";
import { ProgramData } from "@/lib/types";
import { Button, FileUpload, Input, useMediaQuery } from "@dub/ui";
@@ -99,7 +100,9 @@ export function Form() {
}
setValue("logo", destinationUrl, { shouldDirty: true });
- toast.success(`${file.name} uploaded!`);
+ toast.success(`${file.name} uploaded!`, {
+ testId: testIds.onboarding.programLogoUploaded,
+ });
} catch (e) {
toast.error("Failed to upload logo");
} finally {
@@ -132,7 +135,7 @@ export function Form() {
autoFocus={!isMobile}
className="max-w-full"
error={errors.name?.message}
- data-testid="onboarding-program-company-name"
+ data-testid={testIds.onboarding.programCompanyName}
/>
<p className="text-content-subtle text-xs">
@@ -163,7 +166,7 @@ export function Form() {
onChange={({ file }) => handleUpload(file)}
content={null}
maxFileSizeMB={2}
- data-testid="onboarding-program-logo"
+ data-testid={testIds.onboarding.programLogo}
/>
)}
/>
@@ -191,7 +194,7 @@ export function Form() {
placeholder="https://"
className="max-w-full"
error={errors.url?.message}
- data-testid="onboarding-program-destination-url"
+ data-testid={testIds.onboarding.programDestinationUrl}
/>
)}
/>
@@ -219,7 +222,7 @@ export function Form() {
type="email"
className="max-w-full"
error={errors.supportEmail?.message}
- data-testid="onboarding-program-support-email"
+ data-testid={testIds.onboarding.programSupportEmail}
/>
)}
/>
@@ -235,7 +238,7 @@ export function Form() {
disabledTooltip={!isLoading ? disabledTooltip : undefined}
text="Continue"
className="w-full"
- data-testid="onboarding-program-continue"
+ data-testid={testIds.onboarding.programContinue}
/>
</form>
);
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/page-client.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/page-client.tsx
index 67ac4f7dbe..c8dab76807 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/page-client.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/page-client.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import { ProgramOnboardingFormWrapper } from "@/ui/partners/program-onboarding-form-wrapper";
import { cn } from "@dub/utils/src";
import { StepPage } from "../step-page";
@@ -11,6 +12,7 @@ export function ProgramPageClient({ domain }: { domain: string }) {
return (
<StepPage
+ headingTestId={testIds.onboarding.stepProgram}
title="Create your partner program"
description="Set up your program in a few steps"
>
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/form.tsx
index ebd60d8cb0..4259c10fe8 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/form.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/form.tsx
@@ -1,6 +1,7 @@
"use client";
import { onboardProgramAction } from "@/lib/actions/partners/onboard-program";
+import { testIds } from "@/lib/e2e/test-ids";
import { handleMoneyInputChange, handleMoneyKeyDown } from "@/lib/form-utils";
import useWorkspace from "@/lib/swr/use-workspace";
import { ProgramData } from "@/lib/types";
@@ -448,7 +449,7 @@ export function Form() {
</span>
<input
id={rewardAmountInputId}
- data-testid="onboarding-reward-amount"
+ data-testid={testIds.onboarding.rewardAmount}
className={cn(
"block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
type === "flat" ? "pl-6 pr-12" : "pr-7",
@@ -480,7 +481,7 @@ export function Form() {
loading={isLoading}
disabledTooltip={!isLoading ? disabledTooltip : undefined}
type="submit"
- data-testid="onboarding-reward-continue"
+ data-testid={testIds.onboarding.rewardContinue}
/>
</form>
);
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/page.tsx
index 2e50386808..a1d045f1b8 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/page.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import { ProgramOnboardingFormWrapper } from "@/ui/partners/program-onboarding-form-wrapper";
import { cn } from "@dub/utils";
import { StepPage } from "../../step-page";
@@ -11,6 +12,7 @@ export default function ProgramReward() {
return (
<StepPage
+ headingTestId={testIds.onboarding.stepReward}
title="Create your default reward"
description={
<>
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/step-page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/step-page.tsx
index 5d6d50af38..05a335c58c 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/step-page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/step-page.tsx
@@ -10,6 +10,7 @@ export function StepPage({
paidPlanRequired,
badge,
className,
+ headingTestId,
}: PropsWithChildren<{
title: ReactNode;
description: ReactNode;
@@ -19,6 +20,7 @@ export function StepPage({
label: string;
};
className?: string;
+ headingTestId?: string;
}>) {
const BadgeIcon = badge?.icon ?? Crown;
@@ -36,7 +38,12 @@ export function StepPage({
{badge?.label ?? "Paid plan required"}
</div>
)}
- <h1 className="text-center text-xl font-semibold">{title}</h1>
+ <h1
+ className="text-center text-xl font-semibold"
+ data-testid={headingTestId}
+ >
+ {title}
+ </h1>
<div className="mt-2 text-balance text-center text-base text-neutral-500">
{description}
</div>
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/success/page-client.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/success/page-client.tsx
index 433a202354..46a03d139c 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/success/page-client.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/success/page-client.tsx
@@ -1,6 +1,7 @@
"use client";
import { DIRECT_DEBIT_PAYMENT_METHOD_TYPES } from "@/lib/constants/payouts";
+import { testIds } from "@/lib/e2e/test-ids";
import { useSyncedLocalStorage } from "@/lib/hooks/use-synced-local-storage";
import { getPlanCapabilities } from "@/lib/plan-capabilities";
import useDomains from "@/lib/swr/use-domains";
@@ -111,7 +112,10 @@ export function SuccessPageClient({
</div>
</div>
)}
- <h1 className="text-pretty text-center text-xl font-semibold">
+ <h1
+ className="text-pretty text-center text-xl font-semibold"
+ data-testid={testIds.onboarding.workspaceCreated}
+ >
The {workspace.name} workspace has been created
</h1>
<MarkdownDescription className="mt-2 text-pretty text-center text-base text-neutral-500">
@@ -125,6 +129,7 @@ export function SuccessPageClient({
loading={isLoading || isSuccessful}
text="Go to your dashboard"
className="h-9 rounded-lg"
+ data-testid={testIds.onboarding.goToDashboard}
/>
</div>
</div>
@@ -135,7 +140,12 @@ export function SuccessPageClient({
"animate-slide-up-fade motion-reduce:animate-fade-in [--offset:10px] [animation-delay:250ms] [animation-duration:0.5s] [animation-fill-mode:both]",
)}
>
- <h3 className="text-content-emphasis font-semibold">Complete setup</h3>
+ <h3
+ className="text-content-emphasis font-semibold"
+ data-testid={testIds.onboarding.completeSetup}
+ >
+ Complete setup
+ </h3>
<div className="divide-border-subtle border-border-subtle bg-bg-muted flex flex-col divide-y overflow-hidden rounded-lg border">
{[
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/page.tsx
index 9030c76af9..79ec5648a2 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/page.tsx
@@ -1,9 +1,11 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { StepPage } from "../step-page";
import { Form } from "./form";
export default function Workspace() {
return (
<StepPage
+ headingTestId={testIds.onboarding.stepWorkspace}
title="Create your workspace"
description={
<>
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/later-button.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/later-button.tsx
index 0c1c2f0c07..e7a45295ca 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/later-button.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/later-button.tsx
@@ -10,12 +10,18 @@ export function LaterButton({
next,
className,
children,
-}: PropsWithChildren<{ next: OnboardingStep; className?: string }>) {
+ "data-testid": dataTestId,
+}: PropsWithChildren<{
+ next: OnboardingStep;
+ className?: string;
+ "data-testid"?: string;
+}>) {
const { continueTo, isLoading, isSuccessful } = useOnboardingProgress();
return (
<button
type="button"
+ data-testid={dataTestId}
onClick={() => continueTo(next)}
className={cn(
"mx-auto flex w-fit items-center gap-2 text-center text-sm font-medium text-neutral-800 transition-colors enabled:hover:text-neutral-950",
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/welcome/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/welcome/page.tsx
index 4c2b55add5..7e5d7ba766 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/welcome/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/welcome/page.tsx
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { NewBackground } from "@/ui/shared/new-background";
import { Wordmark } from "@dub/ui";
import { cn } from "@dub/utils/src";
@@ -16,7 +17,10 @@ export default function Welcome() {
<Wordmark className="relative h-24 sm:h-36" />
<Gradient className="opacity-50 mix-blend-hard-light" />
</div>
- <h1 className="animate-slide-up-fade mt-14 text-xl font-semibold text-neutral-900 [--offset:10px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]">
+ <h1
+ className="animate-slide-up-fade mt-14 text-xl font-semibold text-neutral-900 [--offset:10px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]"
+ data-testid={testIds.onboarding.stepWelcome}
+ >
Welcome to Dub
</h1>
<p className="animate-slide-up-fade mt-2 text-balance text-base text-neutral-500 [--offset:10px] [animation-delay:500ms] [animation-duration:1s] [animation-fill-mode:both]">
@@ -24,7 +28,11 @@ export default function Welcome() {
convert to revenue.
</p>
<div className="animate-slide-up-fade mt-8 w-full [--offset:10px] [animation-delay:750ms] [animation-duration:1s] [animation-fill-mode:both]">
- <NextButton text="Get started" step="workspace" />
+ <NextButton
+ text="Get started"
+ step="workspace"
+ data-testid={testIds.onboarding.getStarted}
+ />
</div>
</div>
</div>
diff --git a/apps/web/lib/e2e/test-ids.ts b/apps/web/lib/e2e/test-ids.ts
new file mode 100644
index 0000000000..b8679f6fd0
--- /dev/null
+++ b/apps/web/lib/e2e/test-ids.ts
@@ -0,0 +1,68 @@
+export const testIds = {
+ auth: {
+ signupSubmit: "auth-signup-submit",
+ loginSubmit: "auth-login-submit",
+ loginHeading: "auth-login-heading",
+ verifyEmailHeading: "auth-verify-email-heading",
+ loginNoAccount: "auth-login-no-account",
+ loginInvalidCredentials: "auth-login-invalid-credentials",
+ },
+ onboarding: {
+ getStarted: "onboarding-get-started",
+ createWorkspace: "onboarding-create-workspace",
+ workspaceName: "onboarding-workspace-name",
+ workspaceSlug: "onboarding-workspace-slug",
+ connectDomain: "onboarding-connect-domain",
+ domainInput: "onboarding-domain-input",
+ domainAvailable: "onboarding-domain-available",
+ addDomain: "onboarding-add-domain",
+ skipDomain: "onboarding-skip-domain",
+ freePlan: "onboarding-free-plan",
+ programCompanyName: "onboarding-program-company-name",
+ programLogo: "onboarding-program-logo",
+ programLogoUploaded: "onboarding-program-logo-uploaded",
+ programDestinationUrl: "onboarding-program-destination-url",
+ programSupportEmail: "onboarding-program-support-email",
+ programContinue: "onboarding-program-continue",
+ rewardAmount: "onboarding-reward-amount",
+ rewardContinue: "onboarding-reward-continue",
+ goToDashboard: "onboarding-go-to-dashboard",
+ completeSetup: "onboarding-complete-setup",
+ workspaceCreated: "onboarding-workspace-created",
+ stepWelcome: "onboarding-step-welcome",
+ stepWorkspace: "onboarding-step-workspace",
+ stepProducts: "onboarding-step-products",
+ stepDomain: "onboarding-step-domain",
+ stepDomainCustom: "onboarding-step-domain-custom",
+ stepProgram: "onboarding-step-program",
+ stepReward: "onboarding-step-reward",
+ stepPlan: "onboarding-step-plan",
+ productCta: (product: "links" | "partners") =>
+ `onboarding-product-cta-${product}` as const,
+ planCta: (plan: string) =>
+ `onboarding-plan-cta-${plan.toLowerCase()}` as const,
+ },
+ partnerOnboarding: {
+ continue: "partner-onboarding-continue",
+ skip: "partner-onboarding-skip",
+ profile: "partner-onboarding-profile",
+ platforms: "partner-onboarding-platforms",
+ profileImage: "partner-onboarding-profile-image",
+ aboutYou: "partner-onboarding-about-you",
+ profileType: "partner-onboarding-profile-type",
+ },
+ billing: {
+ plansHeading: "billing-plans-heading",
+ viewDashboard: "billing-view-dashboard",
+ upgradedHeading: "billing-upgraded-heading",
+ startPaidPlan: "billing-start-paid-plan",
+ viewPlans: "billing-view-plans",
+ confirmStartPaidPlan: "billing-confirm-start-paid-plan",
+ startPaidPlanHeading: "billing-start-paid-plan-heading",
+ startPaidPlanNotice: "billing-start-paid-plan-notice",
+ trialBanner: "billing-trial-banner",
+ freeTrial: "billing-free-trial",
+ planCta: (plan: string) =>
+ `billing-plan-cta-${plan.toLowerCase()}` as const,
+ },
+} as const;
diff --git a/apps/web/playwright/README.md b/apps/web/playwright/README.md
index a4fbe6ac15..cea8af5eb3 100644
--- a/apps/web/playwright/README.md
+++ b/apps/web/playwright/README.md
@@ -42,6 +42,10 @@ pnpm --filter web test:e2e --project=api playwright/api/tags/tags.spec.ts -g "PO
`-g` / `--grep` matches the test title (regex). Combine with a file path to narrow further.
+## Locators
+
+UI specs locate controls with `page.getByTestId` and IDs from [`lib/e2e/test-ids.ts`](../lib/e2e/test-ids.ts), not button labels or headings. That stays stable when copy changes and when i18n lands. Form fields can still use `input[name]`. Sonner toasts used as assertions set the same ID via the toast `testId` option.
+
## Running tests
Make sure the dev server is running first (`pnpm dev`), then:
diff --git a/apps/web/playwright/partners/auth.setup.ts b/apps/web/playwright/partners/auth.setup.ts
index 6c5b8f9b70..c7c7c2843c 100644
--- a/apps/web/playwright/partners/auth.setup.ts
+++ b/apps/web/playwright/partners/auth.setup.ts
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { nanoid } from "@dub/utils";
import { expect, test } from "@playwright/test";
import { extractOtp, waitForEmail } from "../mailhog";
@@ -15,18 +16,16 @@ test("sign up and verify new partner", async ({ page }) => {
// Step 1: Enter email and reveal password field
await page.locator('input[name="email"]').fill(email);
- await page.getByRole("button", { name: "Sign Up" }).click();
+ await page.getByTestId(testIds.auth.signupSubmit).click();
// Step 2: Enter password and submit
const passwordInput = page.locator('input[name="password"]');
await expect(passwordInput).toBeVisible();
await passwordInput.fill(SIGNUP_PASSWORD);
- await page.getByRole("button", { name: "Sign Up" }).click();
+ await page.getByTestId(testIds.auth.signupSubmit).click();
// Step 3: Verify email via OTP from MailHog
- await expect(
- page.getByRole("heading", { name: "Verify your email address" }),
- ).toBeVisible();
+ await expect(page.getByTestId(testIds.auth.verifyEmailHeading)).toBeVisible();
const message = await waitForEmail(email);
const otp = extractOtp(message);
diff --git a/apps/web/playwright/partners/login.spec.ts b/apps/web/playwright/partners/login.spec.ts
index 33cbbe72fe..0b7a40736e 100644
--- a/apps/web/playwright/partners/login.spec.ts
+++ b/apps/web/playwright/partners/login.spec.ts
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { expect, test } from "@playwright/test";
import { env } from "../env";
@@ -12,30 +13,20 @@ test.describe("Partner Login", () => {
test("login page renders correctly", async ({ page }) => {
await page.goto("/login");
- await expect(
- page.getByRole("heading", {
- name: "Log in to your Dub Partner account",
- }),
- ).toBeVisible();
+ await expect(page.getByTestId(testIds.auth.loginHeading)).toBeVisible();
await expect(page.locator('input[name="email"]')).toBeVisible();
- await expect(
- page.getByRole("button", {
- name: "Log in with email",
- }),
- ).toBeVisible();
+ await expect(page.getByTestId(testIds.auth.loginSubmit)).toBeVisible();
});
test("shows error for invalid email", async ({ page }) => {
await page.goto("/login");
await page.locator('input[name="email"]').fill("[email protected]");
- await page.getByRole("button", { name: "Log in with email" }).click();
+ await page.getByTestId(testIds.auth.loginSubmit).click();
- await expect(
- page.getByText("No account found with that email address."),
- ).toBeVisible();
+ await expect(page.getByTestId(testIds.auth.loginNoAccount)).toBeVisible();
});
test("login with email and password", async ({ page }) => {
@@ -43,14 +34,14 @@ test.describe("Partner Login", () => {
// Enter email and submit to trigger account check
await page.locator('input[name="email"]').fill(env.E2E_PARTNER_EMAIL);
- await page.getByRole("button", { name: "Log in with email" }).click();
+ await page.getByTestId(testIds.auth.loginSubmit).click();
// Wait for password field to appear
await expect(page.locator('input[type="password"]')).toBeVisible();
// Enter password and submit
await page.locator('input[type="password"]').fill(env.E2E_PARTNER_PASSWORD);
- await page.getByRole("button", { name: "Log in with password" }).click();
+ await page.getByTestId(testIds.auth.loginSubmit).click();
// Verify redirect to authenticated area
await page.waitForURL((url) =>
@@ -63,15 +54,15 @@ test.describe("Partner Login", () => {
await page.goto("/login");
await page.locator('input[name="email"]').fill(env.E2E_PARTNER_EMAIL);
- await page.getByRole("button", { name: "Log in with email" }).click();
+ await page.getByTestId(testIds.auth.loginSubmit).click();
await expect(page.locator('input[type="password"]')).toBeVisible();
await page.locator('input[type="password"]').fill("wrongpassword123");
- await page.getByRole("button", { name: "Log in with password" }).click();
+ await page.getByTestId(testIds.auth.loginSubmit).click();
await expect(
- page.getByText("Email or password is incorrect."),
+ page.getByTestId(testIds.auth.loginInvalidCredentials),
).toBeVisible();
});
});
diff --git a/apps/web/playwright/partners/onboarding.spec.ts b/apps/web/playwright/partners/onboarding.spec.ts
index d888115680..07eb024839 100644
--- a/apps/web/playwright/partners/onboarding.spec.ts
+++ b/apps/web/playwright/partners/onboarding.spec.ts
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { expect, test } from "@playwright/test";
test.describe("Partner onboarding (unauthenticated)", () => {
@@ -13,12 +14,22 @@ test.describe("Partner onboarding", () => {
test("onboarding page renders", async ({ page }) => {
await page.goto("/onboarding");
- await expect(page.getByText("Create your partner profile")).toBeVisible();
+ await expect(
+ page.getByTestId(testIds.partnerOnboarding.profile),
+ ).toBeVisible();
await expect(page.locator('input[name="name"]').first()).toBeVisible();
- await expect(page.getByText("Profile image").first()).toBeVisible();
- await expect(page.getByText("About you").first()).toBeVisible();
- await expect(page.getByText("Profile Type").first()).toBeVisible();
- await expect(page.getByRole("button", { name: "Continue" })).toBeVisible();
+ await expect(
+ page.getByTestId(testIds.partnerOnboarding.profileImage),
+ ).toBeVisible();
+ await expect(
+ page.getByTestId(testIds.partnerOnboarding.aboutYou),
+ ).toBeVisible();
+ await expect(
+ page.getByTestId(testIds.partnerOnboarding.profileType),
+ ).toBeVisible();
+ await expect(
+ page.getByTestId(testIds.partnerOnboarding.continue),
+ ).toBeVisible();
});
test("profile submit redirects to platforms", async ({ page }) => {
@@ -26,14 +37,14 @@ test.describe("Partner onboarding", () => {
await page.waitForLoadState("networkidle");
const nameInput = page.locator('input[name="name"]');
- const continueButton = page.getByRole("button", { name: "Continue" });
+ const continueButton = page.getByTestId(testIds.partnerOnboarding.continue);
await nameInput.fill("E2E Onboarding Test");
await continueButton.click();
await page.waitForURL("/onboarding/platforms");
await expect(
- page.getByText("Your social and web platforms", { exact: true }),
+ page.getByTestId(testIds.partnerOnboarding.platforms),
).toBeVisible();
});
@@ -42,15 +53,13 @@ test.describe("Partner onboarding", () => {
await page.waitForLoadState("networkidle");
const nameInput = page.locator('input[name="name"]').first();
- const continueButton = page.getByRole("button", { name: "Continue" });
+ const continueButton = page.getByTestId(testIds.partnerOnboarding.continue);
await nameInput.fill("E2E Onboarding Test");
await continueButton.click();
await page.waitForURL("/onboarding/platforms");
- const skipLink = page.getByRole("link", {
- name: "I'll complete this later",
- });
+ const skipLink = page.getByTestId(testIds.partnerOnboarding.skip);
await expect(skipLink).toBeVisible();
await skipLink.click();
@@ -60,9 +69,7 @@ test.describe("Partner onboarding", () => {
test("payouts step skip link goes to programs", async ({ page }) => {
await page.goto("/onboarding/payouts");
- const skipLink = page.getByRole("link", {
- name: "I'll complete this later",
- });
+ const skipLink = page.getByTestId(testIds.partnerOnboarding.skip);
await expect(skipLink).toBeVisible();
await skipLink.click();
diff --git a/apps/web/playwright/workspaces/auth.setup.ts b/apps/web/playwright/workspaces/auth.setup.ts
index 7cc850d464..167c4da97f 100644
--- a/apps/web/playwright/workspaces/auth.setup.ts
+++ b/apps/web/playwright/workspaces/auth.setup.ts
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { nanoid } from "@dub/utils";
import { expect, test } from "@playwright/test";
import { extractOtp, waitForEmail } from "../mailhog";
@@ -15,18 +16,16 @@ test("sign up new user for workspace onboarding", async ({ page }) => {
// Step 1: Enter email and reveal password field
await page.locator('input[name="email"]').fill(email);
- await page.getByRole("button", { name: "Sign Up" }).click();
+ await page.getByTestId(testIds.auth.signupSubmit).click();
// Step 2: Enter password and submit
const passwordInput = page.locator('input[name="password"]');
await expect(passwordInput).toBeVisible();
await passwordInput.fill(SIGNUP_PASSWORD);
- await page.getByRole("button", { name: "Sign Up" }).click();
+ await page.getByTestId(testIds.auth.signupSubmit).click();
// Step 3: Verify email via OTP from MailHog
- await expect(
- page.getByRole("heading", { name: "Verify your email address" }),
- ).toBeVisible();
+ await expect(page.getByTestId(testIds.auth.verifyEmailHeading)).toBeVisible();
const message = await waitForEmail(email);
const otp = extractOtp(message);
diff --git a/apps/web/playwright/workspaces/billing-trial.spec.ts b/apps/web/playwright/workspaces/billing-trial.spec.ts
index d6bb93605b..7b52633794 100644
--- a/apps/web/playwright/workspaces/billing-trial.spec.ts
+++ b/apps/web/playwright/workspaces/billing-trial.spec.ts
@@ -1,4 +1,4 @@
-import { DUB_TRIAL_PERIOD_DAYS } from "@dub/utils";
+import { testIds } from "@/lib/e2e/test-ids";
import { expect, test } from "@playwright/test";
import {
applyMockActivatedPaidPlan,
@@ -38,17 +38,11 @@ test.describe("Billing trial checkout", () => {
try {
await page.goto(`/${slug}/settings/billing/upgrade`);
- await expect(
- page.getByRole("heading", { name: "Plans", exact: true }),
- ).toBeVisible({ timeout: 30_000 });
+ await expect(page.getByTestId(testIds.billing.plansHeading)).toBeVisible({
+ timeout: 30_000,
+ });
- const proCard = page.getByRole("heading", { name: "Pro", exact: true });
- await proCard
- .locator("xpath=ancestor::div[contains(@class,'flex-col')][1]")
- .getByRole("button", {
- name: new RegExp(`Start ${DUB_TRIAL_PERIOD_DAYS}-day trial`, "i"),
- })
- .click();
+ await page.getByTestId(testIds.billing.planCta("pro")).click();
await page.waitForURL(
(u) => {
@@ -79,11 +73,11 @@ test.describe("Billing trial checkout", () => {
.not.toBeNull();
await expect(
- page.getByRole("heading", { name: /Dub Pro looks good on you/i }),
+ page.getByTestId(testIds.billing.upgradedHeading),
).toBeVisible({ timeout: 15_000 });
- await page.getByRole("button", { name: "View dashboard" }).click();
- await expect(page.getByText("Free trial", { exact: true })).toBeVisible({
+ await page.getByTestId(testIds.billing.viewDashboard).click();
+ await expect(page.getByTestId(testIds.billing.freeTrial)).toBeVisible({
timeout: 15_000,
});
} finally {
@@ -127,13 +121,11 @@ test.describe("Free trial user navigation", () => {
}) => {
await page.goto(`/${slug}/settings/billing`);
- await expect(page.getByText(/Trial ends on/)).toBeVisible({
+ await expect(page.getByTestId(testIds.billing.trialBanner)).toBeVisible({
timeout: 15_000,
});
- await expect(
- page.getByRole("button", { name: "Start paid plan" }),
- ).toBeVisible();
- await expect(page.getByRole("link", { name: "View plans" })).toBeVisible();
+ await expect(page.getByTestId(testIds.billing.startPaidPlan)).toBeVisible();
+ await expect(page.getByTestId(testIds.billing.viewPlans)).toBeVisible();
});
test("upgrade page shows Activate plan for current Business plan", async ({
@@ -141,18 +133,12 @@ test.describe("Free trial user navigation", () => {
}) => {
await page.goto(`/${slug}/settings/billing/upgrade`);
- await expect(
- page.getByRole("heading", { name: "Plans", exact: true }),
- ).toBeVisible({ timeout: 30_000 });
-
- const businessCard = page.getByRole("heading", {
- name: "Business",
- exact: true,
+ await expect(page.getByTestId(testIds.billing.plansHeading)).toBeVisible({
+ timeout: 30_000,
});
+
await expect(
- businessCard
- .locator("xpath=ancestor::div[contains(@class,'flex-col')][1]")
- .getByRole("button", { name: "Activate plan" }),
+ page.getByTestId(testIds.billing.planCta("business")),
).toBeVisible();
});
@@ -176,17 +162,14 @@ test.describe("Free trial user navigation", () => {
await page.goto(`/${slug}/settings/billing`);
- await page.getByRole("button", { name: "Start paid plan" }).click();
- const confirmModal = page.getByRole("dialog").filter({
- has: page.getByRole("heading", { name: "Plan start confirmation" }),
- });
- await expect(confirmModal).toBeVisible();
+ await page.getByTestId(testIds.billing.startPaidPlan).click();
+ await expect(
+ page.getByTestId(testIds.billing.startPaidPlanHeading),
+ ).toBeVisible();
await expect(
- confirmModal.getByText(
- "You'll be charged today and your trial will end.",
- ),
+ page.getByTestId(testIds.billing.startPaidPlanNotice),
).toBeVisible();
- await confirmModal.getByRole("button", { name: "Start paid plan" }).click();
+ await page.getByTestId(testIds.billing.confirmStartPaidPlan).click();
await page.waitForURL((u) => {
const url = new URL(u);
@@ -196,7 +179,7 @@ test.describe("Free trial user navigation", () => {
);
});
await expect(
- page.getByRole("heading", { name: /Dub Business looks good on you/i }),
+ page.getByTestId(testIds.billing.upgradedHeading),
).toBeVisible({ timeout: 15_000 });
});
});
diff --git a/apps/web/playwright/workspaces/onboarding-dub-links.spec.ts b/apps/web/playwright/workspaces/onboarding-dub-links.spec.ts
index c21d9d4c60..dd39c98f54 100644
--- a/apps/web/playwright/workspaces/onboarding-dub-links.spec.ts
+++ b/apps/web/playwright/workspaces/onboarding-dub-links.spec.ts
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { nanoid } from "@dub/utils";
import { expect, test } from "@playwright/test";
@@ -14,36 +15,36 @@ test("complete workspace onboarding with Dub Links product", async ({
// Welcome page
await page.goto("/onboarding");
await expect(
- page.getByRole("heading", { name: "Welcome to Dub" }),
+ page.getByTestId(testIds.onboarding.stepWelcome),
).toBeVisible();
await Promise.all([
expect(page).toHaveURL(/\/onboarding\/workspace/, {
timeout: STEP_NAV_TIMEOUT,
}),
- page.getByRole("button", { name: "Get started" }).click(),
+ page.getByTestId(testIds.onboarding.getStarted).click(),
]);
// Workspace creation step
await expect(
- page.getByRole("heading", { name: "Create your workspace" }),
+ page.getByTestId(testIds.onboarding.stepWorkspace),
).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
// Fill workspace name (slug auto-generates)
- await page.locator('input[id="name"]').fill(workspaceName);
+ await page.getByTestId(testIds.onboarding.workspaceName).fill(workspaceName);
// Read the auto-generated slug for later assertions
- const slug = await page.locator('input[id="slug"]').inputValue();
+ const slug = await page
+ .getByTestId(testIds.onboarding.workspaceSlug)
+ .inputValue();
expect(slug).toBeTruthy();
- const productsHeading = page.getByRole("heading", {
- name: "What do you want to do with Dub?",
- });
+ const productsHeading = page.getByTestId(testIds.onboarding.stepProducts);
await Promise.all([
expect(page).toHaveURL(/\/onboarding\/products/, {
timeout: STEP_NAV_TIMEOUT,
}),
- page.getByRole("button", { name: "Create workspace" }).click(),
+ page.getByTestId(testIds.onboarding.createWorkspace).click(),
]);
await expect(productsHeading).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
@@ -51,16 +52,14 @@ test("complete workspace onboarding with Dub Links product", async ({
expect(page).toHaveURL(/\/onboarding\/domain/, {
timeout: STEP_NAV_TIMEOUT,
}),
- page.getByRole("button", { name: "Continue with Dub Links" }).click(),
+ page.getByTestId(testIds.onboarding.productCta("links")).click(),
]);
// Domain step — skip it
- await expect(
- page.getByRole("heading", { name: "Add a custom domain" }),
- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
- const skipDomainCta = page.getByRole("button", {
- name: "I'll do this later",
+ await expect(page.getByTestId(testIds.onboarding.stepDomain)).toBeVisible({
+ timeout: STEP_NAV_TIMEOUT,
});
+ const skipDomainCta = page.getByTestId(testIds.onboarding.skipDomain);
await expect(skipDomainCta).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
await Promise.all([
expect(page).toHaveURL(/\/onboarding\/plan/, {
@@ -70,9 +69,7 @@ test("complete workspace onboarding with Dub Links product", async ({
]);
// Plan step — use free plan
- const freePlanCta = page.getByRole("button", {
- name: "Start for free, pick a plan later",
- });
+ const freePlanCta = page.getByTestId(testIds.onboarding.freePlan);
await expect(freePlanCta).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
await Promise.all([
expect(page).toHaveURL(/\/onboarding\/success/, {
@@ -83,16 +80,14 @@ test("complete workspace onboarding with Dub Links product", async ({
// Success page
await expect(
- page.locator("h1").filter({ hasText: workspaceName }),
- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
+ page.getByTestId(testIds.onboarding.workspaceCreated),
+ ).toContainText(workspaceName, { timeout: STEP_NAV_TIMEOUT });
await expect(
- page.locator("h3").filter({ hasText: /^Complete setup$/ }),
+ page.getByTestId(testIds.onboarding.completeSetup),
).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
// Go to dashboard
- const dashboardCta = page.getByRole("button", {
- name: "Go to your dashboard",
- });
+ const dashboardCta = page.getByTestId(testIds.onboarding.goToDashboard);
await expect(dashboardCta).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
const slugPathPattern = new RegExp(
`/${slug.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:/|$)`,
diff --git a/apps/web/playwright/workspaces/onboarding-dub-partners.spec.ts b/apps/web/playwright/workspaces/onboarding-dub-partners.spec.ts
index e2c0580b1c..8d3256147e 100644
--- a/apps/web/playwright/workspaces/onboarding-dub-partners.spec.ts
+++ b/apps/web/playwright/workspaces/onboarding-dub-partners.spec.ts
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import { nanoid } from "@dub/utils";
import { expect, test, type Page } from "@playwright/test";
import {
@@ -73,30 +74,30 @@ test.describe("Dub Partners onboarding", () => {
// Welcome page
await page.goto("/onboarding");
await expect(
- page.getByRole("heading", { name: "Welcome to Dub" }),
+ page.getByTestId(testIds.onboarding.stepWelcome),
).toBeVisible();
await Promise.all([
expect(page).toHaveURL(/\/onboarding\/workspace/, {
timeout: STEP_NAV_TIMEOUT,
}),
- page.getByRole("button", { name: "Get started" }).click(),
+ page.getByTestId(testIds.onboarding.getStarted).click(),
]);
// Workspace creation step
await expect(
- page.getByRole("heading", { name: "Create your workspace" }),
+ page.getByTestId(testIds.onboarding.stepWorkspace),
).toBeVisible();
// Fill workspace name (slug auto-generates)
- await page.locator('input[id="name"]').fill(workspaceName);
+ await page.getByTestId(testIds.onboarding.workspaceName).fill(workspaceName);
// Read the auto-generated slug for later assertions
- const slug = await page.locator('input[id="slug"]').inputValue();
+ const slug = await page
+ .getByTestId(testIds.onboarding.workspaceSlug)
+ .inputValue();
expect(slug).toBeTruthy();
- const productsHeading = page.getByRole("heading", {
- name: "What do you want to do with Dub?",
- });
+ const productsHeading = page.getByTestId(testIds.onboarding.stepProducts);
// Navigation runs in onSuccess after POST + SWR mutate + session.update(); wait for API first (CI).
const createWorkspacePost = page.waitForResponse(
@@ -105,7 +106,7 @@ test.describe("Dub Partners onboarding", () => {
new URL(r.url()).pathname === "/api/workspaces",
{ timeout: STEP_NAV_TIMEOUT },
);
- await page.getByRole("button", { name: "Create workspace" }).click();
+ await page.getByTestId(testIds.onboarding.createWorkspace).click();
const createWsRes = await createWorkspacePost;
if (!createWsRes.ok()) {
throw new Error(
@@ -122,42 +123,44 @@ test.describe("Dub Partners onboarding", () => {
expect(page).toHaveURL(/\/onboarding\/domain/, {
timeout: STEP_NAV_TIMEOUT,
}),
- page.getByRole("button", { name: "Continue with Dub Partners" }).click(),
+ page.getByTestId(testIds.onboarding.productCta("partners")).click(),
]);
// Domain step — connect a custom domain
- await expect(
- page.getByRole("heading", { name: "Add a custom domain" }),
- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
+ await expect(page.getByTestId(testIds.onboarding.stepDomain)).toBeVisible({
+ timeout: STEP_NAV_TIMEOUT,
+ });
await Promise.all([
expect(page).toHaveURL(/\/onboarding\/domain\/custom/, {
timeout: STEP_NAV_TIMEOUT,
}),
- page.getByRole("button", { name: "Connect domain" }).click(),
+ page.getByTestId(testIds.onboarding.connectDomain).click(),
]);
await expect(
- page.getByRole("heading", { name: "Connect a custom domain" }),
+ page.getByTestId(testIds.onboarding.stepDomainCustom),
).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
- await page.getByPlaceholder("go.acme.com").fill(customDomain);
- await expect(page.getByText(/is ready to connect/i)).toBeVisible({
+ await page.getByTestId(testIds.onboarding.domainInput).fill(customDomain);
+ await expect(
+ page.getByTestId(testIds.onboarding.domainAvailable),
+ ).toBeVisible({
timeout: 30_000,
});
await Promise.all([
expect(page).toHaveURL(/\/onboarding\/program/, {
timeout: STEP_NAV_TIMEOUT,
}),
- page.getByRole("button", { name: "Add domain" }).click(),
+ page.getByTestId(testIds.onboarding.addDomain).click(),
]);
// Partner program step
await expect(
- page.getByRole("heading", { name: "Create your partner program" }),
+ page.getByTestId(testIds.onboarding.stepProgram),
).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
await page
- .getByTestId("onboarding-program-company-name")
+ .getByTestId(testIds.onboarding.programCompanyName)
.fill(`Test Program ${nanoid(4)}`);
await installProgramLogoUploadMocks(page);
@@ -168,7 +171,7 @@ test.describe("Dub Partners onboarding", () => {
new URL(r.url()).pathname.endsWith("/upload-url"),
{ timeout: STEP_NAV_TIMEOUT },
);
- await page.getByTestId("onboarding-program-logo").setInputFiles({
+ await page.getByTestId(testIds.onboarding.programLogo).setInputFiles({
name: "logo.png",
mimeType: "image/png",
buffer: MINIMAL_PNG,
@@ -179,52 +182,52 @@ test.describe("Dub Partners onboarding", () => {
`Logo upload-url failed: HTTP ${uploadUrlRes.status()} ${await uploadUrlRes.text()}`,
);
}
- await expect(page.getByText("logo.png uploaded!")).toBeVisible({
+ await expect(
+ page.getByTestId(testIds.onboarding.programLogoUploaded),
+ ).toBeVisible({
timeout: 30_000,
});
await page
- .getByTestId("onboarding-program-destination-url")
+ .getByTestId(testIds.onboarding.programDestinationUrl)
.fill("https://acme.com");
await page
- .getByTestId("onboarding-program-support-email")
+ .getByTestId(testIds.onboarding.programSupportEmail)
await Promise.all([
expect(page).toHaveURL(/\/onboarding\/program\/reward/, {
timeout: STEP_NAV_TIMEOUT,
}),
- page.getByTestId("onboarding-program-continue").click(),
+ page.getByTestId(testIds.onboarding.programContinue).click(),
]);
// Default reward — keep Sale / recurring / percentage defaults, set 30%
- await expect(
- page.getByRole("heading", { name: "Create your default reward" }),
- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
- const pctInput = page.getByTestId("onboarding-reward-amount");
+ await expect(page.getByTestId(testIds.onboarding.stepReward)).toBeVisible({
+ timeout: STEP_NAV_TIMEOUT,
+ });
+ const pctInput = page.getByTestId(testIds.onboarding.rewardAmount);
await expect(pctInput).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
await pctInput.fill("30");
await Promise.all([
expect(page).toHaveURL(/\/onboarding\/plan/, {
timeout: STEP_NAV_TIMEOUT,
}),
- page.getByTestId("onboarding-reward-continue").click(),
+ page.getByTestId(testIds.onboarding.rewardContinue).click(),
]);
// Plan step — mocked checkout trial (no Stripe)
- await expect(
- page
- .locator("h1")
- .filter({ hasText: /Partners/i })
- .filter({ hasText: /plan/i }),
- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
+ await expect(page.getByTestId(testIds.onboarding.stepPlan)).toBeVisible({
+ timeout: STEP_NAV_TIMEOUT,
+ });
await installBillingCheckoutMocks(page, {
slug,
baseURL,
});
- // use testId instead (since plan-selector overrides UpgradePlanButton text)
- const advancedPaidCta = page.getByTestId("onboarding-plan-cta-advanced");
+ const advancedPaidCta = page.getByTestId(
+ testIds.onboarding.planCta("advanced"),
+ );
await expect(advancedPaidCta).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
await expect(advancedPaidCta).toBeEnabled({ timeout: STEP_NAV_TIMEOUT });
@@ -245,15 +248,13 @@ test.describe("Dub Partners onboarding", () => {
});
await expect(
- page.getByRole("heading", {
- name: `The ${workspaceName} workspace has been created`,
- }),
- ).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
+ page.getByTestId(testIds.onboarding.workspaceCreated),
+ ).toContainText(workspaceName, { timeout: STEP_NAV_TIMEOUT });
await expect(
- page.getByRole("button", { name: "Go to your dashboard" }),
+ page.getByTestId(testIds.onboarding.goToDashboard),
).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
await expect(
- page.getByRole("heading", { name: "Complete setup" }),
+ page.getByTestId(testIds.onboarding.completeSetup),
).toBeVisible({ timeout: STEP_NAV_TIMEOUT });
await expect
diff --git a/apps/web/ui/auth/login/email-sign-in.tsx b/apps/web/ui/auth/login/email-sign-in.tsx
index 8611da49d0..59c5a1a9f0 100644
--- a/apps/web/ui/auth/login/email-sign-in.tsx
+++ b/apps/web/ui/auth/login/email-sign-in.tsx
@@ -1,4 +1,5 @@
import { checkAccountExistsAction } from "@/lib/actions/check-account-exists";
+import { testIds } from "@/lib/e2e/test-ids";
import { Button, Input, useCurrentSubdomain, useMediaQuery } from "@dub/ui";
import { cn } from "@dub/utils";
import { signIn } from "next-auth/react";
@@ -66,7 +67,9 @@ export const EmailSignIn = ({ next }: { next?: string }) => {
if (!accountExists) {
setClickedMethod(undefined);
- toast.error("No account found with that email address.");
+ toast.error("No account found with that email address.", {
+ testId: testIds.auth.loginNoAccount,
+ });
return;
}
}
@@ -83,7 +86,9 @@ export const EmailSignIn = ({ next }: { next?: string }) => {
if (!accountExists) {
setClickedMethod(undefined);
- toast.error("No account found with that email address.");
+ toast.error("No account found with that email address.", {
+ testId: testIds.auth.loginNoAccount,
+ });
return;
}
@@ -101,7 +106,11 @@ export const EmailSignIn = ({ next }: { next?: string }) => {
}
if (response.error) {
- if (errorCodes[response.error]) {
+ if (response.error === "invalid-credentials") {
+ toast.error(errorCodes[response.error], {
+ testId: testIds.auth.loginInvalidCredentials,
+ });
+ } else if (errorCodes[response.error]) {
toast.error(errorCodes[response.error]);
} else {
toast.error(response.error);
@@ -176,6 +185,7 @@ export const EmailSignIn = ({ next }: { next?: string }) => {
)}
<Button
+ data-testid={testIds.auth.loginSubmit}
text={`Log in with ${password ? "password" : "email"}`}
{...(authMethod !== "email" && {
type: "button",
diff --git a/apps/web/ui/auth/register/signup-email.tsx b/apps/web/ui/auth/register/signup-email.tsx
index 3c42385017..ea5a61a9ac 100644
--- a/apps/web/ui/auth/register/signup-email.tsx
+++ b/apps/web/ui/auth/register/signup-email.tsx
@@ -1,6 +1,7 @@
"use client";
import { sendOtpAction } from "@/lib/actions/send-otp";
+import { testIds } from "@/lib/e2e/test-ids";
import { signUpSchema } from "@/lib/zod/schemas/auth";
import { PasswordRequirements } from "@/ui/shared/password-requirements";
import { Button, Input, useCurrentSubdomain, useMediaQuery } from "@dub/ui";
@@ -107,6 +108,7 @@ export const SignUpEmail = () => {
text={isPending ? "Submitting..." : "Sign Up"}
disabled={isPending}
loading={isPending}
+ data-testid={testIds.auth.signupSubmit}
/>
</div>
</form>
diff --git a/apps/web/ui/domains/add-edit-domain-form.tsx b/apps/web/ui/domains/add-edit-domain-form.tsx
index 1e4a1bb7f6..75f2c6da89 100644
--- a/apps/web/ui/domains/add-edit-domain-form.tsx
+++ b/apps/web/ui/domains/add-edit-domain-form.tsx
@@ -1,4 +1,5 @@
import { isValidDomain } from "@/lib/api/domains/is-valid-domain";
+import { testIds } from "@/lib/e2e/test-ids";
import { mutatePrefix } from "@/lib/swr/mutate";
import useWorkspace from "@/lib/swr/use-workspace";
import { DomainProps } from "@/lib/types";
@@ -121,6 +122,8 @@ export function AddEditDomainForm({
initialDomain,
fixedDomainSuffix,
isOnboardingSubdomainFlow = false,
+ submitTestId,
+ domainInputTestId,
}: {
props?: DomainProps;
onSuccess?: (data: DomainProps) => void;
@@ -128,6 +131,8 @@ export function AddEditDomainForm({
fixedDomainSuffix?: string;
initialDomain?: string;
isOnboardingSubdomainFlow?: boolean;
+ submitTestId?: string;
+ domainInputTestId?: string;
}) {
const { id: workspaceId, plan } = useWorkspace();
const [lockDomain, setLockDomain] = useState(true);
@@ -462,6 +467,7 @@ export function AddEditDomainForm({
className="block w-full rounded-md border-0 text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-0 sm:text-sm"
placeholder="go.acme.com"
autoFocus={!isMobile}
+ data-testid={domainInputTestId}
/>
)}
</div>
@@ -471,7 +477,13 @@ export function AddEditDomainForm({
transition={{ ease: "easeInOut", duration: 0.1 }}
>
<div className="flex items-center justify-between gap-4 p-2 text-sm">
- <p>
+ <p
+ data-testid={
+ domainStatus === "available"
+ ? testIds.onboarding.domainAvailable
+ : undefined
+ }
+ >
{domainStatus !== "idle" ? (
domainStatus === "invalid" ||
domainStatus === "error" ? (
@@ -743,6 +755,7 @@ export function AddEditDomainForm({
text={props ? "Save changes" : "Add domain"}
disabled={saveDisabled}
loading={isSubmitting}
+ data-testid={submitTestId}
/>
</div>
</form>
diff --git a/apps/web/ui/layout/sidebar/sidebar-usage.tsx b/apps/web/ui/layout/sidebar/sidebar-usage.tsx
index 5c3cfb7559..4d765c212e 100644
--- a/apps/web/ui/layout/sidebar/sidebar-usage.tsx
+++ b/apps/web/ui/layout/sidebar/sidebar-usage.tsx
@@ -1,6 +1,7 @@
"use client";
import { clientAccessCheck } from "@/lib/client-access-check";
+import { testIds } from "@/lib/e2e/test-ids";
import useWorkspace from "@/lib/swr/use-workspace";
import { useRetryPaymentModal } from "@/ui/modals/retry-payment-modal";
import { useStartPaidPlanModal } from "@/ui/modals/start-paid-plan-modal";
@@ -124,7 +125,10 @@ function UsageInner() {
<div className="border-t border-neutral-300/80 p-3">
{isTrial ? (
<div className="flex items-center justify-between gap-2">
- <span className="text-sm font-semibold text-neutral-900">
+ <span
+ className="text-sm font-semibold text-neutral-900"
+ data-testid={testIds.billing.freeTrial}
+ >
Free trial
</span>
diff --git a/apps/web/ui/modals/start-paid-plan-modal.tsx b/apps/web/ui/modals/start-paid-plan-modal.tsx
index a7fc2772ee..f515accdaf 100644
--- a/apps/web/ui/modals/start-paid-plan-modal.tsx
+++ b/apps/web/ui/modals/start-paid-plan-modal.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import useWorkspace from "@/lib/swr/use-workspace";
import { Button, Modal, useRouterStuff } from "@dub/ui";
import { getPlanDetails } from "@dub/utils";
@@ -83,7 +84,10 @@ function StartPaidPlanModal({
className="max-w-md"
>
<div className="sm:py-4.5 border-b border-neutral-200 px-4 py-3 sm:px-6">
- <h3 className="text-lg font-medium text-neutral-900">
+ <h3
+ className="text-lg font-medium text-neutral-900"
+ data-testid={testIds.billing.startPaidPlanHeading}
+ >
Plan start confirmation
</h3>
</div>
@@ -110,7 +114,10 @@ function StartPaidPlanModal({
</div>
)}
</div>
- <p className="text-sm text-neutral-600">
+ <p
+ className="text-sm text-neutral-600"
+ data-testid={testIds.billing.startPaidPlanNotice}
+ >
You&apos;ll be charged today and your trial will end.
</p>
</div>
@@ -130,6 +137,7 @@ function StartPaidPlanModal({
loading={isSubmitting}
disabled={isSubmitting}
onClick={handleConfirm}
+ data-testid={testIds.billing.confirmStartPaidPlan}
/>
</div>
</Modal>
diff --git a/apps/web/ui/modals/upgraded-modal.tsx b/apps/web/ui/modals/upgraded-modal.tsx
index 0b36739531..81b473b905 100644
--- a/apps/web/ui/modals/upgraded-modal.tsx
+++ b/apps/web/ui/modals/upgraded-modal.tsx
@@ -1,3 +1,4 @@
+import { testIds } from "@/lib/e2e/test-ids";
import useWorkspace from "@/lib/swr/use-workspace";
import { useWorkspaceStore } from "@/lib/swr/use-workspace-store";
import { Button, Modal, useRouterStuff, useScrollProgress } from "@dub/ui";
@@ -130,7 +131,10 @@ function UpgradedModal({
onScroll={updateScrollProgress}
className="scrollbar-hide max-h-[calc(100vh-400px)] overflow-y-auto pb-6 text-left"
>
- <h1 className="text-lg font-semibold text-neutral-900">
+ <h1
+ className="text-lg font-semibold text-neutral-900"
+ data-testid={testIds.billing.upgradedHeading}
+ >
Dub {plan?.name} looks good on you!
</h1>
<p className="mt-2 text-sm text-neutral-600">
@@ -173,6 +177,7 @@ function UpgradedModal({
<Button
type="button"
variant={showDotLinkClaimUi ? "secondary" : "primary"}
+ data-testid={testIds.billing.viewDashboard}
text={
showDotLinkClaimUi
? "No thanks, take me to the dashboard"
diff --git a/apps/web/ui/workspaces/create-workspace-form.tsx b/apps/web/ui/workspaces/create-workspace-form.tsx
index 94c2dbdef6..03a14a4d0e 100644
--- a/apps/web/ui/workspaces/create-workspace-form.tsx
+++ b/apps/web/ui/workspaces/create-workspace-form.tsx
@@ -1,5 +1,6 @@
"use client";
+import { testIds } from "@/lib/e2e/test-ids";
import { isGenericEmail } from "@/lib/email/is-generic-email";
import { AlertCircleFill } from "@/ui/shared/icons";
import { Button, buttonVariants, FileUpload, useMediaQuery } from "@dub/ui";
@@ -115,6 +116,7 @@ export function CreateWorkspaceForm({
<div className="mt-2 flex rounded-md shadow-sm">
<input
id="name"
+ data-testid={testIds.onboarding.workspaceName}
type="text"
autoFocus={!isMobile}
autoComplete="off"
@@ -143,6 +145,7 @@ export function CreateWorkspaceForm({
</span>
<input
id="slug"
+ data-testid={testIds.onboarding.workspaceSlug}
type="text"
required
autoComplete="off"
@@ -245,6 +248,7 @@ export function CreateWorkspaceForm({
<Button
loading={isSubmitting || isSubmitSuccessful}
text="Create workspace"
+ data-testid={testIds.onboarding.createWorkspace}
/>
</form>
);