import { render, screen, fireEvent, waitFor } from "@testing-library/react"; import PostJobPage from "./page"; import { toast } from "sonner"; import { useRouter } from "next/navigation"; // Mock dependencies jest.mock("@/lib/i18n", () => ({ useTranslation: () => ({ t: (key: string) => key, locale: "en", setLocale: jest.fn(), }), useI18n: () => ({ t: (key: string) => key, locale: "en", setLocale: jest.fn(), }), })); jest.mock("next/navigation", () => ({ useRouter: jest.fn(), })); jest.mock("sonner", () => ({ toast: { error: jest.fn(), success: jest.fn(), }, })); jest.mock("./translations", () => ({ translations: { en: { title: "Post a Job", buttons: { next: "Next Step", publish: "Publish Job", publishing: "Publishing..." }, company: { name: "Company Name", namePlaceholder: "My Company", email: "Email", password: "Password", confirmPassword: "Confirm Password", phone: "Phone", }, job: { title: "Job Details", jobTitle: "Job Title", jobTitlePlaceholder: "e.g. Developer", description: "Job Description", location: "Location", salary: "Salary", }, steps: { data: "Data", confirm: "Confirm" }, cardTitle: { step1: "Step 1", step2: "Step 2" }, cardDesc: { step1: "Desc 1", step2: "Desc 2" }, common: { company: "Company", job: "Job", name: "Name", email: "Email", title: "Title" }, options: { period: { hourly: "/hr" }, contract: { permanent: "Permanent" }, hours: { fullTime: "Full Time" }, mode: { remote: "Remote" } }, errors: { company_required: "Company required", password_mismatch: "Password mismatch", password_length: "Password length", job_required: "Job required", submit_failed: "Submit failed" }, success: { job_created: "Job created" } }, }, })); // Mock RichTextEditor component jest.mock("@/components/rich-text-editor", () => ({ RichTextEditor: ({ value, onChange, placeholder }: any) => (