E2E: add /sign-in redirect; use it in Clerk Cypress login helper

This commit is contained in:
abhi1693
2026-02-07 19:06:47 +00:00
parent 388402b834
commit 8a2f792541
2 changed files with 17 additions and 2 deletions

View File

@@ -34,8 +34,9 @@ Cypress.Commands.add("loginWithClerkOtp", () => {
const opts: ClerkOtpLoginOptions = { clerkOrigin, email, otp };
// Trigger the modal from the app first.
cy.get('[data-testid="activity-signin"]').click({ force: true });
// Navigate to a dedicated sign-in route that performs a top-level redirect
// to Clerk hosted sign-in (avoids modal/iframe limitations in Cypress).
cy.visit("/sign-in");
// The Clerk UI is typically hosted on a different origin (clerk.accounts.dev / clerk.com).
// Use cy.origin to drive the UI in Chrome.

View File

@@ -0,0 +1,14 @@
import { redirect } from "next/navigation";
import { auth } from "@clerk/nextjs/server";
export default function SignInPage() {
const { userId, redirectToSignIn } = auth();
if (userId) {
redirect("/activity");
}
// Top-level redirect to Clerk hosted sign-in.
// Cypress E2E cannot reliably drive Clerk modal/iframe login.
return redirectToSignIn({ returnBackUrl: "/activity" });
}