0b19b667c0a68281da51c1dac8bf89751932e5ed
[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
45       cy.getDrawingBoardDeployBtn().click();
46
47       // Then...
48
49       cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
50          cy.readFile('cypress/support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__instance_template.json').then((expectedResult) => {
51            convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
52             cy.deepCompare(xhr.request.body, expectedResult);
53         });
54       });
55
56     });
57
58   });
59
60   //We use this function because the deployService() on drawing-board-header.component class
61   // changes rollbackOnFailure value from string type to boolean.
62   function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
63     expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure);
64   }
65
66   function mockAsyncBulkResponse() {
67     cy.server().route({
68       url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
69       method: 'POST',
70       status: 200,
71       response: "[]",
72     }).as("expectedPostAsyncInstantiation");
73   }
74
75 });