2025-12-25 21:54:19 +01:00
|
|
|
import { screen, cleanup } from "@testing-library/react";
|
2025-12-18 22:08:31 +01:00
|
|
|
import { expect, test, vi, beforeEach, afterEach } from "vitest";
|
|
|
|
|
import SignupPage from "./page";
|
2025-12-25 21:54:19 +01:00
|
|
|
import { renderWithProviders } from "../test-utils";
|
2025-12-18 22:08:31 +01:00
|
|
|
|
|
|
|
|
const mockPush = vi.fn();
|
|
|
|
|
vi.mock("next/navigation", () => ({
|
|
|
|
|
useRouter: () => ({ push: mockPush }),
|
2025-12-20 11:43:32 +01:00
|
|
|
useSearchParams: () => ({ get: () => null }),
|
2025-12-18 22:08:31 +01:00
|
|
|
}));
|
|
|
|
|
|
2025-12-25 21:54:19 +01:00
|
|
|
const mockRegister = vi.fn();
|
2025-12-18 22:08:31 +01:00
|
|
|
vi.mock("../auth-context", () => ({
|
2025-12-25 21:54:19 +01:00
|
|
|
useAuth: () => ({ user: null, register: mockRegister }),
|
|
|
|
|
AuthProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
2025-12-18 22:08:31 +01:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
beforeEach(() => vi.clearAllMocks());
|
|
|
|
|
afterEach(() => cleanup());
|
|
|
|
|
|
|
|
|
|
test("renders signup form with title", () => {
|
2025-12-25 21:54:19 +01:00
|
|
|
renderWithProviders(<SignupPage />);
|
2025-12-20 11:43:32 +01:00
|
|
|
// Step 1 shows "Join with Invite" title (invite code entry)
|
2025-12-25 22:14:04 +01:00
|
|
|
expect(screen.getByRole("heading", { name: "Únete con Invitación" })).toBeDefined();
|
2025-12-18 22:08:31 +01:00
|
|
|
});
|
|
|
|
|
|
2025-12-20 11:43:32 +01:00
|
|
|
test("renders invite code input", () => {
|
2025-12-25 21:54:19 +01:00
|
|
|
renderWithProviders(<SignupPage />);
|
2025-12-26 19:06:57 +01:00
|
|
|
expect(screen.getByLabelText("Código de invitación")).toBeDefined();
|
2025-12-18 22:08:31 +01:00
|
|
|
});
|
|
|
|
|
|
2025-12-20 11:43:32 +01:00
|
|
|
test("renders continue button", () => {
|
2025-12-25 21:54:19 +01:00
|
|
|
renderWithProviders(<SignupPage />);
|
2025-12-25 22:14:04 +01:00
|
|
|
expect(screen.getByRole("button", { name: "Continuar" })).toBeDefined();
|
2025-12-18 22:08:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("renders link to login", () => {
|
2025-12-25 21:54:19 +01:00
|
|
|
renderWithProviders(<SignupPage />);
|
2025-12-25 22:14:04 +01:00
|
|
|
expect(screen.getByText("Iniciar sesión")).toBeDefined();
|
2025-12-18 22:08:31 +01:00
|
|
|
});
|