1 import ObjectLike = Cypress.ObjectLike;
3 describe('Drawing Board: Instantiation Templates', function () {
5 describe('Instantiation templates ', () => {
8 cy.clearSessionStorage();
9 cy.setTestApiParamToVNF();
12 cy.initDrawingBoardUserPermission();
15 mockAsyncBulkResponse();
22 describe('Load Page and Deploy', () => {
24 it(`Given a stored template - when click "deploy" - then a coherent request should be sent upon deploy`, function () {
26 loadDrawingBoardWithRecreateMode();
29 cy.getElementByDataTestsId("node-vProbe_NC_VNF 0").should('be.visible');
30 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
33 it('View a template’s details as expected', ()=> {
35 loadDrawingBoardWithRecreateMode();
38 cy.drawingBoardTreeOpenContextMenuByElementDataTestId("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0")
39 .drawingBoardTreeClickOnContextMenuOptionByName('Edit')
40 .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007')
41 .getElementByDataTestsId("productFamily").should('contain', 'Emanuel')
42 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
43 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
44 .getElementByDataTestsId("lineOfBusiness").should('contain', 'zzz1')
45 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
48 .getElementByDataTestsId("cancelButton").click();
50 cy.drawingBoardTreeOpenContextMenuByElementDataTestId("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0")
51 .drawingBoardTreeClickOnContextMenuOptionByName('Edit')
52 .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007_lba_Base_01')
53 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
54 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
55 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
57 .getElementByDataTestsId("cancelButton").click();
59 cy.drawingBoardTreeOpenContextMenuByElementDataTestId("node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1")
60 .drawingBoardTreeClickOnContextMenuOptionByName('Edit')
61 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
62 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
63 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
64 .getElementByDataTestsId("cancelButton").click();
68 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
71 it(`Edit the service`, function () {
73 loadDrawingBoardWithRecreateMode();
75 cy.openServiceContextMenu()
76 .getElementByDataTestsId("context-menu-header-edit-item").click({force : true})
83 function loadDrawingBoardWithRecreateMode() {
84 const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
85 const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";
87 const drawingBoardAction = `RECREATE`;
88 const templateTopologyEndpoint = "templateTopology";
89 cy.route(`**/rest/models/services/${serviceModelId}`,
90 'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
93 cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`,
94 'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json')
95 .as('templateTopology');
99 cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` +
100 `?jobId=${templateUuid}` +
101 `&serviceModelId=${serviceModelId}`);
103 cy.wait('@serviceModel');
104 cy.wait('@templateTopology');
107 function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd() {
108 cy.getDrawingBoardDeployBtn().click();
109 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
110 cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json').then((expectedResult) => {
111 convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
113 let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr);
114 cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult);
119 //We use this function because the deployService() on drawing-board-header.component class
120 // changes rollbackOnFailure value from string type to boolean.
121 function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
122 expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure);
125 function removeIsDirtyFieldFromXhrRequestBody(xhr : any) {
126 let xhrTempBody = JSON.parse(JSON.stringify(xhr.request.body));
127 delete xhrTempBody.isDirty;
131 function mockAsyncBulkResponse() {
133 url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
137 }).as("expectedPostAsyncInstantiation");