diff --git a/src/app/product-store/app-delete/app-delete.component.spec.ts b/src/app/product-store/app-delete/app-delete.component.spec.ts index 5da9225..acd04a7 100644 --- a/src/app/product-store/app-delete/app-delete.component.spec.ts +++ b/src/app/product-store/app-delete/app-delete.component.spec.ts @@ -2,12 +2,28 @@ import { NO_ERRORS_SCHEMA } from '@angular/core' import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing' import { HttpClientTestingModule } from '@angular/common/http/testing' import { TranslateTestingModule } from 'ngx-translate-testing' +import { of } from 'rxjs' +import { PortalMessageService } from '@onecx/portal-integration-angular' +import { MicrofrontendsAPIService } from 'src/app/shared/generated' +import { AppAbstract } from '../app-search/app-search.component' import { AppDeleteComponent } from './app-delete.component' describe('AppDeleteComponent', () => { let component: AppDeleteComponent let fixture: ComponentFixture + const appMfe: AppAbstract = { + id: 'id', + appId: 'appId', + appType: 'MFE', + appName: 'name', + remoteBaseUrl: 'url', + productName: 'productName' + } + const msgServiceSpy = jasmine.createSpyObj('PortalMessageService', ['success', 'error']) + const apiMfeServiceSpy = { + deleteMicrofrontend: jasmine.createSpy('deleteMicrofrontend').and.returnValue(of({})) + } beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ @@ -19,6 +35,10 @@ describe('AppDeleteComponent', () => { en: require('src/assets/i18n/en.json') }).withDefaultLanguage('en') ], + providers: [ + { provide: MicrofrontendsAPIService, useValue: apiMfeServiceSpy }, + { provide: PortalMessageService, useValue: msgServiceSpy } + ], schemas: [NO_ERRORS_SCHEMA] }).compileComponents() })) @@ -28,6 +48,11 @@ describe('AppDeleteComponent', () => { component = fixture.componentInstance fixture.detectChanges() }) + afterEach(() => { + msgServiceSpy.success.calls.reset() + msgServiceSpy.error.calls.reset() + apiMfeServiceSpy.deleteMicrofrontend.calls.reset() + }) it('should create', () => { expect(component).toBeTruthy() @@ -42,10 +67,12 @@ describe('AppDeleteComponent', () => { }) it('should onConfirmDeletion', () => { - spyOn(console, 'log') + spyOn(component.appDeleted, 'emit') + component.appAbstract = appMfe component.onConfirmDeletion() - expect(console.log).toHaveBeenCalledWith('onConfirmDeletion') + expect(msgServiceSpy.success).toHaveBeenCalledWith({ summaryKey: 'ACTIONS.DELETE.APP.OK' }) + expect(component.appDeleted.emit).toHaveBeenCalledWith(true) }) }) diff --git a/src/app/product-store/product-detail/product-apps/product-apps.component.html b/src/app/product-store/product-detail/product-apps/product-apps.component.html index 07ad998..67b21be 100644 --- a/src/app/product-store/product-detail/product-apps/product-apps.component.html +++ b/src/app/product-store/product-detail/product-apps/product-apps.component.html @@ -37,24 +37,34 @@ >
-
+
-
+ +
{{ limitText(app.appId, 25) }}
-
{{ limitText(app.appName, 30) }}
+
{{ app.appType }}
{{ limitText(app.productName, 25) }}
diff --git a/src/app/product-store/product-detail/product-apps/product-apps.component.spec.ts b/src/app/product-store/product-detail/product-apps/product-apps.component.spec.ts index c76761d..532286e 100644 --- a/src/app/product-store/product-detail/product-apps/product-apps.component.spec.ts +++ b/src/app/product-store/product-detail/product-apps/product-apps.component.spec.ts @@ -84,7 +84,7 @@ describe('ProductAppsComponent', () => { }) it('should search microfrontends on searchApps', () => { - const searchSpy = spyOn((component as any).appApi, 'searchMicrofrontends').and.returnValue( + const searchSpy = spyOn((component as any).mfeApi, 'searchMicrofrontends').and.returnValue( of({ totalElements: 0, number: 0, @@ -97,7 +97,7 @@ describe('ProductAppsComponent', () => { component.searchApps() expect(searchSpy).toHaveBeenCalledWith({ - mfeAndMsSearchCriteria: { productName: component.product?.name, pageSize: 1000 } + mfeAndMsSearchCriteria: { productName: component.product?.name } }) }) diff --git a/src/app/product-store/product-detail/product-apps/product-apps.component.ts b/src/app/product-store/product-detail/product-apps/product-apps.component.ts index 5dda8e0..9913ba2 100644 --- a/src/app/product-store/product-detail/product-apps/product-apps.component.ts +++ b/src/app/product-store/product-detail/product-apps/product-apps.component.ts @@ -73,7 +73,7 @@ export class ProductAppsComponent implements OnChanges { public searchApps(): void { this.searchInProgress = true this.mfes$ = this.mfeApi - .searchMicrofrontends({ mfeAndMsSearchCriteria: { productName: this.product } as MfeAndMsSearchCriteria }) + .searchMicrofrontends({ mfeAndMsSearchCriteria: { productName: this.product?.name } as MfeAndMsSearchCriteria }) .pipe( startWith({} as MicrofrontendPageResult), catchError((err) => { @@ -85,7 +85,7 @@ export class ProductAppsComponent implements OnChanges { ) this.mss$ = this.msApi - .searchMicroservice({ mfeAndMsSearchCriteria: { productName: this.product } as MfeAndMsSearchCriteria }) + .searchMicroservice({ mfeAndMsSearchCriteria: { productName: this.product?.name } as MfeAndMsSearchCriteria }) .pipe( startWith({} as MicroservicePageResult), catchError((err) => {