diff --git a/frontend/application/components/SearchResultsPage.tsx b/frontend/application/components/SearchResultsPage.tsx index 652cfc53..30add401 100644 --- a/frontend/application/components/SearchResultsPage.tsx +++ b/frontend/application/components/SearchResultsPage.tsx @@ -194,7 +194,7 @@ export default function SearchResultsPage({ query }: { query: string }) { }; return ( -
+
{/* Mobile-First Header Bar: Back Button & Compact Title */} diff --git a/frontend/application/components/__tests__/search-menu-nav.test.tsx b/frontend/application/components/__tests__/search-menu-nav.test.tsx new file mode 100644 index 00000000..6940faa0 --- /dev/null +++ b/frontend/application/components/__tests__/search-menu-nav.test.tsx @@ -0,0 +1,65 @@ +import React from "react"; +import { describe, it, expect, vi } from "vitest"; +import { render, screen, fireEvent, waitFor } from "@testing-library/react"; + +// Mock next/navigation +let currentPathname = "/search"; +vi.mock("next/navigation", () => ({ + usePathname: () => currentPathname, + 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("../../lib/store/cartStore", () => ({ + useCartStore: (selector?: any) => { + const s = { getTotalItems: () => 0 }; + return typeof selector === "function" ? selector(s) : s; + }, +})); + +vi.mock("../../lib/store/userStore", () => ({ + useUserStore: () => ({ + isLoggedIn: false, + setAuthModalOpen: vi.fn(), + }), +})); + +vi.mock("../../lib/store/uiStore", () => ({ + useUIStore: () => vi.fn(), +})); + +vi.mock("../../lib/store/settingsStore", () => ({ + useSettingsStore: () => ({ + getBoolean: () => true, + getText: () => "true", + }), +})); + +import MobileBottomNav from "../MobileBottomNav"; + +describe("MobileBottomNav on /search route (UX-32)", () => { + it("opens menu bottom sheet smoothly when clicking menu button on search page", async () => { + currentPathname = "/search"; + render(); + + const menuBtn = screen.getByRole("button", { name: "منو" }); + expect(menuBtn).toBeTruthy(); + + fireEvent.click(menuBtn); + + await waitFor(() => { + expect(screen.getByText("منوی بخش‌های کنینا")).toBeTruthy(); + }); + + const closeBtn = screen.getByRole("button", { name: "بستن ✕" }); + fireEvent.click(closeBtn); + + await waitFor(() => { + expect(screen.queryByText("منوی بخش‌های کنینا")).toBeNull(); + }); + }); +});