E2E: add /sign-in redirect; use it in Clerk Cypress login helper
This commit is contained in:
@@ -34,8 +34,9 @@ Cypress.Commands.add("loginWithClerkOtp", () => {
|
|||||||
|
|
||||||
const opts: ClerkOtpLoginOptions = { clerkOrigin, email, otp };
|
const opts: ClerkOtpLoginOptions = { clerkOrigin, email, otp };
|
||||||
|
|
||||||
// Trigger the modal from the app first.
|
// Navigate to a dedicated sign-in route that performs a top-level redirect
|
||||||
cy.get('[data-testid="activity-signin"]').click({ force: true });
|
// 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).
|
// The Clerk UI is typically hosted on a different origin (clerk.accounts.dev / clerk.com).
|
||||||
// Use cy.origin to drive the UI in Chrome.
|
// Use cy.origin to drive the UI in Chrome.
|
||||||
|
|||||||
14
frontend/src/app/sign-in/page.tsx
Normal file
14
frontend/src/app/sign-in/page.tsx
Normal 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" });
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user