Allow platform multi-selection for VNF in modern UI
[vid.git] / vid-webpack-master / src / app / shared / components / genericForm / formControlsServices / vnfGenerator / vnf.control.generator.spec.ts
index d80ccde..9230ccf 100644 (file)
@@ -16,6 +16,7 @@ import {VnfControlGenerator} from "./vnf.control.generator";
 import {Observable} from "rxjs";
 import {SelectOption} from "../../../../models/selectOption";
 import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
+import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
 
 class MockAppStore<T> {
   getState(){
@@ -26,16 +27,9 @@ class MockAppStore<T> {
           "FLAG_NETWORK_TO_ASYNC_INSTANTIATION": false,
           "FLAG_SHOW_ASSIGNMENTS": true,
           "FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS": true,
-          "FLAG_UNASSIGN_SERVICE": true,
           "FLAG_SHOW_VERIFY_SERVICE": false,
-          "FLAG_COLLECTION_RESOURCE_SUPPORT": true,
-          "FLAG_DUPLICATE_VNF": true,
           "FLAG_SERVICE_MODEL_CACHE": true,
-          "CREATE_INSTANCE_TEST": false,
           "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false,
-          "FLAG_ASYNC_INSTANTIATION": true,
-          "FLAG_ASYNC_JOBS": true,
-          "EMPTY_DRAWING_BOARD_TEST": false,
           "FLAG_ADD_MSO_TESTAPI_FIELD": true
         },
         "type": "[FLAGS] Update"
@@ -58,11 +52,11 @@ class MockAppStore<T> {
               "inputs": {}
             },
             "vnfs": {
-              "VF_vMee 0": {
+              "VF_vGeraldine 0": {
                 "uuid": "d6557200-ecf2-4641-8094-5393ae3aae60",
                 "invariantUuid": "4160458e-f648-4b30-a176-43881ffffe9e",
-                "description": "VSP_vMee",
-                "name": "VF_vMee",
+                "description": "VSP_vGeraldine",
+                "name": "VF_vGeraldine",
                 "version": "2.0",
                 "customizationUuid": "91415b44-753d-494c-926a-456a9172bbb9",
                 "inputs": {},
@@ -233,74 +227,74 @@ class MockAppStore<T> {
                   "sctp-b-egress-dst_end_port": "65535.0"
                 },
                 "type": "VF",
-                "modelCustomizationName": "VF_vMee 0",
+                "modelCustomizationName": "VF_vGeraldine 0",
                 "vfModules": {
-                  "vf_vmee0..VfVmee..vmme_vlc..module-1": {
+                  "vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1": {
                     "uuid": "522159d5-d6e0-4c2a-aa44-5a542a12a830",
                     "invariantUuid": "98a7c88b-b577-476a-90e4-e25a5871e02b",
                     "customizationUuid": "55b1be94-671a-403e-a26c-667e9c47d091",
                     "description": null,
-                    "name": "VfVmee..vmme_vlc..module-1",
+                    "name": "VfVgeraldine..vflorence_vlc..module-1",
                     "version": "2",
-                    "modelCustomizationName": "VfVmee..vmme_vlc..module-1",
+                    "modelCustomizationName": "VfVgeraldine..vflorence_vlc..module-1",
                     "properties": {
                       "minCountInstances": 0,
                       "maxCountInstances": null,
                       "initialCount": 0,
-                      "vfModuleLabel": "vmme_vlc"
+                      "vfModuleLabel": "vflorence_vlc"
                     },
                     "inputs": {},
                     "volumeGroupAllowed": true
                   },
-                  "vf_vmee0..VfVmee..vmme_gpb..module-2": {
+                  "vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2": {
                     "uuid": "41708296-e443-4c71-953f-d9a010f059e1",
                     "invariantUuid": "1cca90b8-3490-495e-87da-3f3e4c57d5b9",
                     "customizationUuid": "6add59e0-7fe1-4bc4-af48-f8812422ae7c",
                     "description": null,
-                    "name": "VfVmee..vmme_gpb..module-2",
+                    "name": "VfVgeraldine..vflorence_gpb..module-2",
                     "version": "2",
-                    "modelCustomizationName": "VfVmee..vmme_gpb..module-2",
+                    "modelCustomizationName": "VfVgeraldine..vflorence_gpb..module-2",
                     "properties": {
                       "minCountInstances": 0,
                       "maxCountInstances": null,
                       "initialCount": 0,
-                      "vfModuleLabel": "vmme_gpb"
+                      "vfModuleLabel": "vflorence_gpb"
                     },
                     "inputs": {},
                     "volumeGroupAllowed": false
                   },
-                  "vf_vmee0..VfVmee..base_vmme..module-0": {
+                  "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0": {
                     "uuid": "a27f5cfc-7f12-4f99-af08-0af9c3885c87",
                     "invariantUuid": "a6f9e51a-2b35-416a-ae15-15e58d61f36d",
                     "customizationUuid": "f8c040f1-7e51-4a11-aca8-acf256cfd861",
                     "description": null,
-                    "name": "VfVmee..base_vmme..module-0",
+                    "name": "VfVgeraldine..base_vflorence..module-0",
                     "version": "2",
-                    "modelCustomizationName": "VfVmee..base_vmme..module-0",
+                    "modelCustomizationName": "VfVgeraldine..base_vflorence..module-0",
                     "properties": {
                       "minCountInstances": 1,
                       "maxCountInstances": 1,
                       "initialCount": 1,
-                      "vfModuleLabel": "base_vmme"
+                      "vfModuleLabel": "base_vflorence"
                     },
                     "inputs": {},
                     "volumeGroupAllowed": true
                   }
                 },
                 "volumeGroups": {
-                  "vf_vmee0..VfVmee..base_vmme..module-0": {
+                  "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0": {
                     "uuid": "a27f5cfc-7f12-4f99-af08-0af9c3885c87",
                     "invariantUuid": "a6f9e51a-2b35-416a-ae15-15e58d61f36d",
                     "customizationUuid": "f8c040f1-7e51-4a11-aca8-acf256cfd861",
                     "description": null,
-                    "name": "VfVmee..base_vmme..module-0",
+                    "name": "VfVgeraldine..base_vflorence..module-0",
                     "version": "2",
-                    "modelCustomizationName": "VfVmee..base_vmme..module-0",
+                    "modelCustomizationName": "VfVgeraldine..base_vflorence..module-0",
                     "properties": {
                       "minCountInstances": 1,
                       "maxCountInstances": 1,
                       "initialCount": 1,
-                      "vfModuleLabel": "base_vmme"
+                      "vfModuleLabel": "base_vflorence"
                     },
                     "inputs": {}
                   }
@@ -328,7 +322,7 @@ class MockAppStore<T> {
                 "modelCustomizationName": "ExtVL 0"
               }
             },
-            "collectionResource": {},
+            "collectionResources": {},
             "configurations": {
               "Port Mirroring Configuration By Policy 0": {
                 "uuid": "b4398538-e89d-4f13-b33d-ca323434ba50",
@@ -349,72 +343,72 @@ class MockAppStore<T> {
             },
             "serviceProxies": {},
             "vfModules": {
-              "vf_vmee0..VfVmee..vmme_vlc..module-1": {
+              "vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1": {
                 "uuid": "522159d5-d6e0-4c2a-aa44-5a542a12a830",
                 "invariantUuid": "98a7c88b-b577-476a-90e4-e25a5871e02b",
                 "customizationUuid": "55b1be94-671a-403e-a26c-667e9c47d091",
                 "description": null,
-                "name": "VfVmee..vmme_vlc..module-1",
+                "name": "VfVgeraldine..vflorence_vlc..module-1",
                 "version": "2",
-                "modelCustomizationName": "VfVmee..vmme_vlc..module-1",
+                "modelCustomizationName": "VfVgeraldine..vflorence_vlc..module-1",
                 "properties": {
                   "minCountInstances": 0,
                   "maxCountInstances": null,
                   "initialCount": 0,
-                  "vfModuleLabel": "vmme_vlc"
+                  "vfModuleLabel": "vflorence_vlc"
                 },
                 "inputs": {},
                 "volumeGroupAllowed": true
               },
-              "vf_vmee0..VfVmee..vmme_gpb..module-2": {
+              "vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2": {
                 "uuid": "41708296-e443-4c71-953f-d9a010f059e1",
                 "invariantUuid": "1cca90b8-3490-495e-87da-3f3e4c57d5b9",
                 "customizationUuid": "6add59e0-7fe1-4bc4-af48-f8812422ae7c",
                 "description": null,
-                "name": "VfVmee..vmme_gpb..module-2",
+                "name": "VfVgeraldine..vflorence_gpb..module-2",
                 "version": "2",
-                "modelCustomizationName": "VfVmee..vmme_gpb..module-2",
+                "modelCustomizationName": "VfVgeraldine..vflorence_gpb..module-2",
                 "properties": {
                   "minCountInstances": 0,
                   "maxCountInstances": null,
                   "initialCount": 0,
-                  "vfModuleLabel": "vmme_gpb"
+                  "vfModuleLabel": "vflorence_gpb"
                 },
                 "inputs": {},
                 "volumeGroupAllowed": false
               },
-              "vf_vmee0..VfVmee..base_vmme..module-0": {
+              "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0": {
                 "uuid": "a27f5cfc-7f12-4f99-af08-0af9c3885c87",
                 "invariantUuid": "a6f9e51a-2b35-416a-ae15-15e58d61f36d",
                 "customizationUuid": "f8c040f1-7e51-4a11-aca8-acf256cfd861",
                 "description": null,
-                "name": "VfVmee..base_vmme..module-0",
+                "name": "VfVgeraldine..base_vflorence..module-0",
                 "version": "2",
-                "modelCustomizationName": "VfVmee..base_vmme..module-0",
+                "modelCustomizationName": "VfVgeraldine..base_vflorence..module-0",
                 "properties": {
                   "minCountInstances": 1,
                   "maxCountInstances": 1,
                   "initialCount": 1,
-                  "vfModuleLabel": "base_vmme"
+                  "vfModuleLabel": "base_vflorence"
                 },
                 "inputs": {},
                 "volumeGroupAllowed": true
               }
             },
             "volumeGroups": {
-              "vf_vmee0..VfVmee..base_vmme..module-0": {
+              "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0": {
                 "uuid": "a27f5cfc-7f12-4f99-af08-0af9c3885c87",
                 "invariantUuid": "a6f9e51a-2b35-416a-ae15-15e58d61f36d",
                 "customizationUuid": "f8c040f1-7e51-4a11-aca8-acf256cfd861",
                 "description": null,
-                "name": "VfVmee..base_vmme..module-0",
+                "name": "VfVgeraldine..base_vflorence..module-0",
                 "version": "2",
-                "modelCustomizationName": "VfVmee..base_vmme..module-0",
+                "modelCustomizationName": "VfVgeraldine..base_vflorence..module-0",
                 "properties": {
                   "minCountInstances": 1,
                   "maxCountInstances": 1,
                   "initialCount": 1,
-                  "vfModuleLabel": "base_vmme"
+                  "vfModuleLabel": "base_vflorence"
                 },
                 "inputs": {}
               }
@@ -425,21 +419,21 @@ class MockAppStore<T> {
         "serviceInstance": {
           "6e59c5de-f052-46fa-aa7e-2fca9d674c44": {
             "vnfs": {
-              "VF_vMee 0": {
+              "VF_vGeraldine 0": {
                 "rollbackOnFailure": "true",
                 "vfModules": {
-                  "vf_vmee0..VfVmee..base_vmme..module-0": {
-                    "vf_vmee0..VfVmee..base_vmme..module-0vmvzo": {
+                  "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0": {
+                    "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0vmvzo": {
                       "isMissingData": false,
                       "sdncPreReload": null,
                       "modelInfo": {
                         "modelType": "VFmodule",
                         "modelInvariantId": "a6f9e51a-2b35-416a-ae15-15e58d61f36d",
                         "modelVersionId": "a27f5cfc-7f12-4f99-af08-0af9c3885c87",
-                        "modelName": "VfVmee..base_vmme..module-0",
+                        "modelName": "VfVgeraldine..base_vflorence..module-0",
                         "modelVersion": "2",
                         "modelCustomizationId": "f8c040f1-7e51-4a11-aca8-acf256cfd861",
-                        "modelCustomizationName": "VfVmee..base_vmme..module-0"
+                        "modelCustomizationName": "VfVgeraldine..base_vflorence..module-0"
                       },
                       "instanceParams": [
                         {}
@@ -449,8 +443,8 @@ class MockAppStore<T> {
                   }
                 },
                 "isMissingData": true,
-                "originalName": "VF_vMee 0",
-                "vnfStoreKey": "VF_vMee 0",
+                "originalName": "VF_vGeraldine 0",
+                "vnfStoreKey": "VF_vGeraldine 0",
                 "trackById": "p3wk448m5do",
                 "uuid": "d6557200-ecf2-4641-8094-5393ae3aae60",
                 "productFamilyId": "36b4733a-53f4-4cc8-8ff0-9172e5fc4b8e",
@@ -462,9 +456,9 @@ class MockAppStore<T> {
                   "modelType": "VF",
                   "modelInvariantId": "4160458e-f648-4b30-a176-43881ffffe9e",
                   "modelVersionId": "6e59c5de-f052-46fa-aa7e-2fca9d674c44",
-                  "modelName": "VF_vMee",
+                  "modelName": "VF_vGeraldine",
                   "modelVersion": "2.0",
-                  "modelCustomizationName": "VF_vMee 0"
+                  "modelCustomizationName": "VF_vGeraldine 0"
                 }
               }
             },
@@ -508,8 +502,8 @@ class MockAppStore<T> {
         "lcpRegionsAndTenants": {
           "lcpRegionList": [
             {
-              "id": "JANET25",
-              "name": "JANET25",
+              "id": "AAIAIC25",
+              "name": "AAIAIC25",
               "isPermitted": true
             },
             {
@@ -519,7 +513,7 @@ class MockAppStore<T> {
             }
           ],
           "lcpRegionsTenantsMap": {
-            "JANET25": [
+            "AAIAIC25": [
               {
                 "id": "092eb9e8e4b7412e8787dd091bc58e86",
                 "name": "USP-SIP-IC-24335-T-01",
@@ -553,7 +547,7 @@ class MockAppStore<T> {
         "productFamilies": [
           {
             "id": "ebc3bc3d-62fd-4a3f-a037-f619df4ff034",
-            "name": "SCOTTIE",
+            "name": "ERICA",
             "isPermitted": true
           },
           {
@@ -578,7 +572,7 @@ class MockAppStore<T> {
           },
           {
             "id": "323d69d9-2efe-4r45-ay0a-89ea7ard4e6f",
-            "name": "vSCP",
+            "name": "vEsmeralda",
             "isPermitted": true
           },
           {
@@ -622,7 +616,7 @@ class MockAppStore<T> {
             "isPermitted": true
           },
           {
-            "id": "Cisneros",
+            "id": "vMuriel",
             "name": "vMuriel",
             "isPermitted": true
           },
@@ -648,7 +642,7 @@ class MockAppStore<T> {
           },
           {
             "id": "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4",
-            "name": "Josefina",
+            "name": "JOSEFINA",
             "isPermitted": true
           },
           {
@@ -696,7 +690,7 @@ class MockAppStore<T> {
             },
             {
               "id": "6",
-              "name": "vSEGW",
+              "name": "vPorfirio",
               "isPermitted": false
             },
             {
@@ -711,7 +705,7 @@ class MockAppStore<T> {
             },
             {
               "id": "9",
-              "name": "vMME",
+              "name": "vFLORENCE",
               "isPermitted": false
             },
             {
@@ -721,7 +715,7 @@ class MockAppStore<T> {
             },
             {
               "id": "11",
-              "name": "vSCP",
+              "name": "vEsmeralda",
               "isPermitted": false
             },
             {
@@ -731,7 +725,7 @@ class MockAppStore<T> {
             },
             {
               "id": "13",
-              "name": "vMMSC",
+              "name": "vWINIFRED",
               "isPermitted": false
             },
             {
@@ -946,10 +940,39 @@ describe('VNF Control Generator', () => {
   })().then(done).catch(done.fail));
 
 
+
+  test('should call platform dropdown control', ()=>{
+    spyOn(service, 'getPlatformDropdownControl');
+
+    service.getPlatformControl(null, [], false);
+
+    expect(service.getPlatformDropdownControl).toBeCalledWith(null, []);
+  });
+
+  test('should call platform multi select control', ()=>{
+    spyOn(service, 'getPlatformMultiselectControl');
+
+    service.getPlatformControl(null, [], true);
+
+    expect(service.getPlatformMultiselectControl).toBeCalledWith(null, []);
+  });
+
+  test('should generate platform multi select control', ()=>{
+    const control = service.getPlatformMultiselectControl(null, []);
+    expect(control.type).toEqual(FormControlType.MULTI_SELECT);
+    expect(control.controlName).toEqual('platformName');
+    expect(control.displayName).toEqual('Platform');
+    expect(control.dataTestId).toEqual('multi-selectPlatform');
+    expect(control.selectedFieldName).toEqual('name');
+    expect(control.value).toEqual('');
+    expect(control.onChange).toBeDefined();
+    expect(control.convertOriginalDataToArray).toBeDefined();
+  });
+
   test('getMacroFormControls check for mandatory controls', () => {
     const serviceId : string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
-    const vnfName : string = "VF_vMee 0";
-    const vnfStoreKey : string = "VF_vMee 0";
+    const vnfName : string = "VF_vGeraldine 0";
+    const vnfStoreKey : string = "VF_vGeraldine 0";
     const controls :FormControlModel[] = service.getMacroFormControls(serviceId, vnfStoreKey, vnfName, []);
 
     const mandatoryControls : string[] = [
@@ -984,14 +1007,14 @@ describe('VNF Control Generator', () => {
 
   function getALaCarteFormControls(vnfStoreKey: string): FormControlModel[] {
     const serviceId: string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
-    const vnfName: string = "VF_vMee 0";
+    const vnfName: string = "VF_vGeraldine 0";
     const controls: FormControlModel[] = service.getAlaCarteFormControls(serviceId, vnfStoreKey, vnfName, []);
     return controls;
   }
 
   test('getMacroFormControls should return the correct order of controls', () => {
     const serviceId : string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
-    const vnfName : string = "VF_vMee 0";
+    const vnfName : string = "VF_vGeraldine 0";
     const vnfStoreKey : string = null;
     const controls :FormControlModel[] = service.getMacroFormControls(serviceId, vnfStoreKey, vnfName, []);
 
@@ -1030,12 +1053,13 @@ describe('VNF Control Generator', () => {
 
 
   test('getAlacartFormControls check for mandatory controls', () => {
-    const controls = getALaCarteFormControls("VF_vMee 0");
+    const controls = getALaCarteFormControls("VF_vGeraldine 0");
     const mandatoryControls : string[] = [
       FormControlNames.INSTANCE_NAME,
       FormControlNames.LCPCLOUD_REGION_ID,
       'tenantId',
       'platformName',
+      'lineOfBusiness',
       'rollbackOnFailure'
     ];
     for(let i = 0 ; i < mandatoryControls.length ; i++){
@@ -1045,7 +1069,7 @@ describe('VNF Control Generator', () => {
   });
 
   test('getAlacartFormControls instance name control validator shall have the expected regex', () => {
-    const controls:FormControlModel[] = getALaCarteFormControls("VF_vMee 0");
+    const controls:FormControlModel[] = getALaCarteFormControls("VF_vGeraldine 0");
 
     const instanceNameControl: FormControlModel = <FormControlModel>controls.find(item => item.controlName === FormControlNames.INSTANCE_NAME);
     const instanceNameValidator: ValidatorModel = instanceNameControl.validations.find(val => val.validatorName === ValidatorOptions.pattern);