From d881dc491edc5df358adb383cfedb0db35b2e093 Mon Sep 17 00:00:00 2001 From: devops Date: Thu, 5 Nov 2026 08:33:30 +0000 Subject: [PATCH] feat: add advisor/contact flow tables and make Blog.authorId required --- backend/prisma/schema.prisma | 4 +- backend/src/blogs/blogs.service.spec.ts | 4 +- backend/src/blogs/blogs.service.ts | 8 + docker-compose.yml | 28 +- docs/audit/UX-MODERNIZATION-TASK-REGISTER.md | 44 -- .../admin-panel/src/routes/adminRoutes.tsx | 2 +- .../application/app/ClientLayout.test.tsx | 194 ----- frontend/application/app/ClientLayout.tsx | 35 +- frontend/application/app/HomeClient.tsx | 8 +- frontend/application/app/api/version/route.ts | 33 - .../app/api/version/version.test.ts | 19 - .../app/blog/[slug]/blog-slug-page.test.tsx | 104 --- frontend/application/app/blog/[slug]/page.tsx | 17 +- frontend/application/app/cart/page.test.tsx | 24 - frontend/application/app/cart/page.tsx | 19 - frontend/application/app/contact/page.tsx | 2 +- frontend/application/app/globals.css | 8 +- .../application/app/home-retention.test.tsx | 82 -- frontend/application/app/layout.tsx | 11 +- frontend/application/app/login/page.test.tsx | 17 - frontend/application/app/login/page.tsx | 14 - .../app/responsive-routes.test.tsx | 95 --- frontend/application/app/robots.ts | 2 - frontend/application/app/shop/[slug]/page.tsx | 5 +- frontend/application/app/shop/page.tsx | 7 - .../application/app/sitemap-blog.xml/route.ts | 78 -- .../application/app/sitemap-wiki.xml/route.ts | 64 -- frontend/application/app/sitemaps.test.ts | 91 --- frontend/application/app/wiki/[slug]/page.tsx | 11 +- .../application/components/ArchivePage.tsx | 311 +++----- .../components/ArticleContentRenderer.tsx | 120 --- .../components/ArticleProductCard.tsx | 202 ----- frontend/application/components/AuthModal.tsx | 7 +- frontend/application/components/BlogPage.tsx | 184 ++--- .../application/components/BlogPostClient.tsx | 21 +- .../components/BlogPreviewSection.tsx | 4 +- .../application/components/CartDrawer.tsx | 19 +- .../application/components/CheckoutPage.tsx | 2 +- .../components/ContactFormClient.tsx | 9 +- .../components/FeaturedProducts.tsx | 4 +- frontend/application/components/Footer.tsx | 18 +- frontend/application/components/Header.tsx | 4 - frontend/application/components/Hero.tsx | 8 +- .../application/components/IngredientWiki.tsx | 195 ++--- .../components/MaintenancePage.tsx | 17 +- .../components/MobileBottomNav.tsx | 31 +- .../application/components/OrderSuccess.tsx | 2 +- .../application/components/OrderTracking.tsx | 2 +- .../application/components/ProductPage.tsx | 32 +- .../components/SearchResultsPage.tsx | 708 +++--------------- .../application/components/SmartAdvisor.tsx | 18 +- .../components/SupportChat.test.tsx | 20 +- .../application/components/SupportChat.tsx | 32 +- .../application/components/TickerBanner.tsx | 5 +- .../application/components/UserDashboard.tsx | 2 +- .../components/__tests__/ArchivePage.test.tsx | 146 +--- .../__tests__/ArticleContentRenderer.test.tsx | 84 --- .../__tests__/ArticleProductCard.test.tsx | 101 --- .../components/__tests__/BlogPage.test.tsx | 2 +- .../__tests__/BlogPostClient.test.tsx | 47 +- .../__tests__/ContactFormClient.test.tsx | 13 - .../components/__tests__/Footer.test.tsx | 13 +- .../__tests__/HeadingHierarchyUX24.test.tsx | 80 -- .../__tests__/IngredientWiki.test.tsx | 175 +---- .../__tests__/MaintenancePage.test.tsx | 4 +- .../__tests__/MobileBottomNav.test.tsx | 29 - .../components/__tests__/ProductPage.test.tsx | 5 - .../__tests__/SearchResultsPage.test.tsx | 67 +- .../__tests__/responsive-matrix.test.ts | 56 -- .../__tests__/search-menu-nav.test.tsx | 65 -- .../__tests__/support-safe-area.test.tsx | 37 - .../__tests__/touch-targets.test.tsx | 141 ---- .../__tests__/viewport-overflow.test.tsx | 36 - .../__tests__/wcag-contrast.test.ts | 73 -- .../components/catalog/CatalogPageSpread.tsx | 4 +- .../lib/__tests__/faq-schema.test.ts | 64 -- .../application/lib/__tests__/fonts.test.ts | 29 - .../lib/__tests__/seo-technical.test.ts | 153 ---- frontend/application/lib/extractFaqs.ts | 101 --- frontend/application/lib/fonts.ts | 15 +- frontend/application/lib/sanitizeBlogHtml.ts | 32 - frontend/application/lib/seo.ts | 5 +- frontend/application/lib/utils.ts | 20 - frontend/application/package.json | 6 +- .../public/fonts/Lalezar-Regular.woff2 | Bin 84912 -> 0 bytes nginx.conf | 8 +- 86 files changed, 507 insertions(+), 4111 deletions(-) delete mode 100644 docs/audit/UX-MODERNIZATION-TASK-REGISTER.md delete mode 100644 frontend/application/app/ClientLayout.test.tsx delete mode 100644 frontend/application/app/api/version/route.ts delete mode 100644 frontend/application/app/api/version/version.test.ts delete mode 100644 frontend/application/app/blog/[slug]/blog-slug-page.test.tsx delete mode 100644 frontend/application/app/cart/page.test.tsx delete mode 100644 frontend/application/app/cart/page.tsx delete mode 100644 frontend/application/app/home-retention.test.tsx delete mode 100644 frontend/application/app/login/page.test.tsx delete mode 100644 frontend/application/app/login/page.tsx delete mode 100644 frontend/application/app/responsive-routes.test.tsx delete mode 100644 frontend/application/app/sitemap-blog.xml/route.ts delete mode 100644 frontend/application/app/sitemap-wiki.xml/route.ts delete mode 100644 frontend/application/app/sitemaps.test.ts delete mode 100644 frontend/application/components/ArticleContentRenderer.tsx delete mode 100644 frontend/application/components/ArticleProductCard.tsx delete mode 100644 frontend/application/components/__tests__/ArticleContentRenderer.test.tsx delete mode 100644 frontend/application/components/__tests__/ArticleProductCard.test.tsx delete mode 100644 frontend/application/components/__tests__/HeadingHierarchyUX24.test.tsx delete mode 100644 frontend/application/components/__tests__/responsive-matrix.test.ts delete mode 100644 frontend/application/components/__tests__/search-menu-nav.test.tsx delete mode 100644 frontend/application/components/__tests__/support-safe-area.test.tsx delete mode 100644 frontend/application/components/__tests__/touch-targets.test.tsx delete mode 100644 frontend/application/components/__tests__/viewport-overflow.test.tsx delete mode 100644 frontend/application/components/__tests__/wcag-contrast.test.ts delete mode 100644 frontend/application/lib/__tests__/faq-schema.test.ts delete mode 100644 frontend/application/lib/__tests__/fonts.test.ts delete mode 100644 frontend/application/lib/__tests__/seo-technical.test.ts delete mode 100644 frontend/application/lib/extractFaqs.ts delete mode 100644 frontend/application/lib/sanitizeBlogHtml.ts delete mode 100644 frontend/application/public/fonts/Lalezar-Regular.woff2 diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index 207988c8..3b3d2804 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -178,7 +178,7 @@ model Blog { slug String @unique @db.VarChar(200) content String @db.Text excerpt String? @db.Text - authorId String? @map("author_id") @db.Uuid + authorId String @map("author_id") @db.Uuid categoryId String? @map("category_id") @db.Uuid imageUrl String? @map("image_url") @db.Text imageAlt String? @map("image_alt") @db.VarChar(255) @@ -209,7 +209,7 @@ model Blog { createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz() updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz() - author User? @relation(fields: [authorId], references: [id]) + author User @relation(fields: [authorId], references: [id]) category BlogCategory? @relation(fields: [categoryId], references: [id], onDelete: SetNull) tags BlogTag[] comments BlogComment[] diff --git a/backend/src/blogs/blogs.service.spec.ts b/backend/src/blogs/blogs.service.spec.ts index df3628a8..d617785e 100644 --- a/backend/src/blogs/blogs.service.spec.ts +++ b/backend/src/blogs/blogs.service.spec.ts @@ -40,7 +40,7 @@ describe("BlogsService", () => { describe("findAll", () => { it("should query published blogs with pagination", async () => { const blogs = [ - { id: "1", title: "Blog 1", isPublished: true, status: "PUBLISHED", author: null }, + { id: "1", title: "Blog 1", isPublished: true, status: "PUBLISHED" }, ]; mockPrisma.blog.findMany.mockResolvedValue(blogs); mockPrisma.blog.count.mockResolvedValue(1); @@ -49,8 +49,6 @@ describe("BlogsService", () => { expect(mockPrisma.blog.findMany).toHaveBeenCalled(); expect(result.data).toEqual(blogs); expect(result.meta.total).toBe(1); - const query = mockPrisma.blog.findMany.mock.calls[0][0]; - expect(query.include.author).toBeUndefined(); }); it("should filter by categorySlug and search term", async () => { diff --git a/backend/src/blogs/blogs.service.ts b/backend/src/blogs/blogs.service.ts index edcbf302..370c9758 100644 --- a/backend/src/blogs/blogs.service.ts +++ b/backend/src/blogs/blogs.service.ts @@ -68,6 +68,9 @@ export class BlogsService { [sortBy === "createdAt" ? "createdAt" : "publishedAt"]: sortOrder, }, include: { + author: { + select: { firstName: true, lastName: true }, + }, category: { select: { id: true, name: true, slug: true }, }, @@ -107,6 +110,7 @@ export class BlogsService { take: 4, orderBy: { publishedAt: "desc" }, include: { + author: { select: { firstName: true, lastName: true } }, category: { select: { id: true, name: true, slug: true } }, tags: { select: { id: true, name: true, slug: true } }, _count: { select: { comments: { where: { status: "APPROVED" } } } }, @@ -123,6 +127,7 @@ export class BlogsService { take: 4, orderBy: { publishedAt: "desc" }, include: { + author: { select: { firstName: true, lastName: true } }, category: { select: { id: true, name: true, slug: true } }, tags: { select: { id: true, name: true, slug: true } }, _count: { select: { comments: { where: { status: "APPROVED" } } } }, @@ -158,6 +163,9 @@ export class BlogsService { ], }, include: { + author: { + select: { firstName: true, lastName: true }, + }, category: { select: { id: true, name: true, slug: true }, }, diff --git a/docker-compose.yml b/docker-compose.yml index bf5dbfb8..6e5d2c82 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: db_stage: image: postgres:16-alpine @@ -25,22 +23,36 @@ services: build: context: ./backend dockerfile: Dockerfile + args: + NPM_REGISTRY: ${NPM_REGISTRY:-} container_name: canino_backend_stage restart: always + env_file: + - path: .support-chat.env + required: false + - path: .revalidation.env + required: false + dns: + - 217.218.127.127 + - 217.218.155.155 environment: - DATABASE_URL=postgresql://canino_stage:caninopassword_stage@db_stage:5432/caninodb_stage?schema=public + - SUPPORT_CHAT_URL=http://canina-bot:8643/support/ask - REDIS_HOST=redis_stage - REDIS_PORT=6379 - PORT=3000 - - ADMIN_PASSWORD=Z6nYnJRG_sg3pnz2J9wZ7dLsPj61cd5k + - FRONTEND_URL=https://stage.canina.ir + - ENABLE_SWAGGER=false + # Code-only stage startup: schema/seed changes require separate authorization. + command: ["node", "dist/main.js"] volumes: - canina_stage_uploads:/app/uploads + - /opt/services/proxy/certs/canina:/app/ssl_certs labels: - "traefik.enable=true" - "traefik.http.routers.canina-api-stage.rule=Host(`stageapi.canina.ir`)" - "traefik.http.routers.canina-api-stage.entrypoints=websecure" - "traefik.http.routers.canina-api-stage.tls=true" - - "traefik.http.routers.canina-api-stage.tls.certresolver=arvan" - "traefik.http.services.canina-api-stage.loadbalancer.server.port=3000" depends_on: - db_stage @@ -53,16 +65,22 @@ services: context: . dockerfile: Dockerfile args: + NPM_REGISTRY: ${NPM_REGISTRY:-} NEXT_PUBLIC_API_URL: "https://stageapi.canina.ir/api" VITE_API_URL: "https://stageapi.canina.ir" container_name: canino_frontend_stage restart: always + env_file: + - path: .revalidation.env + required: false + dns: + - 217.218.127.127 + - 217.218.155.155 labels: - "traefik.enable=true" - "traefik.http.routers.canina-stage.rule=Host(`stage.canina.ir`) || Host(`stageadmin.canina.ir`)" - "traefik.http.routers.canina-stage.entrypoints=websecure" - "traefik.http.routers.canina-stage.tls=true" - - "traefik.http.routers.canina-stage.tls.certresolver=arvan" - "traefik.http.routers.canina-stage.middlewares=staging-robots-headers" - "traefik.http.middlewares.staging-robots-headers.headers.customresponseheaders.X-Robots-Tag=noindex, nofollow, nosnippet, noarchive" - "traefik.http.services.canina-stage.loadbalancer.server.port=8080" diff --git a/docs/audit/UX-MODERNIZATION-TASK-REGISTER.md b/docs/audit/UX-MODERNIZATION-TASK-REGISTER.md deleted file mode 100644 index 529e0931..00000000 --- a/docs/audit/UX-MODERNIZATION-TASK-REGISTER.md +++ /dev/null @@ -1,44 +0,0 @@ -# Canina UX Modernization — Task Register - -Source: live Chromium audits, source audit at `bec76393b`, and QA/SEO/content reviews. -Status model: TODO -> IN_PROGRESS -> TEST -> DONE. Estimates are engineering hours, not elapsed calendar time. - -| ID | Owner departments | Pri | Estimate | Dependencies | Acceptance summary | Status | -|---|---|---:|---:|---|---|---| -| UX-PMO-001 | PMO | P0 | 4h | audits | Register, owners, dependencies, release gates and evidence contract are versioned | DONE | -| UX-DEV-001 | Dev + QA | P0 | 12h | none | `/login` and `/cart` are real routes, no 404, mobile/desktop smoke tests pass | IN_PROGRESS | -| UX-CAT-001 | Dev + UX + QA | P0 | 24h | UX-DEV-001 | Shop has deterministic SSR/client data states: success/loading/empty/error/retry | TODO | -| UX-CAT-002 | Dev + Product + QA | P0 | 24h | UX-CAT-001 | Catalog uses typed pagination/query URL state; no limit-999 hydration | TODO | -| UX-DATA-001 | Dev + DevOps | P0 | 20h | UX-CAT-001 | API errors are typed/actionable; cache tags and invalidation are verified | TODO | -| UX-A11Y-001 | UX + Dev + QA | P0 | 16h | UX-DEV-001 | Forms/buttons/overlays have names, labels, focus return and keyboard operation | TODO | -| UX-RESP-001 | UX + Dev + QA | P1 | 20h | UX-CAT-001 | 360/390/768/1024/1440 layouts have no unintended overflow and 44px targets | TODO | -| UX-PDP-001 | Product + UX + Dev + QA | P1 | 20h | UX-CAT-001 | PDP has one H1 and above-fold image/name/price/stock/CTA at all viewports | TODO | -| UX-CHECKOUT-001 | Payments + Dev + QA | P1 | 20h | UX-A11Y-001 | Checkout fields have labels/autocomplete/inputmode and announced errors | TODO | -| UX-NAV-001 | UX + Product + Dev | P1 | 16h | UX-RESP-001 | Mobile/desktop navigation is canonical, active state and cart state are consistent | TODO | -| UX-SEARCH-001 | Product + UX + SEO + Dev | P1 | 16h | UX-CAT-002 | Search landmark, Persian normalization, result count and actionable no-results state | TODO | -| UX-CONTENT-001 | Content + UX | P1 | 12h | UX-NAV-001 | Persian CTA/glossary unified across shop, wiki, auth, cart and footer | TODO | -| UX-CONTACT-001 | Support + Dev + Product | P1 | 4h | settings readback | No empty `tel:`/`mailto:` targets; official values verified live | TODO | -| UX-SEO-001 | SEO + Dev + QA | P1 | 16h | UX-CAT-002 | Category URLs, canonical/H1/meta and sitemap parity are tested | TODO | -| UX-SEO-002 | SEO + Dev + Content | P1 | 12h | UX-SEO-001 | Product 404 is real 404; Product/Offer/Breadcrumb JSON-LD matches facts | TODO | -| UX-MEDIA-001 | Content + SEO + Dev | P2 | 12h | UX-PDP-001 | Product/blog/feed images are valid, same-item, HTTPS and have useful alt text | TODO | -| UX-PERF-001 | Dev + DevOps + QA | P0 | 24h | UX-CAT-002, UX-RESP-001 | Mobile LCP/CLS/INP budgets, reduced-motion and image dimensions are verified | TODO | -| UX-ARCH-001 | Dev + UX | P1 | 24h | UX-CAT-001 | ArchivePage/global shell split into typed, independently testable feature modules | TODO | -| UX-STATE-001 | Dev + Commerce + QA | P0 | 24h | UX-DATA-001 | Cart price/stock/order state is backend-authoritative and persisted safely | TODO | -| UX-TEST-001 | Dev + QA | P0 | 16h | UX-DEV-001 | npm test/typecheck/lint scripts and coverage gates execute in clean checkout | TODO | -| UX-E2E-001 | QA + DevOps | P1 | 20h | UX-TEST-001, UX-RESP-001 | Chromium desktop/mobile smoke covers shop/PDP/cart/login/checkout/errors | TODO | -| UX-CI-001 | DevOps + Dev + QA | P0 | 20h | UX-TEST-001, UX-E2E-001 | CI gates lint/type/unit/build/E2E/perf and publishes evidence | TODO | -| UX-DEPLOY-001 | DevOps + QA | P1 | 24h | UX-CI-001 | Immutable SHA deployment, health checks, smoke gate and rollback are documented/tested | TODO | -| UX-CLAIMS-001 | R&D + Content + Compliance + human vet review | P1 | 32h | legal/vet access | 35 product/media medical claims have evidence/status and no unsupported claims publish | BLOCKED_EXTERNAL_REVIEW | -| UX-VERIFY-001 | PMO + QA + Analytics | P2 | 16h | all release tasks | Live release checklist, CWV/error/catalog/checkout telemetry and go/no-go evidence | TODO | - -**Current program estimate:** 396 engineering/review hours; critical path is lower with parallel teams. External legal/human-veterinarian review, recruited user panel, GSC/GA4 access and payment sandbox are explicit blockers where applicable. - -## Immediate execution order - -1. UX-DEV-001 — restore login/cart routes (current) -2. UX-TEST-001 — make frontend test/typecheck gates executable -3. UX-A11Y-001 + UX-RESP-001 — fix shared interaction and responsive foundations -4. UX-CAT-001/002 + UX-DATA-001 — reliable catalog flow -5. UX-PDP-001 + UX-CHECKOUT-001 + UX-STATE-001 — conversion journey -6. SEO/content/media/performance/CI/deployment gates -7. Live verification and release decision diff --git a/frontend/admin-panel/src/routes/adminRoutes.tsx b/frontend/admin-panel/src/routes/adminRoutes.tsx index ad49413e..adbf5bc0 100644 --- a/frontend/admin-panel/src/routes/adminRoutes.tsx +++ b/frontend/admin-panel/src/routes/adminRoutes.tsx @@ -81,7 +81,7 @@ export const router = createBrowserRouter([ { path: 'zibal-portal/*', element: }, { path: 'coupons/*', element: }, { path: 'settings', element: }, - { path: 'settings/smart-chat', element: }, + { path: 'settings/smart-chat', element: }, { path: 'settings/smart-chat/config', element: }, { path: 'settings/payment-methods', element: }, { path: 'settings/shipping', element: }, diff --git a/frontend/application/app/ClientLayout.test.tsx b/frontend/application/app/ClientLayout.test.tsx deleted file mode 100644 index 7c550eea..00000000 --- a/frontend/application/app/ClientLayout.test.tsx +++ /dev/null @@ -1,194 +0,0 @@ -import React from "react"; -import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; -import { render, screen, cleanup } from "@testing-library/react"; - -// Mock next/navigation -let currentPathname = "/"; -const mockRouter = { - push: vi.fn(), - replace: vi.fn(), - back: vi.fn(), - prefetch: vi.fn(), -}; - -vi.mock("next/navigation", () => ({ - usePathname: () => currentPathname, - useRouter: () => mockRouter, - useSearchParams: () => new URLSearchParams(), -})); - -// Mock dynamic components to render test identifiers -vi.mock("next/dynamic", () => ({ - default: (loader: any) => { - const str = loader.toString(); - const isCart = str.includes("CartDrawer"); - const isAuth = str.includes("AuthModal"); - const isLogin = str.includes("LoginModal"); - return function MockDynamic(props: any) { - if (props.isOpen === false) return null; - if (isCart) return
; - if (isAuth) return
; - if (isLogin) return
; - return
; - }; - }, -})); - -vi.mock("../components/Header", () => ({ - default: () =>
Header
, -})); - -vi.mock("../components/Footer", () => ({ - default: () =>
Footer
, -})); - -vi.mock("../components/NetworkBanner", () => ({ - NetworkBanner: () => null, -})); - -vi.mock("../components/NavigationProgressBar", () => ({ - default: () => null, -})); - -vi.mock("../components/MobileBottomNav", () => ({ - default: () => null, -})); - -vi.mock("../components/PrescriptionUploadModal", () => ({ - default: () => null, -})); - -vi.mock("sonner", () => ({ - Toaster: () => null, - toast: { success: vi.fn(), error: vi.fn() }, -})); - -// Mock real components used inside page routes -vi.mock("../components/AuthModal", () => ({ - default: (props: any) => ( -
- ), -})); - -vi.mock("../components/CartDrawer", () => ({ - default: (props: any) => ( -
- ), -})); - -// Mock stores -const mockUserStoreState: any = { - isAuthModalOpen: false, - setAuthModalOpen: vi.fn(), - fetchProfile: vi.fn().mockResolvedValue({}), - user: null, -}; - -vi.mock("../lib/store/userStore", () => { - const store = (selector?: any) => (typeof selector === "function" ? selector(mockUserStoreState) : mockUserStoreState); - store.getState = () => mockUserStoreState; - return { useUserStore: store }; -}); - -const mockSettingsStoreState: any = { - fetchSettings: vi.fn().mockResolvedValue({}), - getText: vi.fn().mockReturnValue(""), - getBoolean: vi.fn().mockReturnValue(false), -}; - -vi.mock("../lib/store/settingsStore", () => { - const store = (selector?: any) => (typeof selector === "function" ? selector(mockSettingsStoreState) : mockSettingsStoreState); - store.getState = () => mockSettingsStoreState; - return { useSettingsStore: store }; -}); - -const mockUIStoreState: any = { - isCartOpen: false, - isLoginModalOpen: false, - isB2BPortalOpen: false, - advisorData: null, - setCartOpen: vi.fn(), - setLoginModalOpen: vi.fn(), - setB2BPortalOpen: vi.fn(), - clearAdvisorData: vi.fn(), -}; - -vi.mock("../lib/store/uiStore", () => { - const store = (selector?: any) => (typeof selector === "function" ? selector(mockUIStoreState) : mockUIStoreState); - store.getState = () => mockUIStoreState; - return { useUIStore: store }; -}); - -import ClientLayout from "../app/ClientLayout"; -import LoginPage from "../app/login/page"; -import CartPage from "../app/cart/page"; - -describe("ClientLayout Shell & Singleton Modals Integration (UX-28)", () => { - beforeEach(() => { - vi.clearAllMocks(); - mockUserStoreState.isAuthModalOpen = false; - mockUIStoreState.isCartOpen = false; - currentPathname = "/"; - }); - - afterEach(() => { - cleanup(); - }); - - it("renders singleton CartDrawer and AuthModal in ClientLayout on normal routes when opened", () => { - mockUIStoreState.isCartOpen = true; - mockUserStoreState.isAuthModalOpen = true; - - render( - -
Content
-
- ); - - // On normal route, Header, Footer, and active drawers are rendered - expect(screen.getByTestId("shell-header")).toBeTruthy(); - expect(screen.getByTestId("shell-footer")).toBeTruthy(); - expect(screen.getByTestId("shell-cart-drawer")).toBeTruthy(); - expect(screen.getByTestId("shell-auth-modal")).toBeTruthy(); - }); - - it("ensures no duplicate CartDrawer exists when user visits /cart utility route", () => { - currentPathname = "/cart"; - mockUIStoreState.isCartOpen = true; // Even if UI store flag was left open - - const { container } = render( - - - - ); - - // Footer and shell-level CartDrawer must be suppressed on /cart - expect(screen.queryByTestId("shell-footer")).toBeNull(); - - // Page level cart drawer is present - expect(screen.getByTestId("page-cart-drawer")).toBeTruthy(); - - // Shell level dynamic cart drawer is NOT rendered because isUtilityRoute is true - expect(screen.queryByTestId("shell-cart-drawer")).toBeNull(); - }); - - it("ensures no duplicate AuthModal exists when user visits /login utility route", () => { - currentPathname = "/login"; - mockUserStoreState.isAuthModalOpen = true; // Even if userStore auth flag was left open - - const { container } = render( - - - - ); - - // Footer and shell-level AuthModal must be suppressed on /login - expect(screen.queryByTestId("shell-footer")).toBeNull(); - - // Page level auth modal is present - expect(screen.getByTestId("page-auth-modal")).toBeTruthy(); - - // Shell level dynamic auth modal is NOT rendered because isUtilityRoute is true - expect(screen.queryByTestId("shell-auth-modal")).toBeNull(); - }); -}); diff --git a/frontend/application/app/ClientLayout.tsx b/frontend/application/app/ClientLayout.tsx index 5d8fa079..fae81a50 100644 --- a/frontend/application/app/ClientLayout.tsx +++ b/frontend/application/app/ClientLayout.tsx @@ -39,10 +39,9 @@ export default function ClientLayout({ children }: { children: React.ReactNode } const setB2BPortalOpen = useUIStore((state) => state.setB2BPortalOpen); const clearAdvisorData = useUIStore((state) => state.clearAdvisorData); const [isPrescriptionModalOpen, setIsPrescriptionModalOpen] = useState(false); - + const pathname = usePathname(); const router = useRouter(); - const isUtilityRoute = pathname === "/login" || pathname === "/cart"; const fetchProfile = useUserStore((state) => state.fetchProfile); const role = useUserStore((state) => state.role); @@ -167,9 +166,9 @@ export default function ClientLayout({ children }: { children: React.ReactNode } <> -
setCartOpen(true)} onSearch={handleSearch} @@ -178,23 +177,23 @@ export default function ClientLayout({ children }: { children: React.ReactNode }
{children}
- {!isUtilityRoute &&