summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/cypress/integration/iFrames/pauseInstantiationOnVfModule.e2e.ts
blob: 6d4c343a7d0f5a27fd4d422fc1c3f367eaa6b9e5 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
///<reference path="../../../node_modules/cypress/types/index.d.ts"/> / <reference types="Cypress" />

describe('Create Instance page: Pause after vfModule instantiation ', () => {

  beforeEach(() => {
    cy.clearSessionStorage();
    cy.setTestApiParamToGR();
    cy.initVidMock();
    cy.permissionVidMock();
    cy.login();

  });

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

  it(`Pause on VFModule instantiation: create two vfmodules and pause after a first vfmodule`, function () {
    cy.readFile('cypress/support/jsonBuilders/mocks/jsons/flags.cypress.json').then((flags) => {
      cy.server()
      .route({
        method: 'GET',
        delay: 0,
        status: 200,
        url: Cypress.config('baseUrl') + "/flags**",
        response: flags
      }).as('initFlags');
    });

    cy.readFile('cypress/support/jsonBuilders/mocks/jsons/reduxModelOneVnfAndTwoVfmodulesInstanceOneVnf.json').then((reduxState) => {

      cy.setReduxState(<any>reduxState);
      cy.openIframe('app/ui/#/servicePlanning?serviceModelId=f3862254-8df2-4a0a-8137-0a9fe985860c');
      const vnfName = "vOCG_1804_VF 0";
      let vfModulesNames: Array<string> = [
        'vocg_1804_vf0..Vocg1804Vf..base_ocg..module-0',
        'vocg_1804_vf0..Vocg1804Vf..ocgapp_004..module-11'
      ];
      const uuidAndVfModuleNames: Array<string> = [
        '815db6e5-bdfd-4cb6-9575-82c36df8747a-vocg_1804_vf0..Vocg1804Vf..base_ocg..module-0',
        'da10c7fe-cf81-441c-9694-4e9ddf2054d8-vocg_1804_vf0..Vocg1804Vf..ocgapp_004..module-11'
      ];

      addALaCarteVfModuleEcompGeneratedNamingTrue(vnfName, vfModulesNames[0], uuidAndVfModuleNames[0]);
      addALaCarteVfModuleEcompGeneratedNamingTrue(vnfName, vfModulesNames[1], uuidAndVfModuleNames[1]);
      pauseOnVfModuleInstantiation('node-' + uuidAndVfModuleNames[1], 0)
      pauseOnVfModuleInstantiation('node-' + uuidAndVfModuleNames[0], 0)
      removePauseInstantiation('node-'+uuidAndVfModuleNames[0], 0)
      mockAsyncBulkResponse();
      cy.getDrawingBoardDeployBtn().click();

      cy.wait('@expectedPostAsyncInstantiation')
      .then(xhr => {
        let vfModules = bodyOf(xhr).vnfs['vOCG_1804_VF 0'].vfModules;

        let unPausedVModule = vfModules[vfModulesNames[0]];
        const unPausedVModuleObject = unPausedVModule[Object.keys(unPausedVModule)[0]];
        expect(unPausedVModuleObject.pauseInstantiation).equals(null);

        let pausedVModule = vfModules[vfModulesNames[1]];
        const pausedVModuleObject = pausedVModule[Object.keys(pausedVModule)[0]];
        expect(pausedVModuleObject.pauseInstantiation).equals("afterCompletion");
      });
    });
  });

  function addALaCarteVfModuleEcompGeneratedNamingTrue(vnfName: string, vfModulesName: string, uuidAndVfModuleName: string): Chainable<any> {
    return cy.getElementByDataTestsId('node-' + vnfName).click({force: true}).then(() => {
      cy.getElementByDataTestsId('node-' + vfModulesName + '-add-btn').click({force: true}).then(() => {
        cy.getElementByDataTestsId('node-' + uuidAndVfModuleName + '-menu-btn')
        .click({force: true}).then(() => {
          cy.getElementByDataTestsId('context-menu-edit').click().then(() => {
            cy.getElementByDataTestsId('form-set').click();
          })
        })
      })
    })
  }

  function bodyOf(xhr: Cypress.WaitXHR) {
    return JSON.parse(JSON.stringify(xhr.request.body));
  }

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


  function pauseOnVfModuleInstantiation(nodeId: string, index: number) {
    cy.drawingBoardTreeOpenContextMenuByElementDataTestId(`${nodeId}`, index)
    .getElementByDataTestsId('context-menu-pause').click({force: true});
  }

  function removePauseInstantiation(nodeId: string, index: number){
    cy.getElementByDataTestsId(nodeId + '-menu-btn')
    .click({force: true}).then(() => {
      cy.wait(500);
      cy.getElementByDataTestsId('context-menu-removePause').click();
    })
  }

});