import { render, screen } from "@testing-library/react"
import { CandidateDashboardContent } from "./candidate-dashboard"

// Mocks
jest.mock("@/lib/auth", () => ({
    getCurrentUser: jest.fn().mockReturnValue({ id: "1", name: "Candidate User" }),
    isAuthenticated: jest.fn().mockReturnValue(true),
}))

jest.mock("@/contexts/notification-context", () => ({
    useNotifications: jest.fn().mockReturnValue({ notifications: [], markAsRead: jest.fn() }),
    useNotify: jest.fn().mockReturnValue(jest.fn()),
}))

jest.mock("@/lib/i18n", () => ({
    useTranslation: () => ({
        t: (key: string) => key,
    }),
}))

jest.mock("@/lib/api", () => ({
    jobsApi: {
        list: jest.fn().mockResolvedValue({ data: [], pagination: {} }),
    },
    applicationsApi: {
        list: jest.fn().mockResolvedValue([]),
    },
    notificationsApi: {
        list: jest.fn().mockResolvedValue([]),
    },
    ticketsApi: {
        list: jest.fn().mockResolvedValue([]),
    },
}))

jest.mock("@/components/ui/card", () => ({
    Card: ({ children }: any) => <div>{children}</div>,
    CardHeader: ({ children }: any) => <div>{children}</div>,
    CardTitle: ({ children }: any) => <h3>{children}</h3>,
    CardDescription: ({ children }: any) => <p>{children}</p>,
    CardContent: ({ children }: any) => <div>{children}</div>,
}))

jest.mock("@/components/ui/button", () => ({
    Button: ({ children }: any) => <button>{children}</button>,
}))

jest.mock("@/components/ui/skeleton", () => ({
    Skeleton: () => <div>Loading...</div>,
}))

jest.mock("@/components/stats-card", () => ({
    StatsCard: () => <div>StatsCard</div>,
}))

jest.mock("@/components/job-card", () => ({
    JobCard: () => <div>JobCard</div>,
}))

describe("CandidateDashboard", () => {
    it("renders welcome message", async () => {
        render(<CandidateDashboardContent />)
        // Check for static text or known content
        // Assuming dashboard has "Welcome" or similar
        // Or check for section headers "My Applications", "Recommended Jobs"
        // Wait for potential async data loading
        expect(await screen.findByText("candidate.dashboard.recommended.title")).toBeInTheDocument()
    })
})
