Merge "Load template button in new template modal"
authorEylon Malin <eylon.malin@intl.att.com>
Sun, 15 Dec 2019 11:21:41 +0000 (11:21 +0000)
committerGerrit Code Review <gerrit@onap.org>
Sun, 15 Dec 2019 11:21:41 +0000 (11:21 +0000)
vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts
vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts
vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html
vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts
vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts
vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.row.model.ts
vid-webpack-master/src/app/shared/models/serviceBase.ts [new file with mode: 0644]
vid-webpack-master/src/app/shared/server/serviceInfo/serviceInfo.model.ts

index b862e56..3caa4e8 100644 (file)
@@ -1,6 +1,47 @@
 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
 describe('Template', () => {
 
+  const asyncInstantiation = [
+    {
+      "id": 8,
+      "created": 1525075968000,
+      "modified": 1525075971000,
+      "action": "INSTANTIATE",
+      "createdId": null,
+      "modifiedId": null,
+      "rowNum": null,
+      "auditUserId": null,
+      "auditTrail": null,
+      "jobId": "5c2cd8e5-27d0-42e3-85a1-85db5eaba459",
+      "templateId": "d42ba7c8-9e19-4e34-ae2c-d8af3f24498e",
+      "userId": "16807000",
+      "aLaCarte": false,
+      "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d9c",
+      "jobStatus": "FAILED",
+      "statusModifiedDate": 1525075968000,
+      "hidden": false,
+      "pause": false,
+      "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
+      "owningEntityName": "WayneHolland",
+      "project": "WATKINS",
+      "aicZoneId": "NFT1",
+      "aicZoneName": "NFTJSSSS-NFT1",
+      "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
+      "tenantName": "AIN Web Tool-15-D-testalexandria",
+      "regionId": "hvf6",
+      "regionName": null,
+      "serviceType": "TYLER SILVIA",
+      "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
+      "serviceInstanceId": null,
+      "serviceInstanceName": "nWUfl instance name_002",
+      "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
+      "serviceModelName": "action-data",
+      "serviceModelVersion": "1.0",
+      "createdBulkDate": 1525075968000,
+      "isRetryEnabled": true
+    }
+  ];
+
   beforeEach(() => {
     cy.clearSessionStorage();
     cy.setReduxState();
@@ -8,71 +49,35 @@ describe('Template', () => {
     cy.initAAIMock();
     cy.initVidMock();
     cy.login();
-  });
-
-  afterEach(() => {
-    cy.screenshot();
-  });
 
-  it('when open service popup should show template button', function () {
     cy.readFile('cypress/support/jsonBuilders/mocks/jsons/flags.cypress.json').then((flags) => {
       cy.server()
-        .route({
-          method: 'GET',
-          delay: 0,
-          status: 200,
-          url: Cypress.config('baseUrl') + "/flags**",
-          response: {
-            "FLAG_VF_MODULE_RESUME_STATUS_CREATE": false,
-            "FLAG_2004_INSTANTIATION_TEMPLATES_POPUP": true
-          }
-        }).as('initFlags');
+      .route({
+        method: 'GET',
+        delay: 0,
+        status: 200,
+        url: Cypress.config('baseUrl') + "/flags**",
+        response: {
+          "FLAG_VF_MODULE_RESUME_STATUS_CREATE": false,
+          "FLAG_2004_INSTANTIATION_TEMPLATES_POPUP": true
+        }
+      }).as('initFlags');
     });
 
-    const asyncInstantiation = [
-      {
-        "id": 8,
-        "created": 1525075968000,
-        "modified": 1525075971000,
-        "action": "INSTANTIATE",
-        "createdId": null,
-        "modifiedId": null,
-        "rowNum": null,
-        "auditUserId": null,
-        "auditTrail": null,
-        "jobId": "5c2cd8e5-27d0-42e3-85a1-85db5eaba459",
-        "templateId": "d42ba7c8-9e19-4e34-ae2c-d8af3f24498e",
-        "userId": "16807000",
-        "aLaCarte": false,
-        "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d9c",
-        "jobStatus": "FAILED",
-        "statusModifiedDate": 1525075968000,
-        "hidden": false,
-        "pause": false,
-        "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
-        "owningEntityName": "WayneHolland",
-        "project": "WATKINS",
-        "aicZoneId": "NFT1",
-        "aicZoneName": "NFTJSSSS-NFT1",
-        "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
-        "tenantName": "AIN Web Tool-15-D-testalexandria",
-        "regionId": "hvf6",
-        "regionName": null,
-        "serviceType": "TYLER SILVIA",
-        "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
-        "serviceInstanceId": null,
-        "serviceInstanceName": "nWUfl instance name_002",
-        "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
-        "serviceModelName": "action-data",
-        "serviceModelVersion": "1.0",
-        "createdBulkDate": 1525075968000,
-        "isRetryEnabled": true
-      }
-    ];
-
     cy.route(Cypress.config('baseUrl') + "/asyncInstantiation**", asyncInstantiation);
 
     cy.openIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true');
+
+
+
+
+  });
+
+  afterEach(() => {
+    cy.screenshot();
+  });
+
+  it('when open service popup should show template button', function () {
     cy.getElementByDataTestsId('templateButton').contains('Template')
       .getElementByDataTestsId('templateButton').click({force: true}) // Open template Modal
       .getElementByDataTestsId('template-modal-title').contains('Templates') // Check Modal header
@@ -106,5 +111,24 @@ describe('Template', () => {
     cy.getElementByDataTestsId('LoadTemplateButton').should('not.be.disabled')
 
   });
+
+  it('clicking on load template button, go to expected url', function () {
+
+    cy.getElementByDataTestsId('templateButton').contains('Template')
+    .getElementByDataTestsId('templateButton').click({force: true}) // Open template Modal
+
+    const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
+    const jobId = '5c2cd8e5-27d0-42e3-85a1-85db5eaba459';
+    const vidBaseUrl = `http://localhost:8080/vid/serviceModels.htm`;
+
+    cy.getElementByDataTestsId('row-5c2cd8e5-27d0-42e3-85a1-85db5eaba459').click();
+    cy.getElementByDataTestsId('LoadTemplateButton').click()
+
+    cy.location().should((loc) => {
+      expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${jobId}`);
+    });
+  });
+
+
 });
 
index 4bfedd9..229beb4 100644 (file)
@@ -13,6 +13,7 @@ import {Router, UrlTree} from "@angular/router";
 import {of} from "rxjs";
 import {MsoService} from "../shared/services/msoService/mso.service";
 import {ServiceAction} from "../shared/models/serviceInstanceActions";
+import {InstantiationBase} from "../shared/models/serviceBase";
 
 export let PENDING : string = "pending";
 export let INPROGRESS : string = "in_progress";
@@ -112,21 +113,21 @@ export class InstantiationStatusComponentService {
     window.parent.location.assign('../../serviceModels.htm#/instantiate?' + query);
   }
 
-  navigateToNewViewEdit(item: ServiceInfoModel, mode: DrawingBoardModes): void{
+  navigateToNewViewEdit(item: InstantiationBase, mode: DrawingBoardModes): void {
     this._store.dispatch(updateDrawingBoardStatus(mode));
     const viewEditUrlTree:UrlTree = this.getNewViewEditUrlTree(item, mode);
     this._router.navigateByUrl(viewEditUrlTree);
     window.parent.location.assign(this.getViewEditUrl(viewEditUrlTree));
   }
 
-  getNewViewEditUrlTree(item: ServiceInfoModel, mode: DrawingBoardModes): UrlTree {
+  getNewViewEditUrlTree(item: InstantiationBase, mode: DrawingBoardModes): UrlTree {
     return this._router.createUrlTree(
       ['/servicePlanning/' + mode],
       {
         queryParams:
         mode==DrawingBoardModes.RECREATE ?
           this.getRecreateQueryParams(item) :
-          this.getDefaultViewEditQueryParams(item)
+          this.getDefaultViewEditQueryParams(<ServiceInfoModel> item)
       });
   }
 
@@ -140,7 +141,7 @@ export class InstantiationStatusComponentService {
     };
   }
 
-  private getRecreateQueryParams(item: ServiceInfoModel) {
+  private getRecreateQueryParams(item: InstantiationBase) {
     return {
       serviceModelId: item.serviceModelId,
       jobId: item.jobId
index 19f641a..86c46ab 100644 (file)
@@ -50,8 +50,8 @@
           <tbody>
           <tr class="member-table-row"
               *ngFor="let item of filterTableData | searchFilter: filterText ;"
-              (click)="selectedJobId = item.jobId"
-              [ngClass]="{'selected' : selectedJobId === item.jobId}"
+              (click)="selectedInstantiation = item"
+              [ngClass]="{'selected' : selectedInstantiation && selectedInstantiation.jobId === item.jobId}"
               [attr.data-tests-id]="'row-' + item.jobId">
             <td>
               <div>
       </div>
       <div class="col-md-6" style="padding: 15px;padding-right: 35px;">
         <button
-          [disabled]="selectedJobId === null"
+          [disabled]="selectedInstantiation && selectedInstantiation.jobId === null"
           [attr.data-tests-id]="'LoadTemplateButton'"
           type="button" class="btn btn-primary submit"
           (click)="loadTemplate()"><span>Load Template</span>
index 4d89750..7b16b66 100644 (file)
@@ -5,6 +5,8 @@ import {ActivatedRoute} from "@angular/router";
 import {ServiceInfoService} from "../../../server/serviceInfo/serviceInfo.service";
 import {InstantiationTemplatesModalService} from "./instantiation.templates.modal.service";
 import {InstantiationTemplatesRowModel} from "./instantiation.templates.row.model";
+import {DrawingBoardModes} from "../../../../drawingBoard/service-planning/drawing-board.modes";
+import {InstantiationStatusComponentService} from "../../../../instantiationStatus/instantiationStatus.component.service";
 
 @Component({
   selector: 'template-modal',
@@ -14,7 +16,7 @@ import {InstantiationTemplatesRowModel} from "./instantiation.templates.row.mode
 
 export class InstantiationTemplatesModalComponent extends DialogComponent<string, boolean> implements OnInit, OnDestroy {
 
-  selectedJobId : string = null;
+  selectedInstantiation: InstantiationTemplatesRowModel = null;
   templateModalComponentService: InstantiationTemplatesModalService;
   originalTableData: InstantiationTemplatesRowModel[] = [];
   filterTableData : InstantiationTemplatesRowModel[] = [];
@@ -24,6 +26,7 @@ export class InstantiationTemplatesModalComponent extends DialogComponent<string
               private _iframeService: IframeService,
               private _serviceInfoService: ServiceInfoService,
               private _templateModalComponentService: InstantiationTemplatesModalService,
+              private _instantiationStatusComponentService: InstantiationStatusComponentService,
               private _route: ActivatedRoute) {
     super(dialogService);
     this.templateModalComponentService = _templateModalComponentService;
@@ -42,6 +45,7 @@ export class InstantiationTemplatesModalComponent extends DialogComponent<string
   }
 
   loadTemplate = () => {
+    this._instantiationStatusComponentService.navigateToNewViewEdit(this.selectedInstantiation, DrawingBoardModes.RECREATE)
 
   };
 
index 7126da3..8377ccf 100644 (file)
@@ -3,6 +3,7 @@ import {InstantiationTemplatesRowModel} from "./instantiation.templates.row.mode
 
 @Injectable()
 export class InstantiationTemplatesModalService {
+
   convertResponseToUI = (jobsResponse: any[]): InstantiationTemplatesRowModel[] => {
     let tableRows: InstantiationTemplatesRowModel[] = [];
 
@@ -12,4 +13,5 @@ export class InstantiationTemplatesModalService {
 
     return tableRows;
   };
+
 }
index 08982cc..f4609ee 100644 (file)
@@ -1,8 +1,8 @@
 import * as moment from 'moment';
 import * as _ from 'lodash';
+import {InstantiationBase} from "../../../models/serviceBase";
 
-export class InstantiationTemplatesRowModel {
-  readonly jobId: string;
+export class InstantiationTemplatesRowModel extends InstantiationBase{
   readonly userId ?: string;
   readonly createDate ?: string;
   readonly instanceName ?: string;
@@ -13,7 +13,7 @@ export class InstantiationTemplatesRowModel {
   readonly aicZone?: string;
 
   constructor(data) {
-    this.jobId = data.jobId;
+    super(data);
     this.userId = !_.isNil(data.created) ? data.userId : null;
     this.createDate = !_.isNil(data.created) ? moment(data.created).format("YYYY-MM-DD HH:mm:ss") : null;
     this.instanceName = this.getInstanceName(data.serviceInstanceName);
@@ -22,7 +22,6 @@ export class InstantiationTemplatesRowModel {
     this.region = this.getRegion(data.regionId, data.owningEntityName);
     this.tenant = !_.isNil(data.tenantName) ? data.tenantName : null;
     this.aicZone = !_.isNil(data.aicZoneName) ? data.aicZoneName : null;
-
   }
 
 
diff --git a/vid-webpack-master/src/app/shared/models/serviceBase.ts b/vid-webpack-master/src/app/shared/models/serviceBase.ts
new file mode 100644 (file)
index 0000000..b6dec0f
--- /dev/null
@@ -0,0 +1,9 @@
+export class InstantiationBase {
+  readonly jobId: string;
+  readonly serviceModelId: string;
+
+  constructor(data) {
+    this.jobId = data.jobId;
+    this.serviceModelId = data.serviceModelId;
+  }
+}
index a507e07..fa26a61 100644 (file)
@@ -1,7 +1,8 @@
 import {ServiceStatus} from '../../../instantiationStatus/instantiationStatus.component.service';
 import {ServiceAction} from "../../models/serviceInstanceActions";
+import {InstantiationBase} from "../../models/serviceBase";
 
-export class ServiceInfoModel {
+export class ServiceInfoModel extends InstantiationBase{
   id: number;
   created: Date;
   modified: Date;
@@ -28,12 +29,10 @@ export class ServiceInfoModel {
   subscriberId: string;
   serviceInstanceId: string;
   serviceInstanceName: string;
-  serviceModelId: string;
   serviceModelName: string;
   serviceModelVersion: string;
   templateId: string;
   auditUserId: string;
-  jobId: string;
   action: ServiceAction;
   isRetryEnabled: boolean;
 }