Merge "fix open modern ui from Create new service instance flow"
authorIttay Stern <ittay.stern@att.com>
Wed, 15 Jan 2020 09:10:53 +0000 (09:10 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 15 Jan 2020 09:10:53 +0000 (09:10 +0000)
vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js
vid-webpack-master/cypress/integration/iFrames/browse-sdc.e2e.ts
vid-webpack-master/cypress/support/jsonBuilders/mocks/aai.mock.ts
vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/aaiGetModelsByServiceType.json [new file with mode: 0644]

index 7b6d4af..a6f6cc6 100755 (executable)
@@ -93,11 +93,14 @@ var creationDialogController = function (COMPONENT, FIELD, PARAMETER, $scope, $h
 
 
         if (!$scope.shouldShowOldPopup()) {
+            let modelNameVersionId = request.modelNameVersionId ?
+                request.modelNameVersionId :
+                (DataService.getModelInfo(COMPONENT.SERVICE) ? DataService.getModelInfo(COMPONENT.SERVICE).modelNameVersionId : "");
             if(DataService.getIsInstantiationTemplateExists()){
-                $scope.url = COMPONENT.INSTANTIATION_TEMPLATES_IFRAME_URL + request.modelNameVersionId;
+                $scope.url = COMPONENT.INSTANTIATION_TEMPLATES_IFRAME_URL + modelNameVersionId;
                 window.addEventListener("message", receiveMessage, false);
             }else {
-                $scope.url = COMPONENT.SERVICE_POPUP_IFRAME_URL + request.modelNameVersionId + "&isCreate=true&r=" + Math.random();
+                $scope.url = COMPONENT.SERVICE_POPUP_IFRAME_URL + modelNameVersionId + "&isCreate=true&r=" + Math.random();
                 window.addEventListener("message", receiveMessage, false);
             }
         }
index a71d942..b1671a4 100644 (file)
@@ -98,6 +98,45 @@ describe('Browse SDC', function () {
     });
   });
 
+  it(`browse sdc open create new service instance flow`, function () {
+    const MACRO_FOR_NEW_FLOW_ID: string = '745d1bf1-9ed1-413f-8111-f1e984ad63fb';
+
+    cy.initGetAAISubDetails();
+
+    cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiGetModelsByServiceType.json').then((res) => {
+      jsonBuilderAndMock.basicJson(res,
+        Cypress.config('baseUrl') + '/aai_get_models_by_service_type/**',
+        200,
+        0,
+        'aaiGetModelByServiceType');
+    });
+
+    cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => {
+      jsonBuilderAndMock.basicJson(res,
+        Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_FOR_NEW_FLOW_ID,
+        200,
+        0,
+        'MACRO_FOR_NEW_FLOW');
+    });
+
+    cy.get('span').contains('Create New Service Instance').click({force: true})
+      .selectDropdownOptionByText('subscriberName', 'SILVIA ROBBINS');
+    cy.get('button').contains('Submit').click({force: true});
+    cy.selectDropdownOptionByText('serviceType', 'TYLER SILVIA');
+    cy.get('button').contains('Submit').click({force: true});
+    cy.wait("@aaiGetModelByServiceType").then(() => {
+      cy.getElementByDataTestsId('deploy-' + MACRO_FOR_NEW_FLOW_ID).click({force: true});
+      cy.get('button').contains('Deploy').eq(0).click({force: true});
+      cy.get('iframe').then(function ($iframe) {
+          expect($iframe.attr('src')).to.contain(`app/ui/#/servicePopup?serviceModelId=74fa72dd-012b-49c3-800d-06b12bcaf1a0`);
+      });
+    });
+
+    cy.visit("welcome.htm"); //relaod page to not break the following tests
+
+  });
+
+
   it(`browse sdc of service without instantiationType open aLaCarte popup`, function () {
     const VERY_OLD_SERVICE_UUID: string = "09c476c7-91ae-44b8-a731-04d8d8fa3695";
     const TEST_MOCKS_PATH = "cypress/support/jsonBuilders/mocks/jsons/bug_aLaCarteServiceWrongPopup/";
index ae60361..807a3bc 100644 (file)
@@ -9,6 +9,7 @@ declare namespace Cypress {
     initActiveVPNs : typeof  initActiveVPNs;
     initGetAAISubDetails : typeof  initGetAAISubDetails;
     initAAIServices: typeof initAAIServices;
+    initGetModelByServiceType: typeof initGetModelByServiceType;
   }
 }
 
@@ -48,6 +49,19 @@ function initGetAAISubDetails(response? : JSON) : void {
   });
 }
 
+function initGetModelByServiceType(response? : JSON) : void {
+  cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiSubDetails.json').then((res) => {
+    cy.server()
+      .route({
+        method: 'GET',
+        status: 200,
+        url: Cypress.config('baseUrl') + "/aai_get_models_by_service_type/**",
+        response: response ? response : res
+      }).as('aai-sub-details')
+  });
+}
+
+
 function initAlaCarteService(response? : JSON) : void {
   cy.readFile('cypress/support/jsonBuilders/mocks/jsons/a-la-carteService.json').then((res) => {
     cy.server()
@@ -156,6 +170,7 @@ Cypress.Commands.add('initSearchVNFMemebers', initSearchVNFMemebers);
 Cypress.Commands.add('initActiveNetworks', initActiveNetworks);
 Cypress.Commands.add('initActiveVPNs', initActiveVPNs);
 Cypress.Commands.add('initAAIServices', initAAIServices);
+Cypress.Commands.add('initGetModelByServiceType', initGetModelByServiceType);
 
 
 
diff --git a/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/aaiGetModelsByServiceType.json b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/aaiGetModelsByServiceType.json
new file mode 100644 (file)
index 0000000..2540650
--- /dev/null
@@ -0,0 +1,58 @@
+{
+  "inventory-response-item": [
+    {
+      "service-subscription": {
+        "service-type": "TYLER SILVIA",
+        "resource-version": "1494001841964"
+      },
+      "extra-properties": {},
+      "inventory-response-items": {
+        "inventory-response-item":[
+          {
+            "model-name": "RG_11-18_vccf_srvc",
+            "service-instance": {
+              "service-instance-id": "b9769e8f-70aa-4b05-8988-64044aa63498",
+              "service-instance-name": "TestCharlie",
+              "model-invariant-id": "4af418a9-c2f5-4fae-a577-b69d6341eee8",
+              "model-version-id": "745d1bf1-9ed1-413f-8111-f1e984ad63fb",
+              "resource-version": "1494002070115"
+            },
+            "extra-properties": {
+              "extra-property": [
+                {
+                  "property-name": "model-ver.model-description",
+                  "property-value": "Service for vccf"
+                },
+                {
+                  "property-name": "model-ver.model-version-id",
+                  "property-value": "745d1bf1-9ed1-413f-8111-f1e984ad63fb"
+                },
+                {
+                  "property-name": "model-ver.model-name",
+                  "property-value": "RG_11-18_vccf_srvc"
+                },
+                {
+                  "property-name": "model.model-type",
+                  "property-value": "service"
+                },
+                {
+                  "property-name": "model.model-invariant-id",
+                  "property-value": "4af418a9-c2f5-4fae-a577-b69d6341eee8"
+                },
+                {
+                  "property-name": "model.model-description"
+                },
+                {
+                  "property-name": "model-ver.model-version",
+                  "property-value": "1.0"
+                }
+              ]
+            }
+          }
+        ]
+      }
+    }
+  ]
+}
+
+