Add another vfm-upgrade test

Issue-ID: VID-603

Change-Id: I4690906d3bc660984a0c2269d7151f6151b89940
Signed-off-by: Ittay Stern <ittay.stern@att.com>
diff --git a/vid-webpack-master/cypress/integration/iFrames/ala-carte.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/ala-carte.e2e.ts
index 790fcfc..5c6d28e 100644
--- a/vid-webpack-master/cypress/integration/iFrames/ala-carte.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/ala-carte.e2e.ts
@@ -19,7 +19,8 @@
         cy.setReduxState();
         cy.preventErrorsOnLoading();
         cy.initAAIMock();
-        cy.initVidMock({serviceUuid:SERVICE_ID, invariantId: SERVICE_INVARIANT_ID});
+        cy.initVidMock();
+        cy.mockLatestVersionForService(SERVICE_ID, SERVICE_INVARIANT_ID);
         cy.initAlaCarteService();
         cy.initZones();
         cy.login();
diff --git a/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts
index 0fef7ae..79f6a8d 100644
--- a/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts
@@ -143,7 +143,8 @@
           0,
           "aai_getPortMirroringSourcePorts - empty response")
       });
-      cy.initVidMock({serviceUuid: commonUuid, invariantId: serviceInvariantId});
+      cy.initVidMock();
+      cy.mockLatestVersionForService(commonUuid, serviceInvariantId);
       cy.setReduxState();
       cy.permissionVidMock();
       cy.login();
diff --git a/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts
index bea31fc..0d94e60 100644
--- a/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts
@@ -79,7 +79,8 @@
 
       mockAsyncBulkResponse();
       cy.initGetAAISubDetails();
-      cy.initVidMock({serviceUuid: serviceUuid, invariantId: serviceInvariantId});
+      cy.initVidMock();
+      cy.mockLatestVersionForService(serviceUuid, serviceInvariantId);
       cy.setReduxState();
       cy.permissionVidMock();
       cy.login();
@@ -91,8 +92,8 @@
 
     it(`should display the more actions button if user is permitted`, function () {
       let SERVICE_INSTANCE_ID="3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
-      let SERVICE_TYPE="VIRTUAL%20USP";
-      cy.visit(`/serviceModels.htm#/instantiate?subscriberId=${SUBSCRIBER_ID}&subscriberName=USP%20VOICE&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&aaiModelVersionId=${serviceUuid}&isPermitted=true`);
+      let SERVICE_TYPE="TYLER%20SILVIA";
+      cy.visit(`/serviceModels.htm#/instantiate?subscriberId=${SUBSCRIBER_ID}&subscriberName=SILVIA%20ROBBINS&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&aaiModelVersionId=${serviceUuid}&isPermitted=true`);
 
       cy.get("[data-tests-id='service-instanceId-th-id']").should('contain', SERVICE_INSTANCE_ID);
       cy.getElementByDataTestsId("show-new-screen").should('be.visible').should('have.text', 'More actions').click();
@@ -126,6 +127,67 @@
 
   });
 
