Add existingVNFCounterMap to mock json file to display the Service Model.
[vid.git] / vid-webpack-master / cypress / integration / iFrames / instantiation-templates.e2e.ts
1 describe('Drawing Board: Instantiation Templates', function () {
2
3   describe('Load Page and Deploy', () => {
4
5     beforeEach(() => {
6       cy.clearSessionStorage();
7       cy.setTestApiParamToVNF();
8       cy.initVidMock();
9       cy.initDrawingBoardUserPermission();
10       cy.login();
11
12       mockAsyncBulkResponse();
13     });
14
15     afterEach(() => {
16       cy.screenshot();
17     });
18
19     it(`Given a stored template - when click "deploy" - then a coherent request should be sent upon deploy`, function () {
20       const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
21       const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";
22
23       const drawingBoardAction = `RECREATE`;
24       const templateTopologyEndpoint = "templateTopology";
25
26       // Given...
27
28       cy.route(`**/rest/models/services/${serviceModelId}`,
29         'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
30       .as('serviceModel');
31
32       cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`,
33         'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__instance_template.json')
34       .as('templateTopology');
35
36       // When...
37
38       cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` +
39         `?jobId=${templateUuid}` +
40         `&serviceModelId=${serviceModelId}`);
41
42       cy.wait('@serviceModel');
43       cy.wait('@templateTopology');
44       cy.getElementByDataTestsId("node-vProbe_NC_VNF 0").should('be.visible');
45
46       cy.getDrawingBoardDeployBtn().click();
47
48       // Then...
49
50       cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
51          cy.readFile('cypress/support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__instance_template.json').then((expectedResult) => {
52            convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
53             cy.deepCompare(xhr.request.body, expectedResult);
54         });
55       });
56
57     });
58
59   });
60
61   //We use this function because the deployService() on drawing-board-header.component class
62   // changes rollbackOnFailure value from string type to boolean.
63   function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
64     expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure);
65   }
66
67   function mockAsyncBulkResponse() {
68     cy.server().route({
69       url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
70       method: 'POST',
71       status: 200,
72       response: "[]",
73     }).as("expectedPostAsyncInstantiation");
74   }
75
76 });