From 6e7af0dfce2c87e9303ae11eec656037752d3a5f Mon Sep 17 00:00:00 2001 From: Henry Taeschner Date: Fri, 17 Jan 2025 17:07:28 +0100 Subject: [PATCH] feat: test cov 100% --- .../app-detail/app-detail.component.html | 7 +- .../app-search/app-search.component.ts | 3 - .../endpoint-search.component.spec.ts | 70 +++++++++++++++++++ .../endpoint-search.component.ts | 7 +- .../product-detail.component.scss | 1 + .../product-intern.component.html | 40 +++++------ .../product-search.component.spec.ts | 38 ++++++---- .../slot-delete/slot-delete.component.html | 12 +++- 8 files changed, 130 insertions(+), 48 deletions(-) diff --git a/src/app/product-store/app-detail/app-detail.component.html b/src/app/product-store/app-detail/app-detail.component.html index 5db1c6b..24af077 100644 --- a/src/app/product-store/app-detail/app-detail.component.html +++ b/src/app/product-store/app-detail/app-detail.component.html @@ -126,9 +126,10 @@ id="ps_app_detail_form_mfe_field_icon_name" styleClass="w-full" formControlName="iconName" + appendTo="body" [options]="iconItems" - [showClear]="false" - [attr.aria-label]="'APP.ICON_NAME' | translate" + [showClear]="true" + [ariaLabel]="'APP.ICON_NAME' | translate" [pTooltip]="'APP.TOOLTIPS.ICON_NAME' | translate" tooltipPosition="top" tooltipEvent="hover" @@ -402,7 +403,7 @@ pInputText type="text" id="ps_app_detail_form_mfe_field_remote_name" - class="w-full sm:w-18rem pt-3 pb-2 text-responsive" + class="w-full pt-3 pb-2 text-responsive" formControlName="remoteName" [attr.aria-label]="'APP.REMOTE_NAME' | translate" [pTooltip]="'APP.TOOLTIPS.REMOTE_NAME' | translate" diff --git a/src/app/product-store/app-search/app-search.component.ts b/src/app/product-store/app-search/app-search.component.ts index 2bb4f58..56e8dac 100644 --- a/src/app/product-store/app-search/app-search.component.ts +++ b/src/app/product-store/app-search/app-search.component.ts @@ -337,9 +337,6 @@ export class AppSearchComponent implements OnInit, OnDestroy { public onSearchReset() { this.appSearchCriteriaGroup.reset({ appType: 'ALL' }) } - public onBack() { - this.router.navigate(['../'], { relativeTo: this.route }) - } public onGotoProduct(ev: any, product: string) { ev.stopPropagation() this.router.navigate(['../', product], { relativeTo: this.route }) diff --git a/src/app/product-store/endpoint-search/endpoint-search.component.spec.ts b/src/app/product-store/endpoint-search/endpoint-search.component.spec.ts index 99fbb1f..7ac6d69 100644 --- a/src/app/product-store/endpoint-search/endpoint-search.component.spec.ts +++ b/src/app/product-store/endpoint-search/endpoint-search.component.spec.ts @@ -24,6 +24,7 @@ const responseData: MicrofrontendAbstract[] = [ productName: 'product1', appName: 'MFE 1', appId: 'mfe1', + exposedModule: './expMod_p1_mfe1', remoteBaseUrl: '/mfe1/remoteEntry.js', type: MicrofrontendType.Module, endpoints: [ @@ -36,6 +37,7 @@ const responseData: MicrofrontendAbstract[] = [ productName: 'product2', appName: 'MFE 1', appId: 'mfe1', + exposedModule: './expMod_p2_mfe1', remoteBaseUrl: '/mfe1/remoteEntry.js', type: MicrofrontendType.Module, endpoints: [{ name: 'endpoint_2_1_1', path: '/{name}' }] @@ -45,6 +47,7 @@ const responseData: MicrofrontendAbstract[] = [ productName: 'product3', appName: 'MFE 1', appId: 'mfe1', + exposedModule: './expMod_p3_mfe1', remoteBaseUrl: '/mfe1/remoteEntry.js', type: MicrofrontendType.Module } @@ -57,6 +60,7 @@ const itemData: MfeEndpoint[] = [ productName: 'product1', appName: 'MFE 1', appId: 'mfe1', + exposedModule: './expMod_p1_mfe1', remoteBaseUrl: '/mfe1/remoteEntry.js', type: MicrofrontendType.Module, endpoint_name: 'endpoint_1_1_1', @@ -68,6 +72,7 @@ const itemData: MfeEndpoint[] = [ productName: 'product1', appName: 'MFE 1', appId: 'mfe1', + exposedModule: './expMod_p1_mfe1', remoteBaseUrl: '/mfe1/remoteEntry.js', type: MicrofrontendType.Module, endpoint_name: 'endpoint_1_1_2', @@ -79,6 +84,7 @@ const itemData: MfeEndpoint[] = [ productName: 'product2', appName: 'MFE 1', appId: 'mfe1', + exposedModule: './expMod_p2_mfe1', remoteBaseUrl: '/mfe1/remoteEntry.js', type: MicrofrontendType.Module, endpoint_name: 'endpoint_2_1_1', @@ -199,6 +205,44 @@ describe('EndpointSearchComponent', () => { }) }) + describe('page actions', () => { + it('should navigate to Products when button clicked and actionCallback executed', () => { + component.ngOnInit() + + if (component.actions$) { + component.actions$.subscribe((actions) => { + const action = actions[0] + action.actionCallback() + expect(routerSpy.navigate).toHaveBeenCalledWith(['..'], { relativeTo: routeMock }) + }) + } + }) + + it('should navigate to Apps when button clicked and actionCallback executed', () => { + component.ngOnInit() + + if (component.actions$) { + component.actions$.subscribe((actions) => { + const action = actions[1] + action.actionCallback() + expect(routerSpy.navigate).toHaveBeenCalledWith(['../apps'], { relativeTo: routeMock }) + }) + } + }) + + it('should navigate to Slots when button clicked and actionCallback executed', () => { + component.ngOnInit() + + if (component.actions$) { + component.actions$.subscribe((actions) => { + const action = actions[2] + action.actionCallback() + expect(routerSpy.navigate).toHaveBeenCalledWith(['../slots'], { relativeTo: routeMock }) + }) + } + }) + }) + /* * UI ACTIONS */ @@ -250,4 +294,30 @@ describe('EndpointSearchComponent', () => { expect(component.dateFormat).toEqual('M/d/yy, hh:mm:ss a') }) }) + + describe('sort endpoints', () => { + it('should correctly sort items by product', () => { + const items: MfeEndpoint[] = itemData + const sortedItems = items.sort(component.sortMfes) + + expect(sortedItems[0]).toEqual(itemData[0]) + }) + + it("should treat falsy values for SelectItem.label as ''", () => { + const items: MfeEndpoint[] = itemData + items.push({ ...itemData[1], exposedModule: undefined }) + const sortedItems = items.sort(component.sortMfes) + + expect(sortedItems[1]).toEqual(itemData[1]) + }) + + it("should treat falsy values for SelectItem.label as ''", () => { + const items: MfeEndpoint[] = itemData + items.push({ ...itemData[1], exposedModule: undefined }) + items.push({ ...itemData[2], exposedModule: undefined }) + const sortedItems = items.sort(component.sortMfes) + + expect(sortedItems[1]).toEqual(itemData[1]) + }) + }) }) diff --git a/src/app/product-store/endpoint-search/endpoint-search.component.ts b/src/app/product-store/endpoint-search/endpoint-search.component.ts index 5da7455..b45dc0f 100644 --- a/src/app/product-store/endpoint-search/endpoint-search.component.ts +++ b/src/app/product-store/endpoint-search/endpoint-search.component.ts @@ -20,7 +20,7 @@ export interface MicrofrontendSearchCriteria { productName: FormControl } export type ChangeMode = 'VIEW' | 'COPY' | 'CREATE' | 'EDIT' -export type MfeEndpoint = MicrofrontendAbstract & { unique_id: string; endpoint_name?: string; endpoint_path?: string } +export type MfeEndpoint = MicrofrontendAbstract & { unique_id: string; endpoint_name: string; endpoint_path: string } type ExtendedColumn = Column & { hasFilter?: boolean isDate?: boolean @@ -231,6 +231,7 @@ export class EndpointSearchComponent implements OnInit { appId: mfe.appId, appName: mfe.appName, productName: mfe.productName, + exposedModule: mfe.exposedModule, remoteBaseUrl: mfe.remoteBaseUrl, type: mfe.type, unique_id: mfe.id + '_' + i, @@ -256,9 +257,7 @@ export class EndpointSearchComponent implements OnInit { (a.exposedModule ? a.exposedModule.toUpperCase() : '').localeCompare( b.exposedModule ? b.exposedModule.toUpperCase() : '' ) || - (a.endpoint_name ? a.endpoint_name.toUpperCase() : '').localeCompare( - b.endpoint_name ? b.endpoint_name.toUpperCase() : '' - ) + a.endpoint_name.toUpperCase().localeCompare(b.endpoint_name.toUpperCase()) ) } } diff --git a/src/app/product-store/product-detail/product-detail.component.scss b/src/app/product-store/product-detail/product-detail.component.scss index 339151f..a105a60 100644 --- a/src/app/product-store/product-detail/product-detail.component.scss +++ b/src/app/product-store/product-detail/product-detail.component.scss @@ -1,6 +1,7 @@ @import '/src/app/_ps-mixins.scss'; @include danger-action; +@include readable-disabled-form-controls; @include dropdown-zebra-rows; @include compact-dropdown-list-items; @include dialog-modal-dialog-content; diff --git a/src/app/product-store/product-detail/product-intern/product-intern.component.html b/src/app/product-store/product-detail/product-intern/product-intern.component.html index edac9db..d2d0b64 100644 --- a/src/app/product-store/product-detail/product-intern/product-intern.component.html +++ b/src/app/product-store/product-detail/product-intern/product-intern.component.html @@ -2,11 +2,11 @@
- + - + - +
@@ -67,35 +67,31 @@ - + - + - + diff --git a/src/app/product-store/product-search/product-search.component.spec.ts b/src/app/product-store/product-search/product-search.component.spec.ts index 66f7517..c8bab20 100644 --- a/src/app/product-store/product-search/product-search.component.spec.ts +++ b/src/app/product-store/product-search/product-search.component.spec.ts @@ -192,28 +192,38 @@ describe('ProductSearchComponent', () => { expect(component.productSearchCriteriaGroup.reset).toHaveBeenCalled() }) - it('should navigate to new product onNewProduct', () => { - const routerSpy = spyOn(router, 'navigate') + describe('navigate', () => { + it('should navigate to new product onNewProduct', () => { + const routerSpy = spyOn(router, 'navigate') - component.onNewProduct() + component.onNewProduct() - expect(routerSpy).toHaveBeenCalledWith(['./new'], jasmine.any(Object)) - }) + expect(routerSpy).toHaveBeenCalledWith(['./new'], jasmine.any(Object)) + }) - it('should navigate to apps onAppSearch', () => { - const routerSpy = spyOn(router, 'navigate') + it('should navigate to apps onAppSearch', () => { + const routerSpy = spyOn(router, 'navigate') - component.onAppSearch() + component.onAppSearch() - expect(routerSpy).toHaveBeenCalledWith(['./apps'], jasmine.any(Object)) - }) + expect(routerSpy).toHaveBeenCalledWith(['./apps'], jasmine.any(Object)) + }) - it('should navigate to slots onSlotSearch', () => { - const routerSpy = spyOn(router, 'navigate') + it('should navigate to slots onSlotSearch', () => { + const routerSpy = spyOn(router, 'navigate') - component.onSlotSearch() + component.onEndpointSearch() - expect(routerSpy).toHaveBeenCalledWith(['./slots'], jasmine.any(Object)) + expect(routerSpy).toHaveBeenCalledWith(['./endpoints'], jasmine.any(Object)) + }) + + it('should navigate to slots onSlotSearch', () => { + const routerSpy = spyOn(router, 'navigate') + + component.onSlotSearch() + + expect(routerSpy).toHaveBeenCalledWith(['./slots'], jasmine.any(Object)) + }) }) it('should sort products by display name', () => { diff --git a/src/app/product-store/slot-delete/slot-delete.component.html b/src/app/product-store/slot-delete/slot-delete.component.html index 1b86a2e..c77fc3b 100644 --- a/src/app/product-store/slot-delete/slot-delete.component.html +++ b/src/app/product-store/slot-delete/slot-delete.component.html @@ -13,8 +13,16 @@
{{ 'ACTIONS.DELETE.SLOT.MESSAGE' | translate }}
-
{{ slot?.name }}
-
{{ 'ACTIONS.DELETE.SLOT.OPERATOR_TEXT' | translate }}
+
+
{{ slot?.name }}
+
+
{{ 'SLOT.PRODUCT_NAME' | translate }}:
+
{{ slot?.productName }}
+
+
+ {{ 'ACTIONS.DELETE.SLOT.OPERATOR_TEXT' | translate }} +
+
{{ 'ACTIONS.DELETE.MESSAGE_INFO' | translate }}