From 993aa5823a70f17b7c62693b724f208239f2c257 Mon Sep 17 00:00:00 2001 From: ncoronel Date: Wed, 8 Jul 2026 16:12:35 -0300 Subject: [PATCH] feat(product-detail): implement resolver for product details and update component logic for improved error handling feat(product-carousel): enhance image loading with optimized attributes and improve layout consistency style: refactor HTML structure for better readability and maintainability test(product-detail): add unit tests for product detail resolver and component behavior --- src/app/app.config.ts | 18 +- .../product-carousel.component.html | 79 +++++--- .../product-carousel.component.ts | 6 +- .../product-detail-page.component.spec.ts | 178 ++++++++++-------- .../product-detail-page.component.ts | 105 +++++------ .../product-detail-page.resolver.spec.ts | 91 +++++++++ .../product-detail-page.resolver.ts | 53 ++++++ src/app/features/store/store.routes.ts | 64 ++++--- 8 files changed, 391 insertions(+), 203 deletions(-) create mode 100644 src/app/features/store/pages/product-detail-page/product-detail-page.resolver.spec.ts create mode 100644 src/app/features/store/pages/product-detail-page/product-detail-page.resolver.ts diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 9b6bf20..a00ccb3 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -1,5 +1,9 @@ import { HttpRequest, provideHttpClient, withFetch, withInterceptors } from '@angular/common/http'; -import { ApplicationConfig, provideAppInitializer, provideBrowserGlobalErrorListeners } from '@angular/core'; +import { + ApplicationConfig, + provideAppInitializer, + provideBrowserGlobalErrorListeners, +} from '@angular/core'; import { provideRouter } from '@angular/router'; import { provideClientHydration, withHttpTransferCacheOptions } from '@angular/platform-browser'; @@ -8,10 +12,10 @@ import { authBootstrap } from './core/services/auth/auth-bootstrap'; import { authInterceptor } from './core/services/auth/auth.interceptor'; import { tenantBootstrap } from './core/services/tenant-bootstrap'; -function isStoreHomeProductsRequest(request: HttpRequest): boolean { +function isStoreCatalogRequest(request: HttpRequest): boolean { return ( request.method === 'GET' && - /\/api\/tenants\/[^/]+\/productos(?:\?|$)/.test(request.urlWithParams) + /\/api\/tenants\/[^/]+\/productos(?:\/\d+)?(?:\?|$)/.test(request.urlWithParams) ); } @@ -22,11 +26,11 @@ export const appConfig: ApplicationConfig = { provideClientHydration( withHttpTransferCacheOptions({ includeRequestsWithAuthHeaders: true, - filter: isStoreHomeProductsRequest - }) + filter: isStoreCatalogRequest, + }), ), provideHttpClient(withFetch(), withInterceptors([authInterceptor])), provideAppInitializer(authBootstrap), - provideAppInitializer(tenantBootstrap) - ] + provideAppInitializer(tenantBootstrap), + ], }; diff --git a/src/app/features/store/components/product-carousel/product-carousel.component.html b/src/app/features/store/components/product-carousel/product-carousel.component.html index defccde..4633bba 100644 --- a/src/app/features/store/components/product-carousel/product-carousel.component.html +++ b/src/app/features/store/components/product-carousel/product-carousel.component.html @@ -1,51 +1,70 @@