summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/composition
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/composition')
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.spec.ts44
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts13
2 files changed, 45 insertions, 12 deletions
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.spec.ts b/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.spec.ts
index d5c0b6093b..2f27f468b6 100644
--- a/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.spec.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.spec.ts
@@ -169,28 +169,49 @@ describe('composition-panel component', () => {
expect(fixture).toMatchSnapshot();
});
- it('When Topology Template is Service and no instance is selected Expect (info, deployment, inputs, info and api)', () => {
-
+ it('When Topology Template is Service and no instance is selected Expect tabs info, deployment, inputs, info, api, substitution filter', () => {
const selectedComponent: Service = new Service(null, null);
selectedComponent.isResource = jest.fn(() => false);
- selectedComponent.isService = jest.fn(() => true );
+ selectedComponent.isService = jest.fn(() => true);
+ selectedComponent.isSubstituteCandidate = jest.fn(() => true);
+ fixture.componentInstance.store.select = jest.fn(() => Observable.of(selectedComponent));
+
+ fixture.componentInstance.topologyTemplate = selectedComponent;
+
+ // Call ngOnInit
+ fixture.componentInstance.ngOnInit();
+
+ // Expect that
+ expect(fixture.componentInstance.tabs.length).toBe(6);
+ expect(fixture.componentInstance.tabs[0]).toEqual(tabs.infoTab);
+ expect(fixture.componentInstance.tabs[1]).toEqual(tabs.deploymentArtifacts);
+ expect(fixture.componentInstance.tabs[2]).toEqual(tabs.inputs);
+ expect(fixture.componentInstance.tabs[3]).toEqual(tabs.infoArtifacts);
+ expect(fixture.componentInstance.tabs[4]).toEqual(tabs.apiArtifacts);
+ expect(fixture.componentInstance.tabs[5]).toEqual(tabs.substitutionFilter);
+ });
+
+ it('When Topology Template is Service without base type, and no instance is selected. Expect tabs info, deployment, inputs, info and api', () => {
+
+ const selectedComponent: Service = new Service(null, null);
+ selectedComponent.isResource = jest.fn(() => false);
+ selectedComponent.isService = jest.fn(() => true);
+ selectedComponent.isSubstituteCandidate = jest.fn(() => false);
fixture.componentInstance.store.select = jest.fn(() => Observable.of(selectedComponent));
- // const pnfMock = Mock.of<Service>({ isResource : () => false });
fixture.componentInstance.topologyTemplate = selectedComponent;
// Call ngOnInit
fixture.componentInstance.ngOnInit();
// Expect that
- expect (fixture.componentInstance.tabs.length).toBe(6);
- expect (fixture.componentInstance.tabs[0]).toEqual(tabs.infoTab);
- expect (fixture.componentInstance.tabs[1]).toEqual(tabs.deploymentArtifacts);
- expect (fixture.componentInstance.tabs[2]).toEqual(tabs.inputs);
- expect (fixture.componentInstance.tabs[3]).toEqual(tabs.infoArtifacts);
- expect (fixture.componentInstance.tabs[4]).toEqual(tabs.apiArtifacts);
- expect (fixture.componentInstance.tabs[5]).toEqual(tabs.substitutionFilter);
+ expect(fixture.componentInstance.tabs.length).toBe(5);
+ expect(fixture.componentInstance.tabs[0]).toEqual(tabs.infoTab);
+ expect(fixture.componentInstance.tabs[1]).toEqual(tabs.deploymentArtifacts);
+ expect(fixture.componentInstance.tabs[2]).toEqual(tabs.inputs);
+ expect(fixture.componentInstance.tabs[3]).toEqual(tabs.infoArtifacts);
+ expect(fixture.componentInstance.tabs[4]).toEqual(tabs.apiArtifacts);
});
@@ -223,6 +244,7 @@ describe('composition-panel component', () => {
const selectedComponent: Service = new Service(null, null);
selectedComponent.isResource = jest.fn(() => false);
selectedComponent.isService = jest.fn(() => true );
+ selectedComponent.isSubstituteCandidate = jest.fn(() => true );
fixture.componentInstance.store.select = jest.fn(() => Observable.of(selectedComponent));
fixture.componentInstance.selectedComponentIsServiceProxyInstance = jest.fn(() => true);
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts
index 6ed73b3384..3422cc142d 100644
--- a/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts
@@ -264,7 +264,7 @@ export class CompositionPanelComponent {
this.tabs.push(tabs.apiArtifacts);
}
- if((component.isService() || this.isVF()) && !this.isComponentInstanceSelected()){
+ if (this.showSubstitutionFilterTab(component)) {
this.tabs.push(tabs.substitutionFilter);
}
@@ -279,6 +279,17 @@ export class CompositionPanelComponent {
}
+ private showSubstitutionFilterTab(component): boolean {
+ if ((component.isService() || this.isVF()) && !this.isComponentInstanceSelected()) {
+ if (component.isService()) {
+ return (<Service>component).isSubstituteCandidate();
+ }
+ return true;
+ }
+
+ return false;
+ }
+
private toggleSidebarDisplay = () => {
// this.withSidebar = !this.withSidebar;
this.store.dispatch(new OnSidebarOpenOrCloseAction());