Add cypress test that check vnf popup contains correct lcp region data. 91/99491/1
authorAlexey Sandler <alexey.sandler@intl.att.com>
Wed, 11 Dec 2019 08:06:31 +0000 (10:06 +0200)
committerAlexey Sandler <alexey.sandler@intl.att.com>
Wed, 11 Dec 2019 14:14:21 +0000 (16:14 +0200)
Issue-ID: VID-724
Signed-off-by: Alexey Sandler <alexey.sandler@intl.att.com>
Change-Id: I8231009ca8753987055291af83eb5c088d816ac8

vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json
vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts

index 04b0961..a8417e3 100644 (file)
@@ -44,9 +44,9 @@
       "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
       "instanceName": "zolson57arlba007",
       "action": "Create",
-      "platformName": "NETWORK-CLOUD",
-      "lcpCloudRegionId": "olson57a",
-      "tenantId": "dcb28ad99c7341748830c9dc307f85eb",
+      "platformName": "xxx1",
+      "lcpCloudRegionId": "hvf6",
+      "tenantId": "4914ab0ab3a743e58f0eefdacc1dde77",
       "instanceParams": [
         {}
       ],
@@ -66,8 +66,8 @@
             },
             "instanceName": "zolson57arlba007_lba_Base_01",
             "action": "Create",
-            "lcpCloudRegionId": "olson57a",
-            "tenantId": "dcb28ad99c7341748830c9dc307f85eb",
+            "lcpCloudRegionId": "hvf6",
+            "tenantId": "4914ab0ab3a743e58f0eefdacc1dde77",
             "instanceParams": [
               {}
             ],
@@ -89,8 +89,8 @@
             },
             "instanceName": "zolson57arlba007_lba_dj_01",
             "action": "Create",
-            "lcpCloudRegionId": "olson57a",
-            "tenantId": "dcb28ad99c7341748830c9dc307f85eb",
+            "lcpCloudRegionId": "hvf6",
+            "tenantId": "4914ab0ab3a743e58f0eefdacc1dde77",
             "instanceParams": [
               {}
             ],
       "isFailed": false,
       "statusMessage": null,
       "position": null,
-      "lineOfBusiness": "EMANUEL-CONSUMER"
+      "lineOfBusiness": "zzz1"
     }
   },
   "networks": {},
index 8eb70b1..afad687 100644 (file)
@@ -1,10 +1,13 @@
+import ObjectLike = Cypress.ObjectLike;
+
 describe('Drawing Board: Instantiation Templates', function () {
 
-  describe('Load Page and Deploy', () => {
+  describe('Instantiation templates ', () => {
 
     beforeEach(() => {
       cy.clearSessionStorage();
       cy.setTestApiParamToVNF();
+      cy.initAAIMock();
       cy.initVidMock();
       cy.initDrawingBoardUserPermission();
       cy.login();
@@ -16,41 +19,28 @@ describe('Drawing Board: Instantiation Templates', function () {
       cy.screenshot();
     });
 
-    it(`Given a stored template - when click "deploy" - then a coherent request should be sent upon deploy`, function () {
-      const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
-      const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";
-
-      const drawingBoardAction = `RECREATE`;
-      const templateTopologyEndpoint = "templateTopology";
-
-      // Given...
+    describe('Load Page and Deploy', () => {
 
-      cy.route(`**/rest/models/services/${serviceModelId}`,
-        'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
-      .as('serviceModel');
+      it(`Given a stored template - when click "deploy" - then a coherent request should be sent upon deploy`, function () {
 
-      cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`,
-        'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json')
-      .as('templateTopology');
+        loadDrawingBoardWithRecreateMode();
 
-      // When...
-
-      cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` +
-        `?jobId=${templateUuid}` +
-        `&serviceModelId=${serviceModelId}`);
+        // Then...
+        cy.getElementByDataTestsId("node-vProbe_NC_VNF 0").should('be.visible');
+        assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
+      });
 
-      cy.wait('@serviceModel');
-      cy.wait('@templateTopology');
-      cy.getElementByDataTestsId("node-vProbe_NC_VNF 0").should('be.visible');
+      it('View a template’s details as expected', ()=> {
 
-      cy.getDrawingBoardDeployBtn().click();
+        loadDrawingBoardWithRecreateMode();
 
-      // Then...
+        // Then...
+        cy.drawingBoardTreeOpenContextMenuByElementDataTestId("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0")
+        .drawingBoardTreeClickOnContextMenuOptionByName('Edit')
+        .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
+        .getElementByDataTestsId("cancelButton").click();
 
-      cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
-         cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json').then((expectedResult) => {
-           convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
-            cy.deepCompare(xhr.request.body, expectedResult);
+        assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
         });
       });
 
@@ -58,12 +48,54 @@ describe('Drawing Board: Instantiation Templates', function () {
 
   });
 
+function loadDrawingBoardWithRecreateMode() {
+  const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
+  const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";
+
+  const drawingBoardAction = `RECREATE`;
+  const templateTopologyEndpoint = "templateTopology";
+  cy.route(`**/rest/models/services/${serviceModelId}`,
+    'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
+  .as('serviceModel');
+
+  cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`,
+    'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json')
+  .as('templateTopology');
+
+  // When...
+
+  cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` +
+    `?jobId=${templateUuid}` +
+    `&serviceModelId=${serviceModelId}`);
+
+  cy.wait('@serviceModel');
+  cy.wait('@templateTopology');
+}
+
+function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd() {
+  cy.getDrawingBoardDeployBtn().click();
+  cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
+    cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json').then((expectedResult) => {
+      convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
+
+      let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr);
+      cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult);
+    });
+  });
+}
+
   //We use this function because the deployService() on drawing-board-header.component class
   // changes rollbackOnFailure value from string type to boolean.
   function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
     expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure);
   }
 
+function removeIsDirtyFieldFromXhrRequestBody(xhr : any) {
+  let xhrTempBody = JSON.parse(JSON.stringify(xhr.request.body));
+  delete xhrTempBody.isDirty;
+  return xhrTempBody;
+}
+
   function mockAsyncBulkResponse() {
     cy.server().route({
       url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
@@ -72,5 +104,3 @@ describe('Drawing Board: Instantiation Templates', function () {
       response: "[]",
     }).as("expectedPostAsyncInstantiation");
   }
-
-});