import React from "react"; import { describe, it, expect, vi } from "vitest"; import { render, screen } from "@testing-library/react"; // Mock next/navigation vi.mock("next/navigation", () => ({ usePathname: () => "/", useRouter: () => ({ push: vi.fn(), replace: vi.fn(), back: vi.fn() }), useSearchParams: () => new URLSearchParams(), })); vi.mock("next/link", () => ({ default: ({ children, href, ...props }: any) => {children}, })); vi.mock("next/image", () => ({ default: (props: any) => , })); // Mock stores const mockCartState: any = { items: [ { product: { id: "p1", name: "Canina Product", nameFa: "مکمل کنینا", priceValue: 100000, image: "/img.png", category: "سگ", }, quantity: 2, }, ], totalPrice: 200000, updateQuantity: vi.fn(), removeItem: vi.fn(), hasItem: vi.fn().mockReturnValue(false), getTotalItems: vi.fn().mockReturnValue(2), getSubtotal: vi.fn().mockReturnValue(200000), getDiscount: vi.fn().mockReturnValue(0), getTotal: vi.fn().mockReturnValue(200000), couponCode: null, applyCoupon: vi.fn(), removeCoupon: vi.fn(), }; vi.mock("../../lib/store/cartStore", () => ({ useCartStore: (selector?: any) => (typeof selector === "function" ? selector(mockCartState) : mockCartState), })); const mockSettingsState: any = { getText: (k: string, d: string) => { if (k === 'contact_instagram') return 'https://instagram.com/canina'; if (k === 'contact_telegram') return 'https://t.me/canina'; return d || 'mock'; }, getBoolean: () => true, }; vi.mock("../../lib/store/settingsStore", () => { const store = (selector?: any) => (typeof selector === "function" ? selector(mockSettingsState) : mockSettingsState); store.getState = () => mockSettingsState; return { useSettingsStore: store }; }); const mockUIState = { setCartOpen: vi.fn(), }; vi.mock("../../lib/store/uiStore", () => ({ useUIStore: (selector?: any) => (typeof selector === "function" ? selector(mockUIState) : mockUIState), })); vi.mock("../../lib/services/api", () => ({ default: { get: vi.fn().mockResolvedValue({ data: [] }), post: vi.fn().mockResolvedValue({ data: {} }), }, })); vi.mock("../../lib/services/productService", () => ({ productService: { getProducts: vi.fn().mockResolvedValue({ data: [] }), }, })); import CartDrawer from "../CartDrawer"; import IngredientWiki from "../IngredientWiki"; import ContactFormClient from "../ContactFormClient"; import Footer from "../Footer"; import MobileBottomNav from "../MobileBottomNav"; describe("Touch Target >= 44px Verification (UX-30)", () => { it("ensures CartDrawer quantity and close buttons have min 44x44px touch targets", () => { render(); const closeBtn = screen.getByLabelText("بستن سبد خرید"); expect(closeBtn.className).toContain("min-w-[44px]"); expect(closeBtn.className).toContain("min-h-[44px]"); const minusBtn = screen.getByTestId("minus-btn"); expect(minusBtn.className).toContain("min-w-[44px]"); expect(minusBtn.className).toContain("min-h-[44px]"); const plusBtn = screen.getByTestId("plus-btn"); expect(plusBtn.className).toContain("min-w-[44px]"); expect(plusBtn.className).toContain("min-h-[44px]"); const deleteBtn = screen.getByTestId("cart-item-delete-btn"); expect(deleteBtn.className).toContain("min-w-[44px]"); expect(deleteBtn.className).toContain("min-h-[44px]"); }); it("ensures MobileBottomNav cart tab has min-h-[48px] (>= 44px) touch target", () => { render(); const cartBtn = screen.getByText("سبد خرید").closest("button"); expect(cartBtn).not.toBeNull(); expect(cartBtn?.className).toContain("min-h-[48px]"); }); it("ensures IngredientWiki navigation has >= 44px touch targets", () => { render(); const backBtn = screen.getByRole("button", { name: "بازگشت" }); expect(backBtn.className).toContain("min-h-[44px]"); }); it("ensures ContactForm submit retry button has min-h-[44px]", () => { render(); expect(screen.getByText("اطلاعات نمایندگی")).toBeTruthy(); }); it("ensures Footer action links and social badges have >= 44px touch targets", () => { render(