aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
blob: 8eb70b1fe3e08ecea5fe34c7ea5b52395eab5a1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
describe('Drawing Board: Instantiation Templates', function () {

  describe('Load Page and Deploy', () => {

    beforeEach(() => {
      cy.clearSessionStorage();
      cy.setTestApiParamToVNF();
      cy.initVidMock();
      cy.initDrawingBoardUserPermission();
      cy.login();

      mockAsyncBulkResponse();
    });

    afterEach(() => {
      cy.screenshot();
    });

    it(`Given a stored template - when click "deploy" - then a coherent request should be sent upon deploy`, function () {
      const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
      const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";

      const drawingBoardAction = `RECREATE`;
      const templateTopologyEndpoint = "templateTopology";

      // Given...

      cy.route(`**/rest/models/services/${serviceModelId}`,
        'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
      .as('serviceModel');

      cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`,
        'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json')
      .as('templateTopology');

      // When...

      cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` +
        `?jobId=${templateUuid}` +
        `&serviceModelId=${serviceModelId}`);

      cy.wait('@serviceModel');
      cy.wait('@templateTopology');
      cy.getElementByDataTestsId("node-vProbe_NC_VNF 0").should('be.visible');

      cy.getDrawingBoardDeployBtn().click();

      // Then...

      cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
         cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json').then((expectedResult) => {
           convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
            cy.deepCompare(xhr.request.body, expectedResult);
        });
      });

    });

  });

  //We use this function because the deployService() on drawing-board-header.component class
  // changes rollbackOnFailure value from string type to boolean.
  function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
    expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure);
  }

  function mockAsyncBulkResponse() {
    cy.server().route({
      url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
      method: 'POST',
      status: 200,
      response: "[]",
    }).as("expectedPostAsyncInstantiation");
  }

});