import { cleanup, render } from "@testing-library/react"; import { afterEach, describe, expect, test, vi } from "vitest"; import { UsernameForm } from "./username-form"; vi.mock("next/navigation", () => ({ useRouter: () => ({ push: vi.fn() }), })); vi.mock("next-intl", () => ({ useTranslations: () => (key: string) => key, })); vi.mock("@/lib/server/loginname", () => ({ sendLoginname: vi.fn(), })); describe("UsernameForm", () => { afterEach(cleanup); test("should autofocus the loginName input on mount", () => { const { getByTestId } = render( , ); expect(getByTestId("username-text-input")).toHaveFocus(); }); });