test(ux-35): enforce 100% home section retention and zero mobile content exclusion regression gate

This commit is contained in:
devops committed 2026-10-17 19:02:19 +00:00
1 parent bfe228adee
commit 5d5cc14f9e
1 file changed
+82
@@ -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: () => <section data-testid="hero-section">Hero</section>,
}));
vi.mock("../components/SmartAdvisor", () => ({
default: () => <section data-testid="smart-advisor-section">SmartAdvisor</section>,
}));
vi.mock("../components/BannerPlacement", () => ({
default: ({ position }: { position: string }) => (
<section data-testid={`banner-placement-${position}`}>BannerPlacement {position}</section>
),
}));
vi.mock("../components/FeaturedProducts", () => ({
default: () => <section data-testid="featured-products-section">FeaturedProducts</section>,
}));
vi.mock("../components/VetGallery", () => ({
default: () => <section data-testid="vet-gallery-section">VetGallery</section>,
}));
vi.mock("../components/TestimonialsSection", () => ({
default: () => <section data-testid="testimonials-section">TestimonialsSection</section>,
}));
vi.mock("../components/BlogPreviewSection", () => ({
default: () => <section data-testid="blog-preview-section">BlogPreviewSection</section>,
}));
vi.mock("../components/FAQSection", () => ({
default: () => <section data-testid="faq-section">FAQSection</section>,
}));
vi.mock("next/link", () => ({
default: ({ children, href, ...props }: any) => <a href={href} {...props}>{children}</a>,
}));
vi.mock("next/image", () => ({
default: ({ src, alt, ...props }: any) => <img src={src} alt={alt} {...props} />,
}));
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(<HomeClient initialData={null} />);
// 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");
});
});
});