aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/cypress/support/steps/fill.vfModule.step.ts
blob: b87e773f9b8fe96bf61223502737d24d7e3b99f0 (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
declare namespace Cypress {
  interface Chainable {
    fillVFModulePopup: typeof fillVFModulePopup;
    addALaCarteVfModule: typeof addALaCarteVfModule;
    addMacroVfModule: typeof addMacroVfModule;
  }
}

function fillVFModulePopup(vnfName: string, vfModuleName: string, instanceName: string, lcpRegion: string, tenant: string, rollback: boolean, sdncPreLoad: boolean): Chainable<any> {
  cy.getElementByDataTestsId('node-' + vnfName).click({force: true});
  cy.getElementByDataTestsId('node-' + vfModuleName + '-add-btn').click({force: true});
  cy.getElementByDataTestsId('instanceName').last().type(instanceName, {force: true});
  cy.getElementByDataTestsId('lcpRegion').last().select(lcpRegion);
  cy.getElementByDataTestsId('tenant').last().select(tenant);
  cy.getElementByDataTestsId('lcpRegion').last().select(lcpRegion);
  cy.getElementByDataTestsId('rollback').last().select(String(rollback));
  if (sdncPreLoad) {
    cy.getElementByDataTestsId('sdncPreLoad').last().check();
  }
  return cy.getElementByDataTestsId('form-set').last().click({force: true}).then((done) => {
    return done;
  });

}

function addMacroVfModule(vnfName: string, vfModuleName: string, instanceName: string): Chainable<any> {
  return cy.getElementByDataTestsId('node-' + vnfName).click({force: true}).then(() => {
    cy.getElementByDataTestsId('node-' + vfModuleName + '-add-btn').click({force: true}).then(() => {
      cy.getElementByDataTestsId('instanceName').clear().type(instanceName, {force: true}).then(() => {
        cy.getElementByDataTestsId('form-set').click({force: true});
      })
    })
  });
}

function addALaCarteVfModule(vnfName: string, vfModuleName: string, instanceName: string, lcpRegion: string, legacyRegion: string,
                     tenant: string, rollback: boolean, sdncPreLoad: boolean, deleteVgName: boolean): Chainable<any> {
  return cy.getElementByDataTestsId('node-' + vnfName).click({force: true}).then(() => {
    cy.getElementByDataTestsId('node-' + vfModuleName + '-add-btn').click({force: true}).then(() => {
      cy.getElementByDataTestsId('instanceName').clear().type(instanceName, {force: true}).then(() => {
        if (deleteVgName) {
          cy.getElementByDataTestsId('volumeGroupName').clear();
        }
      }).then(() => {
        cy.selectDropdownOptionByText('lcpRegion', lcpRegion);
        if (legacyRegion) {
          cy.typeToInput("lcpRegionText", legacyRegion);
        }
        cy.selectDropdownOptionByText('tenant', tenant);
        cy.selectDropdownOptionByText('rollback', String(rollback));
        if (sdncPreLoad) {
          cy.getElementByDataTestsId('sdncPreLoad').check();
        }
        cy.getElementByDataTestsId('form-set').click({force: true});
      });
    });
  });
}

Cypress.Commands.add('fillVFModulePopup', fillVFModulePopup);
Cypress.Commands.add('addALaCarteVfModule', addALaCarteVfModule);
Cypress.Commands.add('addMacroVfModule', addMacroVfModule);