diff --git a/frontend/application/app/home-retention.test.tsx b/frontend/application/app/home-retention.test.tsx new file mode 100644 index 00000000..aae69106 --- /dev/null +++ b/frontend/application/app/home-retention.test.tsx @@ -0,0 +1,82 @@ +import React from "react"; +import { describe, it, expect, vi } from "vitest"; +import { render, screen } from "@testing-library/react"; + +// Mock child components to verify presence without side-effects +vi.mock("../components/Hero", () => ({ + default: () =>
Hero
, +})); +vi.mock("../components/SmartAdvisor", () => ({ + default: () =>
SmartAdvisor
, +})); +vi.mock("../components/BannerPlacement", () => ({ + default: ({ position }: { position: string }) => ( +
BannerPlacement {position}
+ ), +})); +vi.mock("../components/FeaturedProducts", () => ({ + default: () =>
FeaturedProducts
, +})); +vi.mock("../components/VetGallery", () => ({ + default: () =>
VetGallery
, +})); +vi.mock("../components/TestimonialsSection", () => ({ + default: () =>
TestimonialsSection
, +})); +vi.mock("../components/BlogPreviewSection", () => ({ + default: () =>
BlogPreviewSection
, +})); +vi.mock("../components/FAQSection", () => ({ + default: () =>
FAQSection
, +})); + +vi.mock("next/link", () => ({ + default: ({ children, href, ...props }: any) => {children}, +})); + +vi.mock("next/image", () => ({ + default: ({ src, alt, ...props }: any) => {alt}, +})); + +vi.mock("../lib/services/api", () => ({ + default: { + get: vi.fn().mockReturnValue(new Promise(() => {})), // Avoid triggering state updates during test + }, +})); + +vi.mock("../lib/store/settingsStore", () => ({ + useSettingsStore: (selector?: any) => { + const s = { getText: (k: string, d: string) => d }; + return typeof selector === "function" ? selector(s) : s; + }, +})); + +import HomeClient from "./HomeClient"; + +describe("Home Sections Mobile Retention Gate (UX-35)", () => { + it("strictly retains 100% of all core Home sections and feature cards without mobile exclusion or deletion", () => { + const { container } = render(); + + // Verify presence of all major sections + expect(screen.getByTestId("hero-section")).toBeTruthy(); + expect(screen.getByTestId("smart-advisor-section")).toBeTruthy(); + expect(screen.getByTestId("banner-placement-home_middle")).toBeTruthy(); + expect(screen.getByTestId("featured-products-section")).toBeTruthy(); + expect(screen.getByTestId("vet-gallery-section")).toBeTruthy(); + expect(screen.getByTestId("testimonials-section")).toBeTruthy(); + expect(screen.getByTestId("blog-preview-section")).toBeTruthy(); + expect(screen.getByTestId("faq-section")).toBeTruthy(); + + // Verify navigation specialty cards + expect(screen.getByText("داروخانه تخصصی مکمل‌ها")).toBeTruthy(); + expect(screen.getByText("دانشنامه علمی و مقالات")).toBeTruthy(); + + // Ensure none of the sections have `hidden` alone as a display class on mobile + const sections = container.querySelectorAll("section"); + expect(sections.length).toBeGreaterThanOrEqual(10); + sections.forEach((sec) => { + const classList = sec.className.split(/\s+/); + expect(classList).not.toContain("hidden"); + }); + }); +});