allow LOB multi-selection for vnf - fix cypress
[vid.git] / vid-webpack-master / cypress / integration / iFrames / ala-carte.e2e.ts
index ecd9102..4ececb0 100644 (file)
@@ -2,40 +2,37 @@
 /// <reference types="Cypress" />
 import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
 import {ServiceModel} from '../../support/jsonBuilders/models/service.model';
-import * as _ from 'lodash';
 
 describe('A la carte', function () {
   describe('check service name', () => {
     let jsonBuilderAAIService: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
-
+    const SERVICE_ID: string = '4d71990b-d8ad-4510-ac61-496288d9078e';
+    const SERVICE_INVARIANT_ID: string = 'd27e42cf-087e-4d31-88ac-6c4b7585f800';
+    const INSTANCE_NAME_MANDATORY_MESSAGE: string = 'Missing data ("Instance Name" and 3 other fields';
+    const INSTANCE_NAME_NOT_MANDATORY_MESSAGE: string = 'Missing data ("Subscriber Name" and 2 other fields)';
+    const CONFIRM_BUTTON: string = 'confirmButton';
 
     beforeEach(() => {
-      cy.window().then((win) => {
-        win.sessionStorage.clear();
-        cy.setReduxState();
-        cy.preventErrorsOnLoading();
-        cy.initAAIMock();
-        cy.initVidMock();
-        cy.initAlaCarteService();
-        cy.initZones();
-        cy.login();
-      });
+      cy.clearSessionStorage();
+      cy.setReduxState();
+      cy.preventErrorsOnLoading();
+      cy.initAAIMock();
+      cy.initVidMock();
+      cy.mockLatestVersionForService(SERVICE_ID, SERVICE_INVARIANT_ID);
+      cy.initAlaCarteService();
+      cy.initZones();
+      cy.login();
     });
 
     afterEach(() => {
       cy.screenshot();
     });
 
-    const SERVICE_ID: string = '4d71990b-d8ad-4510-ac61-496288d9078e';
-    const INSTANCE_NAME_MANDATORY_MESSAGE: string = 'Missing data ("Instance Name" and 3 other fields';
-    const INSTANCE_NAME_NOT_MANDATORY_MESSAGE: string = 'Missing data ("Subscriber Name" and 2 other fields)';
-    const CONFIRM_BUTTON: string = 'confirmButton';
-
 
-    it(`service name should be mandatory : serviceEcompNaming = true`, ()=> {
-      cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/basicService.json').then((res) => {
+    it(`service name should be mandatory : serviceEcompNaming = true`, () => {
+      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/basicService.json').then((res) => {
         jsonBuilderAAIService.basicJson(res,
-          Cypress.config('baseUrl') + '/rest/models/services/4d71990b-d8ad-4510-ac61-496288d9078e',
+          Cypress.config('baseUrl') + '/rest/models/services/' + SERVICE_ID,
           200,
           0,
           SERVICE_ID + ' - service',
@@ -44,14 +41,14 @@ describe('A la carte', function () {
       });
     });
 
-    it(`Service a-la-carte`, ()=> {
+    it(`Service a-la-carte`, () => {
 
-      const subscriptionServiceType : string = "TYLER SILVIA";
-      const owningEntityName : string = "WayneHolland";
-      const rollbackOnFailure : string = "true";
-      const projectName : string = "WATKINS";
-      const instanceName : string = "serviceInstanceName";
-      cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res) => {
+      const subscriptionServiceType: string = "TYLER SILVIA";
+      const owningEntityName: string = "WayneHolland";
+      const rollbackOnFailure: string = "true";
+      const projectName: string = "WATKINS";
+      const instanceName: string = "serviceInstanceName";
+      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res) => {
 
         cy.setTestApiParamToGR();
         res.service.serviceHierarchy['2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd'].service.vidNotions.instantiationType = 'ALaCarte';
@@ -92,9 +89,22 @@ describe('A la carte', function () {
       });
     });
 
+    it(`VNF a-la-carte`, () => {
+      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/flags.cypress.json').then((res) => {
+        res['FLAG_2002_VNF_PLATFORM_MULTI_SELECT'] = true;
+        res['FLAG_2006_VNF_LOB_MULTI_SELECT'] = true;
+        cy.server()
+          .route({
+            method: 'GET',
+            delay: 0,
+            status: 200,
+            url: Cypress.config('baseUrl') + "/flags**",
+            response: res
+          }).as('initFlags with multi select');
+      });
+
 
-    it(`VNF a-la-carte`, ()=> {
-      cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res) => {
+      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res) => {
         cy.setTestApiParamToGR();
         res.service.serviceHierarchy['2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd'].service.vidNotions.instantiationType = 'ALaCarte';
         res.service.serviceHierarchy['2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd'].service.inputs = null;
@@ -120,32 +130,44 @@ describe('A la carte', function () {
         cy.get('#quantity-select').should('have.attr', 'disabled');
         cy.getElementByDataTestsId('form-set').click({force: true}).then(() => {
           cy.getElementByDataTestsId('node-2017-488_PASQUALE-vPE 0-add-btn').click({force: true}).then(() => {
+
             cy.selectDropdownOptionByText('productFamily', 'Emanuel');
             cy.selectDropdownOptionByText('lcpRegion', 'AAIAIC25');
             cy.typeToInput("lcpRegionText", "just another region");
             cy.selectDropdownOptionByText('tenant', 'USP-SIP-IC-24335-T-01');
-            cy.selectDropdownOptionByText('lineOfBusiness', 'zzz1');
-            cy.selectDropdownOptionByText('platform', 'xxx1');
-            cy.getElementByDataTestsId('form-set').click({force: true}).then(() => {
-              cy.getReduxState().then((state) => {
+            cy.selectLobValue('zzz1');
 
-                const vnf = state.service.serviceInstance['2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd'].vnfs['2017-488_PASQUALE-vPE 0'];
+            cy.selectPlatformValue(`xxx1`);
+
+            cy.getElementByDataTestsId('form-set').click({force: true}).then(() => {
 
-                cy.readFile('../vid-automation/src/test/resources/a-la-carte/redux-a-la-carte.json').then((file) => {
-                  file.vnfs['2017-488_PASQUALE-vPE 0'].trackById = vnf.trackById;
-                  file.vnfs['2017-488_PASQUALE-vPE 0'].vfModules = {};
-                  cy.deepCompare(vnf, file.vnfs['2017-488_PASQUALE-vPE 0'])
+              const vnfMenuBtnDataTestId = 'node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0-menu-btn';
+
+              cy.getElementByDataTestsId(vnfMenuBtnDataTestId).click({force: true}).then(() => {
+                cy.getElementByDataTestsId('context-menu-edit').click({force: true});
+                cy.selectPlatformValue(`platform`);
+                cy.selectLobValue('ONAP');
+                cy.getElementByDataTestsId('form-set').click({force: true}).then(() => {
+                  cy.getReduxState().then((state) => {
+
+                    const vnf = state.service.serviceInstance['2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd'].vnfs['2017-488_PASQUALE-vPE 0'];
+                    cy.readFile('../vid-automation/src/test/resources/a-la-carte/redux-a-la-carte.json').then((file) => {
+                      file.vnfs['2017-488_PASQUALE-vPE 0'].trackById = vnf.trackById;
+                      file.vnfs['2017-488_PASQUALE-vPE 0'].vfModules = {};
+                      file.vnfs['2017-488_PASQUALE-vPE 0'].upgradedVFMSonsCounter = 0;
+                      cy.deepCompare(vnf, file.vnfs['2017-488_PASQUALE-vPE 0'])
+                    });
+                  });
                 });
               });
             });
-
           });
         });
       });
     });
 
-    it(`Network a-la-carte`, ()=> {
-      cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res) => {
+    it(`Network a-la-carte`, () => {
+      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res) => {
         cy.setTestApiParamToGR();
         res.service.serviceHierarchy['2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd'].service.vidNotions.instantiationType = 'ALaCarte';
         res.service.serviceHierarchy['2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd'].service.inputs = null;
@@ -174,11 +196,12 @@ describe('A la carte', function () {
         cy.setReduxState(<any>res);
         cy.openIframe('app/ui/#/servicePlanning?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd');
         cy.getElementByDataTestsId("node-ExtVL 0-add-btn").click({force: true});
-        cy.selectDropdownOptionByText("platform", "xxx1");
+
+        cy.selectPlatformValue(`xxx1`);
         cy.selectDropdownOptionByText("lcpRegion", "AAIAIC25");
         cy.selectDropdownOptionByText("tenant", "USP-SIP-IC-24335-T-01");
         cy.selectDropdownOptionByText("productFamily", "ERICA");
-        cy.selectDropdownOptionByText("lineOfBusiness", "zzz1");
+        cy.selectMultiselectValue("multi-lineOfBusiness", "multi-lineOfBusiness-zzz1");
         cy.typeToInput("lcpRegionText", "lcpRegionText");
 
         cy.getElementByDataTestsId('form-set').click({force: true}).then(() => {
@@ -194,15 +217,20 @@ describe('A la carte', function () {
       });
     });
 
-    it(`VFModule a-la-carte`, ()=> {
-      var timeBomb = new Date('12/09/2018');
-      if (new Date() < timeBomb) {
-        return;
-      }
-      cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res) => {
+    it(`Add ALaCarte VfModule Without LcpRegion Tenant Id And Legacy`, () => {
+      addAlacarteVfmoduleByFlag(true, 'redux-a-la-carte-no-lcp-tenant.json');
+    });
+
+    it(`Add ALaCarte VfModule With LcpRegion Tenant Id And Legacy`, () => {
+      addAlacarteVfmoduleByFlag(false, 'redux-a-la-carte.json');
+    });
+
+    function addAlacarteVfmoduleByFlag  (flag: boolean, expectedJsonFile: string) {
+      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res) => {
         cy.setTestApiParamToGR();
         res.service.serviceHierarchy['2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd'].service.vidNotions.instantiationType = 'ALaCarte';
         res.service.serviceHierarchy['2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd'].service.inputs = null;
+        res.global['flags'] = { 'FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF' : flag };
         cy.setReduxState(<any>res);
         cy.openIframe('app/ui/#/servicePlanning?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd');
 
@@ -210,8 +238,8 @@ describe('A la carte', function () {
           cy.selectDropdownOptionByText('productFamily', 'Emanuel');
           cy.selectDropdownOptionByText('lcpRegion', 'hvf6');
           cy.selectDropdownOptionByText('tenant', 'AIN Web Tool-15-D-STTest2');
-          cy.selectDropdownOptionByText('lineOfBusiness', 'zzz1');
-          cy.selectDropdownOptionByText('platform', 'xxx1');
+          cy.selectLobValue('zzz1');
+          cy.selectPlatformValue(`xxx1`);
           cy.getElementByDataTestsId('form-set').click({force: true}).then(() => {
             const vnfName = '2017-488_PASQUALE-vPE 0';
             let vfModulesNames: Array<string> = [
@@ -220,30 +248,30 @@ describe('A la carte', function () {
               '2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2',
             ];
 
-            addVfModule(vnfName, vfModulesNames[0], 'mimazepubi', 'hvf6', '', 'AINWebTool-15-D-iftach', false, false, false)
+            cy.addALaCarteVfModule(vnfName, vfModulesNames[0], 'mimazepubi', 'hvf6', '', 'AINWebTool-15-D-iftach', false, false, false, flag)
+            .then(() => {
+              cy.addALaCarteVfModule(vnfName, vfModulesNames[1], 'puwesovabe', 'AAIAIC25', 'my region', 'USP-SIP-IC-24335-T-01', true, true, false, flag)
               .then(() => {
-                addVfModule(vnfName, vfModulesNames[1], 'puwesovabe', 'AAIAIC25', 'my region', 'USP-SIP-IC-24335-T-01', true, true, false)
-                  .then(() => {
-                    addVfModule(vnfName, vfModulesNames[2], 'bnmgtrx', 'hvf6', '', 'AINWebTool-15-D-iftach', false, false, true)
-                      .then(() => {
-                        cy.getReduxState().then((state) => {
-                          const vfModules = state.service.serviceInstance['2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd'].vnfs[vnfName].vfModules;
-                          cy.readFile('../vid-automation/src/test/resources/a-la-carte/redux-a-la-carte.json').then((file) => {
-                            for (let vfModulesName of vfModulesNames) {
-                              const vfModule = vfModules[vfModulesName];
-                              let vfModuleObject = vfModule[Object.keys(vfModule)[0]];
-                              cy.deepCompare(vfModuleObject, file.vnfs[vnfName].vfModules[vfModulesName][vfModulesName]);
-                            }
-                          });
-                        });
-                      });
+                cy.addALaCarteVfModule(vnfName, vfModulesNames[2], 'bnmgtrx', 'hvf6', '', 'AINWebTool-15-D-iftach', false, false, true, flag)
+                .then(() => {
+                  cy.getReduxState().then((state) => {
+                    const vfModules = state.service.serviceInstance['2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd'].vnfs[vnfName].vfModules;
+                    cy.readFile('../vid-automation/src/test/resources/a-la-carte/' + expectedJsonFile).then((file) => {
+                      for (let vfModulesName of vfModulesNames) {
+                        const vfModule = vfModules[vfModulesName];
+                        let vfModuleObject = vfModule[Object.keys(vfModule)[0]];
+                        file.vnfs[vnfName].vfModules[vfModulesName][vfModulesName].action = "Create";
+                        cy.deepCompare(vfModuleObject, file.vnfs[vnfName].vfModules[vfModulesName][vfModulesName]);
+                      }
+                    });
                   });
+                });
               });
+            });
           });
         });
       });
-    });
-
+    };
 
     function changeServiceEcompNamingToTrue(obj: ServiceModel) {
       obj.service.serviceEcompNaming = "true";
@@ -251,7 +279,7 @@ describe('A la carte', function () {
     }
 
     function checkServiceNameInputIdMandatory() {
-      cy.get('span').contains('Browse ASDC Service Models').click({force: true})
+      cy.get('span').contains('Browse SDC Service Models').click({force: true})
         .getElementByDataTestsId('deploy-' + SERVICE_ID).click({force: true})
         .wait(1000).getElementByDataTestsId(CONFIRM_BUTTON).click({force: true})
         .get('.error').contains(INSTANCE_NAME_MANDATORY_MESSAGE)
@@ -261,28 +289,5 @@ describe('A la carte', function () {
         .get('.error').contains(INSTANCE_NAME_NOT_MANDATORY_MESSAGE);
     }
 
-    function addVfModule(vnfName: string, vfModuleName: string, instanceName: string, lcpRegion: string, legacyRegion: string, tenant: string, rollback: boolean, sdncPreLoad: boolean, deleteVgName: boolean): Chainable<any> {
-      return cy.getElementByDataTestsId('node-' + vnfName).click({force: true}).then(() => {
-        cy.getElementByDataTestsId('node-' + vfModuleName + '-add-btn').click({force: true}).then(() => {
-          cy.getElementByDataTestsId('instanceName').clear().type(instanceName, {force: true}).then(() => {
-            if (deleteVgName) {
-              cy.getElementByDataTestsId('volumeGroupName').clear();
-            }
-          }).then(() => {
-            cy.selectDropdownOptionByText('lcpRegion', lcpRegion);
-            if (!_.isEmpty(legacyRegion)) {
-              cy.typeToInput("lcpRegionText", legacyRegion);
-            }
-            cy.selectDropdownOptionByText('tenant', tenant);
-            cy.selectDropdownOptionByText('rollback', String(rollback));
-            if (sdncPreLoad) {
-              cy.getElementByDataTestsId('sdncPreLoad').check();
-            }
-            cy.getElementByDataTestsId('form-set').click({force: true});
-          });
-        });
-      });
-    }
-
   });
 });