From cb861377303b2e54f202f3bc9ff98fbcf4898bb3 Mon Sep 17 00:00:00 2001 From: printcalc-ci Date: Tue, 24 Mar 2026 12:19:19 +0000 Subject: [PATCH] style: apply prettier formatting --- .../shop/product-detail.component.spec.ts | 24 +++++-- .../features/shop/product-detail.component.ts | 62 +++++++++---------- .../features/shop/shop-page.component.spec.ts | 62 ++++++++++++------- .../app/features/shop/shop-page.component.ts | 4 +- 4 files changed, 86 insertions(+), 66 deletions(-) diff --git a/frontend/src/app/features/shop/product-detail.component.spec.ts b/frontend/src/app/features/shop/product-detail.component.spec.ts index 3e73a9d..08c0cf9 100644 --- a/frontend/src/app/features/shop/product-detail.component.spec.ts +++ b/frontend/src/app/features/shop/product-detail.component.spec.ts @@ -97,7 +97,9 @@ describe('ProductDetailComponent', () => { const languageService = { currentLang, selectedLang: () => currentLang(), - setLocalizedRouteOverrides: jasmine.createSpy('setLocalizedRouteOverrides'), + setLocalizedRouteOverrides: jasmine.createSpy( + 'setLocalizedRouteOverrides', + ), clearLocalizedRouteOverrides: jasmine.createSpy( 'clearLocalizedRouteOverrides', ), @@ -113,7 +115,9 @@ describe('ProductDetailComponent', () => { .createSpy('quantityForVariant') .and.returnValue(0), loadCart: jasmine.createSpy('loadCart').and.returnValue(of(null)), - resolveMediaUrl: jasmine.createSpy('resolveMediaUrl').and.returnValue(null), + resolveMediaUrl: jasmine + .createSpy('resolveMediaUrl') + .and.returnValue(null), }; const router = { @@ -126,9 +130,13 @@ describe('ProductDetailComponent', () => { } as unknown as Router; const activatedRoute = { - paramMap: of(convertToParamMap({ productSlug: '91823f84-bike-wall-hanger' })), + paramMap: of( + convertToParamMap({ productSlug: '91823f84-bike-wall-hanger' }), + ), snapshot: { - paramMap: convertToParamMap({ productSlug: '91823f84-bike-wall-hanger' }), + paramMap: convertToParamMap({ + productSlug: '91823f84-bike-wall-hanger', + }), }, } as unknown as ActivatedRoute; @@ -200,7 +208,9 @@ describe('ProductDetailComponent', () => { it('builds a soft SSR fallback with 200 + index follow', () => { const { component, seoService, responseInit } = createComponent(); - expect((component as any).shouldUseSoftSeoFallback({ status: 500 })).toBeTrue(); + expect( + (component as any).shouldUseSoftSeoFallback({ status: 500 }), + ).toBeTrue(); (component as any).setResponseStatus(200); (component as any).applySoftFallbackSeo('91823f84-bike-wall-hanger'); @@ -221,7 +231,9 @@ describe('ProductDetailComponent', () => { it('keeps hard fallback noindex for missing products', () => { const { component, seoService, responseInit } = createComponent(); - expect((component as any).shouldUseSoftSeoFallback({ status: 404 })).toBeFalse(); + expect( + (component as any).shouldUseSoftSeoFallback({ status: 404 }), + ).toBeFalse(); (component as any).setResponseStatus(404); (component as any).applyHardFallbackSeo(); diff --git a/frontend/src/app/features/shop/product-detail.component.ts b/frontend/src/app/features/shop/product-detail.component.ts index 47f7257..3573be6 100644 --- a/frontend/src/app/features/shop/product-detail.component.ts +++ b/frontend/src/app/features/shop/product-detail.component.ts @@ -254,37 +254,35 @@ export class ProductDetailComponent { } const productSlug = routeParams.productSlug as string; - return this.shopService - .getProductByPublicPath(productSlug) - .pipe( - catchError((error) => { - this.languageService.clearLocalizedRouteOverrides(); - this.product.set(null); - this.selectedVariantId.set(null); - this.setSelectedImageAssetId(null); - this.modelFile.set(null); - const isNotFound = error?.status === 404; - if (isNotFound) { - this.error.set('SHOP.NOT_FOUND'); - this.setResponseStatus(404); - this.applyHardFallbackSeo(); - return of(null); - } - - if (this.shouldUseSoftSeoFallback(error)) { - this.error.set(null); - this.softFallbackActive.set(true); - this.setResponseStatus(200); - this.applySoftFallbackSeo(productSlug); - return of(null); - } - - this.error.set('SHOP.LOAD_ERROR'); - this.setResponseStatus(503); + return this.shopService.getProductByPublicPath(productSlug).pipe( + catchError((error) => { + this.languageService.clearLocalizedRouteOverrides(); + this.product.set(null); + this.selectedVariantId.set(null); + this.setSelectedImageAssetId(null); + this.modelFile.set(null); + const isNotFound = error?.status === 404; + if (isNotFound) { + this.error.set('SHOP.NOT_FOUND'); + this.setResponseStatus(404); + this.applyHardFallbackSeo(); return of(null); - }), - finalize(() => this.loading.set(false)), - ); + } + + if (this.shouldUseSoftSeoFallback(error)) { + this.error.set(null); + this.softFallbackActive.set(true); + this.setResponseStatus(200); + this.applySoftFallbackSeo(productSlug); + return of(null); + } + + this.error.set('SHOP.LOAD_ERROR'); + this.setResponseStatus(503); + return of(null); + }), + finalize(() => this.loading.set(false)), + ); }), takeUntilDestroyed(this.destroyRef), ) @@ -904,9 +902,7 @@ export class ProductDetailComponent { return this.normalizeRouteParam(this.route.snapshot.paramMap.get(name)); } - private normalizeRouteParam( - value: string | null | undefined, - ): string | null { + private normalizeRouteParam(value: string | null | undefined): string | null { const normalized = String(value ?? '').trim(); return normalized || null; } diff --git a/frontend/src/app/features/shop/shop-page.component.spec.ts b/frontend/src/app/features/shop/shop-page.component.spec.ts index 048234a..39a8ea5 100644 --- a/frontend/src/app/features/shop/shop-page.component.spec.ts +++ b/frontend/src/app/features/shop/shop-page.component.spec.ts @@ -60,24 +60,26 @@ describe('ShopPageComponent', () => { 'TranslateService', ['instant'], ); - translate.instant.and.callFake((key: string, params?: { count?: number }) => { - const translations: Record = { - 'SHOP.TITLE': 'Technische Lösungen', - 'SHOP.SUBTITLE': 'Fertige Produkte, die praktische Probleme lösen', - 'SHOP.CATALOG_TITLE': 'Alle Produkte', - 'SHOP.CATALOG_LABEL': 'Katalog', - 'SHOP.SELECTED_CATEGORY': 'Ausgewählte Kategorie', - 'SHOP.CATALOG_META_DESCRIPTION': - 'Entdecken Sie 3D-gedruckte Produkte und technisches Zubehör.', - 'SEO.ROUTES.SHOP.CATEGORY_TITLE': 'Shop-Kategorie | 3D fab', - 'SEO.ROUTES.SHOP.CATEGORY_DESCRIPTION': - 'Entdecken Sie Produkte dieser Kategorie und technische Lösungen.', - }; - if (key === 'SHOP.CATEGORY_META') { - return `${params?.count ?? 0} Produkte in dieser Kategorie verfügbar`; - } - return translations[key] ?? key; - }); + translate.instant.and.callFake( + (key: string, params?: { count?: number }) => { + const translations: Record = { + 'SHOP.TITLE': 'Technische Lösungen', + 'SHOP.SUBTITLE': 'Fertige Produkte, die praktische Probleme lösen', + 'SHOP.CATALOG_TITLE': 'Alle Produkte', + 'SHOP.CATALOG_LABEL': 'Katalog', + 'SHOP.SELECTED_CATEGORY': 'Ausgewählte Kategorie', + 'SHOP.CATALOG_META_DESCRIPTION': + 'Entdecken Sie 3D-gedruckte Produkte und technisches Zubehör.', + 'SEO.ROUTES.SHOP.CATEGORY_TITLE': 'Shop-Kategorie | 3D fab', + 'SEO.ROUTES.SHOP.CATEGORY_DESCRIPTION': + 'Entdecken Sie Produkte dieser Kategorie und technische Lösungen.', + }; + if (key === 'SHOP.CATEGORY_META') { + return `${params?.count ?? 0} Produkte in dieser Kategorie verfügbar`; + } + return translations[key] ?? key; + }, + ); const currentLang = signal<'it' | 'en' | 'de' | 'fr'>('de'); const languageService = { @@ -100,11 +102,17 @@ describe('ShopPageComponent', () => { flattenCategoryTree: jasmine .createSpy('flattenCategoryTree') .and.returnValue([]), - quantityForProduct: jasmine.createSpy('quantityForProduct').and.returnValue(0), + quantityForProduct: jasmine + .createSpy('quantityForProduct') + .and.returnValue(0), loadCart: jasmine.createSpy('loadCart').and.returnValue(of(null)), clearCart: jasmine.createSpy('clearCart').and.returnValue(of(null)), - removeCartItem: jasmine.createSpy('removeCartItem').and.returnValue(of(null)), - updateCartItem: jasmine.createSpy('updateCartItem').and.returnValue(of(null)), + removeCartItem: jasmine + .createSpy('removeCartItem') + .and.returnValue(of(null)), + updateCartItem: jasmine + .createSpy('updateCartItem') + .and.returnValue(of(null)), }; const router = { @@ -164,7 +172,9 @@ describe('ShopPageComponent', () => { }); it('keeps noindex for categories explicitly marked as non-indexable', () => { - const { component, seoService } = createComponent('/de/shop/compatible-with-garmin'); + const { component, seoService } = createComponent( + '/de/shop/compatible-with-garmin', + ); (component as any).applySeo(buildCategory({ indexable: false })); @@ -180,7 +190,9 @@ describe('ShopPageComponent', () => { '/de/shop/compatible-with-garmin', ); - expect((component as any).shouldUseSoftSeoFallback({ status: 500 })).toBeTrue(); + expect( + (component as any).shouldUseSoftSeoFallback({ status: 500 }), + ).toBeTrue(); (component as any).setResponseStatus(200); (component as any).applySoftFallbackSeo('compatible-with-garmin'); @@ -203,7 +215,9 @@ describe('ShopPageComponent', () => { '/de/shop/compatible-with-garmin', ); - expect((component as any).shouldUseSoftSeoFallback({ status: 404 })).toBeFalse(); + expect( + (component as any).shouldUseSoftSeoFallback({ status: 404 }), + ).toBeFalse(); (component as any).setResponseStatus(404); (component as any).applyHardErrorSeo(); diff --git a/frontend/src/app/features/shop/shop-page.component.ts b/frontend/src/app/features/shop/shop-page.component.ts index 8287ddd..2890b74 100644 --- a/frontend/src/app/features/shop/shop-page.component.ts +++ b/frontend/src/app/features/shop/shop-page.component.ts @@ -528,9 +528,7 @@ export class ShopPageComponent { return this.normalizeRouteParam(this.route.snapshot.paramMap.get(name)); } - private normalizeRouteParam( - value: string | null | undefined, - ): string | null { + private normalizeRouteParam(value: string | null | undefined): string | null { const normalized = String(value ?? '').trim(); return normalized || null; }