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("lcpRegion").should('contain', 'hvf6')
41 .getElementByDataTestsId("cancelButton").click();
43 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
51 function loadDrawingBoardWithRecreateMode() {
52 const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
53 const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";
55 const drawingBoardAction = `RECREATE`;
56 const templateTopologyEndpoint = "templateTopology";
57 cy.route(`**/rest/models/services/${serviceModelId}`,
58 'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
61 cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`,
62 'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json')
63 .as('templateTopology');
67 cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` +
68 `?jobId=${templateUuid}` +
69 `&serviceModelId=${serviceModelId}`);
71 cy.wait('@serviceModel');
72 cy.wait('@templateTopology');
75 function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd() {
76 cy.getDrawingBoardDeployBtn().click();
77 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
78 cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json').then((expectedResult) => {
79 convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
81 let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr);
82 cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult);
87 //We use this function because the deployService() on drawing-board-header.component class
88 // changes rollbackOnFailure value from string type to boolean.
89 function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
90 expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure);
93 function removeIsDirtyFieldFromXhrRequestBody(xhr : any) {
94 let xhrTempBody = JSON.parse(JSON.stringify(xhr.request.body));
95 delete xhrTempBody.isDirty;
99 function mockAsyncBulkResponse() {
101 url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
105 }).as("expectedPostAsyncInstantiation");