+  describe('More UI tests', () => {
+
+    beforeEach(() => {
+      cy.window().then((win) => {win.sessionStorage.clear();});
+      cy.setTestApiParamToVNF();
+      cy.initVidMock();
+      cy.login();
+    });
+
+    afterEach(() => {
+      cy.screenshot();
+    });
+
+    it(`Upgrade a VFModule: another case e2e`, function () {
+
+      const serviceType = 'Emanuel';
+      const subscriberId = 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb';
+      const serviceModelId = '06c415d8-afc2-4bcb-a131-e4db4b8e96ce';
+      const serviceInstanceId = '6196ab1f-2349-4b32-9b6c-cffeb0ccc79c';
+      const serviceInvariantUuid = "b3a1a119-dede-4ed0-b077-2a617fa519a3";
+
+      cy.initDrawingBoardUserPermission();
+
+      cy.route(`**/rest/models/services/${serviceModelId}`,
+        'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_model.json')
+      .as('serviceModel2');
+
+      cy.route(`**/aai_get_service_instance_topology/${subscriberId}/${serviceType}/${serviceInstanceId}`,
+        'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json')
+      .as('serviceInstance2');
+
+      cy.route(`**/aai_get_newest_model_version_by_invariant/${serviceInvariantUuid}`,
+        {
+          "modelVersionId": "d9a5b318-187e-476d-97f7-a15687a927a9",
+          "modelName": "xbi test module replace",
+          "modelVersion": "2.0",
+          "distributionStatus": "DISTRIBUTION_COMPLETE_OK",
+          "resourceVersion": "1571769586156",
+          "modelDescription": "test module replacement feature",
+          "orchestrationType": null
+        }
+      ).as("newestModelVersion2");
+
+      cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&subscriberId=${subscriberId}&serviceType=${serviceType}&serviceInstanceId=${serviceInstanceId}`);
+
+      upgradeTheVFM('node-04b21d26-9780-4956-8329-b22b049329f4-xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0');
+
+      mockAsyncBulkResponse();
+      cy.getDrawingBoardDeployBtn().click();
+
+      cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
+        cy.readFile('../vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json').then((expectedResult) => {
+          cy.deepCompare(xhr.request.body, expectedResult);
+        });
+      });
+
+    });
+
+  });
+
+
   function mockAsyncBulkResponse() {
     cy.server().route({
       url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
@@ -149,8 +211,8 @@
     }).as("expectLatestServiceModelUpgradeVersion")
   }
 
-  function upgradeTheVFM(): Chainable<any> {
-    return cy.getElementByDataTestsId('node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14-menu-btn').click()
+  function upgradeTheVFM(treeNodeId = 'node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14'): Chainable<any> {
+    return cy.getElementByDataTestsId(`${treeNodeId}-menu-btn`).click()
     .drawingBoardTreeClickOnContextMenuOptionByName("Upgrade");
   }
 
diff --git a/vid-webpack-master/cypress/integration/iFrames/viewOnlyDrawingBoard.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/viewOnlyDrawingBoard.e2e.ts
index e5be3fb..26d206d 100644
--- a/vid-webpack-master/cypress/integration/iFrames/viewOnlyDrawingBoard.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/viewOnlyDrawingBoard.e2e.ts
@@ -46,7 +46,8 @@
       win.sessionStorage.clear();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
-      cy.initVidMock({serviceUuid:SERVICE_MODEL_ID, invariantId: SERVICE_INVARIANT_ID});
+      cy.initVidMock();
+      cy.mockLatestVersionForService(SERVICE_MODEL_ID, SERVICE_INVARIANT_ID);
       cy.initZones();
       cy.permissionVidMock();
       cy.login();
diff --git a/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json
new file mode 100644
index 0000000..a697d0b
--- /dev/null
+++ b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json
@@ -0,0 +1,101 @@
+{
+  "action": "None",
+  "instanceName": "PST-VfMod-Replace-5",
+  "instanceId": "6196ab1f-2349-4b32-9b6c-cffeb0ccc79c",
+  "orchStatus": "Active",
+  "productFamilyId": null,
+  "lcpCloudRegionId": null,
+  "tenantId": null,
+  "cloudOwner": null,
+  "modelInfo": {
+    "modelInvariantId": "b3a1a119-dede-4ed0-b077-2a617fa519a3",
+    "modelVersionId": "06c415d8-afc2-4bcb-a131-e4db4b8e96ce",
+    "modelName": "xbi test module replace",
+    "modelType": "service",
+    "modelVersion": "1.0"
+  },
+  "globalSubscriberId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+  "subscriptionServiceType": "Emanuel",
+  "owningEntityId": null,
+  "owningEntityName": null,
+  "tenantName": null,
+  "aicZoneId": null,
+  "aicZoneName": null,
+  "projectName": null,
+  "rollbackOnFailure": null,
+  "isALaCarte": true,
+  "vnfs": {
+    "d520268f-7489-4662-be59-f81495b3a069": {
+      "action": "None",
+      "instanceName": "PST-VfMod-Replace-5-Vnf",
+      "instanceId": "d520268f-7489-4662-be59-f81495b3a069",
+      "orchStatus": "Active",
+      "productFamilyId": null,
+      "lcpCloudRegionId": "olson5a",
+      "tenantId": "7ff7b1a4fe954f71ab79d3160ec3eb08",
+      "cloudOwner": "irma-aic",
+      "modelInfo": {
+        "modelCustomizationName": "xbi test module replace 0",
+        "modelCustomizationId": "84ea2603-b892-4b63-b7ad-e53b902eacdb",
+        "modelInvariantId": "5626a5ec-7dce-4cc1-b025-bdb7abb2f058",
+        "modelVersionId": "fb0fea03-db45-4617-a2a8-0910309e5c86",
+        "modelName": "xbi test module replace",
+        "modelType": "vnf",
+        "modelVersion": "1.0"
+      },
+      "instanceType": "xbi test module replace/xbi test module replace 0",
+      "provStatus": "PREPROV",
+      "inMaint": false,
+      "uuid": "fb0fea03-db45-4617-a2a8-0910309e5c86",
+      "originalName": "xbi test module replace 0",
+      "legacyRegion": null,
+      "lineOfBusiness": null,
+      "platformName": null,
+      "trackById": "d520268f-7489-4662-be59-f81495b3a069",
+      "vfModules": {
+        "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0": {
+          "b0732bed-3ddf-43cc-b193-7f18db84e476": {
+            "action": "None",
+            "instanceName": "PST-VfMod-Replace-5-Vfmod",
+            "instanceId": "b0732bed-3ddf-43cc-b193-7f18db84e476",
+            "orchStatus": "Active",
+            "productFamilyId": null,
+            "lcpCloudRegionId": null,
+            "tenantId": null,
+            "cloudOwner": null,
+            "modelInfo": {
+              "modelCustomizationName": "XbiTestModuleReplace..base_ocg..module-0",
+              "modelCustomizationId": "3f1f0fcb-8a88-4612-a794-3912613ed9e8",
+              "modelInvariantId": "d887658e-2a89-4baf-83e2-b189601a1a7c",
+              "modelVersionId": "04b21d26-9780-4956-8329-b22b049329f4",
+              "modelType": "vfModule"
+            },
+            "instanceType": null,
+            "provStatus": null,
+            "inMaint": false,
+            "uuid": "04b21d26-9780-4956-8329-b22b049329f4",
+            "originalName": "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0",
+            "legacyRegion": null,
+            "lineOfBusiness": null,
+            "platformName": null,
+            "trackById": "b0732bed-3ddf-43cc-b193-7f18db84e476",
+            "isBase": true,
+            "volumeGroupName": null
+          }
+        }
+      },
+      "networks": {}
+    }
+  },
+  "networks": {},
+  "vrfs": {},
+  "vnfGroups": {},
+  "collectionResources": {},
+  "validationCounter": 0,
+  "existingVNFCounterMap": {
+    "84ea2603-b892-4b63-b7ad-e53b902eacdb": 1
+  },
+  "existingNetworksCounterMap": {},
+  "existingVnfGroupCounterMap": {},
+  "existingVRFCounterMap": {}
+}
\ No newline at end of file
diff --git a/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_model.json b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_model.json
new file mode 100644
index 0000000..dc79b14
--- /dev/null
+++ b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_model.json
@@ -0,0 +1,165 @@
+{
+  "service": {
+    "uuid": "06c415d8-afc2-4bcb-a131-e4db4b8e96ce",
+    "invariantUuid": "b3a1a119-dede-4ed0-b077-2a617fa519a3",
+    "name": "xbi test module replace",
+    "version": "1.0",
+    "toscaModelURL": null,
+    "category": "Emanuel",
+    "serviceType": "",
+    "serviceRole": "",
+    "description": "test module replacement feature",
+    "serviceEcompNaming": "true",
+    "instantiationType": "A-La-Carte",
+    "inputs": {},
+    "vidNotions": {
+      "instantiationUI": "legacy",
+      "modelCategory": "other",
+      "viewEditUI": "legacy",
+      "instantiationType": "ALaCarte"
+    }
+  },
+  "vnfs": {
+    "xbi test module replace 0": {
+      "uuid": "fb0fea03-db45-4617-a2a8-0910309e5c86",
+      "invariantUuid": "5626a5ec-7dce-4cc1-b025-bdb7abb2f058",
+      "description": "VSP for testing module replacement feature",
+      "name": "xbi test module replace",
+      "version": "1.0",
+      "customizationUuid": "84ea2603-b892-4b63-b7ad-e53b902eacdb",
+      "inputs": {},
+      "commands": {},
+      "properties": {
+        "nf_function": "OFFLINE-CHARGING-GATEWAY",
+        "vnf_name": "zolson5avocg01",
+        "eth1_ip_range": "10.0.0.10",
+        "ocgmgr_image_name": "vOCG_MGR_SNAP_20180130"
+      },
+      "type": "VF",
+      "modelCustomizationName": "xbi test module replace 0",
+      "vfModules": {
+        "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0": {
+          "uuid": "04b21d26-9780-4956-8329-b22b049329f4",
+          "invariantUuid": "d887658e-2a89-4baf-83e2-b189601a1a7c",
+          "customizationUuid": "3f1f0fcb-8a88-4612-a794-3912613ed9e8",
+          "description": null,
+          "name": "XbiTestModuleReplace..base_ocg..module-0",
+          "version": "1",
+          "modelCustomizationName": "XbiTestModuleReplace..base_ocg..module-0",
+          "properties": {
+            "minCountInstances": 1,
+            "maxCountInstances": 1,
+            "initialCount": 1,
+            "vfModuleLabel": "base_ocg",
+            "baseModule": true
+          },
+          "inputs": {},
+          "volumeGroupAllowed": false
+        },
+        "xbitestmodulereplace0..XbiTestModuleReplace..ocgmgr..module-1": {
+          "uuid": "17dc819b-6cae-40e6-aea0-3afb856646f6",
+          "invariantUuid": "9fe2a0bb-e1e2-4dfd-9566-a7dfc3adc07d",
+          "customizationUuid": "9d428546-00c6-468b-94de-2d4e136459cd",
+          "description": null,
+          "name": "XbiTestModuleReplace..ocgmgr..module-1",
+          "version": "1",
+          "modelCustomizationName": "XbiTestModuleReplace..ocgmgr..module-1",
+          "properties": {
+            "minCountInstances": 0,
+            "maxCountInstances": null,
+            "initialCount": 0,
+            "vfModuleLabel": "ocgmgr",
+            "baseModule": false
+          },
+          "inputs": {},
+          "volumeGroupAllowed": true
+        }
+      },
+      "volumeGroups": {
+        "xbitestmodulereplace0..XbiTestModuleReplace..ocgmgr..module-1": {
+          "uuid": "17dc819b-6cae-40e6-aea0-3afb856646f6",
+          "invariantUuid": "9fe2a0bb-e1e2-4dfd-9566-a7dfc3adc07d",
+          "customizationUuid": "9d428546-00c6-468b-94de-2d4e136459cd",
+          "description": null,
+          "name": "XbiTestModuleReplace..ocgmgr..module-1",
+          "version": "1",
+          "modelCustomizationName": "XbiTestModuleReplace..ocgmgr..module-1",
+          "properties": {
+            "minCountInstances": 0,
+            "maxCountInstances": null,
+            "initialCount": 0,
+            "vfModuleLabel": "ocgmgr",
+            "baseModule": false
+          },
+          "inputs": {}
+        }
+      },
+      "vfcInstanceGroups": {}
+    }
+  },
+  "networks": {},
+  "collectionResources": {},
+  "configurations": {},
+  "fabricConfigurations": {},
+  "serviceProxies": {},
+  "vfModules": {
+    "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0": {
+      "uuid": "04b21d26-9780-4956-8329-b22b049329f4",
+      "invariantUuid": "d887658e-2a89-4baf-83e2-b189601a1a7c",
+      "customizationUuid": "3f1f0fcb-8a88-4612-a794-3912613ed9e8",
+      "description": null,
+      "name": "XbiTestModuleReplace..base_ocg..module-0",
+      "version": "1",
+      "modelCustomizationName": "XbiTestModuleReplace..base_ocg..module-0",
+      "properties": {
+        "minCountInstances": 1,
+        "maxCountInstances": 1,
+        "initialCount": 1,
+        "vfModuleLabel": "base_ocg",
+        "baseModule": true
+      },
+      "inputs": {},
+      "volumeGroupAllowed": false
+    },
+    "xbitestmodulereplace0..XbiTestModuleReplace..ocgmgr..module-1": {
+      "uuid": "17dc819b-6cae-40e6-aea0-3afb856646f6",
+      "invariantUuid": "9fe2a0bb-e1e2-4dfd-9566-a7dfc3adc07d",
+      "customizationUuid": "9d428546-00c6-468b-94de-2d4e136459cd",
+      "description": null,
+      "name": "XbiTestModuleReplace..ocgmgr..module-1",
+      "version": "1",
+      "modelCustomizationName": "XbiTestModuleReplace..ocgmgr..module-1",
+      "properties": {
+        "minCountInstances": 0,
+        "maxCountInstances": null,
+        "initialCount": 0,
+        "vfModuleLabel": "ocgmgr",
+        "baseModule": false
+      },
+      "inputs": {},
+      "volumeGroupAllowed": true
+    }
+  },
+  "volumeGroups": {
+    "xbitestmodulereplace0..XbiTestModuleReplace..ocgmgr..module-1": {
+      "uuid": "17dc819b-6cae-40e6-aea0-3afb856646f6",
+      "invariantUuid": "9fe2a0bb-e1e2-4dfd-9566-a7dfc3adc07d",
+      "customizationUuid": "9d428546-00c6-468b-94de-2d4e136459cd",
+      "description": null,
+      "name": "XbiTestModuleReplace..ocgmgr..module-1",
+      "version": "1",
+      "modelCustomizationName": "XbiTestModuleReplace..ocgmgr..module-1",
+      "properties": {
+        "minCountInstances": 0,
+        "maxCountInstances": null,
+        "initialCount": 0,
+        "vfModuleLabel": "ocgmgr",
+        "baseModule": false
+      },
+      "inputs": {}
+    }
+  },
+  "pnfs": {},
+  "vnfGroups": {},
+  "vrfs": {}
+}
diff --git a/vid-webpack-master/cypress/support/jsonBuilders/mocks/vid.mock.ts b/vid-webpack-master/cypress/support/jsonBuilders/mocks/vid.mock.ts
index 052fb8a..6fff0bc 100644
--- a/vid-webpack-master/cypress/support/jsonBuilders/mocks/vid.mock.ts
+++ b/vid-webpack-master/cypress/support/jsonBuilders/mocks/vid.mock.ts
@@ -107,14 +107,13 @@
   })
 }
 
-function mockLatestVersionForService(uuidObject :any) {
-  if(uuidObject && uuidObject.serviceUuid && uuidObject.invariantId){
+function mockLatestVersionForService(serviceUuid: string, invariantId: string) {
     cy.server().route({
-      url: Cypress.config('baseUrl') + '/aai_get_newest_model_version_by_invariant/' + uuidObject.invariantId,
+      url: Cypress.config('baseUrl') + '/aai_get_newest_model_version_by_invariant/' + invariantId,
       method: 'GET',
       status: 200,
       response: {
-        "modelVersionId": uuidObject.serviceUuid,
+        "modelVersionId": serviceUuid,
         "modelName": "SERVICE_INSTANCE_NAME",
         "modelVersion": "2.0",
         "distributionStatus": "DISTRIBUTION_COMPLETE_OK",
@@ -122,16 +121,14 @@
         "modelDescription": "modelDescription"
       },
     }).as("expectLatestServiceModelUpgradeVersion")
-  }
 }
 
-function initVidMock(...args :any): void {
+function initVidMock(): void {
   initGetToMenuInfo();
   initCategoryParameter();
   initFlags();
   initAuditInfoVID();
   initAuditInfoMSO();
-  mockLatestVersionForService(args[0]);
 }