import { describe, expect, it, vi } from "vitest"; import "@testing-library/jest-dom/vitest"; import TopWithPathname from "../../app/components/navigation/Top/TopWithPathname"; import { renderWithProviders, screen } from "../utils/test-utils"; const { pushMock } = vi.hoisted(() => ({ pushMock: vi.fn() })); vi.mock("next/navigation", () => ({ useRouter: () => ({ push: pushMock, replace: vi.fn(), prefetch: vi.fn(), back: vi.fn(), forward: vi.fn(), refresh: vi.fn(), }), usePathname: () => "/learn", })); vi.mock("../../lib/create/api", () => ({ fetchAuthSession: () => new Promise(() => {}), })); describe("TopWithPathname", () => { it("renders Profile from the server session before /api/auth/session resolves", () => { renderWithProviders(); expect( screen.getByRole("menuitem", { name: /go to your profile/i }), ).toBeInTheDocument(); expect( screen.queryByRole("button", { name: /log in to your account/i }), ).not.toBeInTheDocument(); }); });