blob: 6d4c343a7d0f5a27fd4d422fc1c3f367eaa6b9e5 [file] [log] [blame]
Alexey Sandlerc8a3cff2020-05-06 18:58:14 +03001///<reference path="../../../node_modules/cypress/types/index.d.ts"/> / <reference types="Cypress" />
2
3describe('Create Instance page: Pause after vfModule instantiation ', () => {
4
5 beforeEach(() => {
6 cy.clearSessionStorage();
7 cy.setTestApiParamToGR();
8 cy.initVidMock();
9 cy.permissionVidMock();
10 cy.login();
11
12 });
13
14 afterEach(() => {
15 cy.screenshot();
16 });
17
18 it(`Pause on VFModule instantiation: create two vfmodules and pause after a first vfmodule`, function () {
19 cy.readFile('cypress/support/jsonBuilders/mocks/jsons/flags.cypress.json').then((flags) => {
20 cy.server()
21 .route({
22 method: 'GET',
23 delay: 0,
24 status: 200,
25 url: Cypress.config('baseUrl') + "/flags**",
26 response: flags
27 }).as('initFlags');
28 });
29
30 cy.readFile('cypress/support/jsonBuilders/mocks/jsons/reduxModelOneVnfAndTwoVfmodulesInstanceOneVnf.json').then((reduxState) => {
31
32 cy.setReduxState(<any>reduxState);
33 cy.openIframe('app/ui/#/servicePlanning?serviceModelId=f3862254-8df2-4a0a-8137-0a9fe985860c');
34 const vnfName = "vOCG_1804_VF 0";
35 let vfModulesNames: Array<string> = [
36 'vocg_1804_vf0..Vocg1804Vf..base_ocg..module-0',
37 'vocg_1804_vf0..Vocg1804Vf..ocgapp_004..module-11'
38 ];
39 const uuidAndVfModuleNames: Array<string> = [
40 '815db6e5-bdfd-4cb6-9575-82c36df8747a-vocg_1804_vf0..Vocg1804Vf..base_ocg..module-0',
41 'da10c7fe-cf81-441c-9694-4e9ddf2054d8-vocg_1804_vf0..Vocg1804Vf..ocgapp_004..module-11'
42 ];
43
44 addALaCarteVfModuleEcompGeneratedNamingTrue(vnfName, vfModulesNames[0], uuidAndVfModuleNames[0]);
45 addALaCarteVfModuleEcompGeneratedNamingTrue(vnfName, vfModulesNames[1], uuidAndVfModuleNames[1]);
46 pauseOnVfModuleInstantiation('node-' + uuidAndVfModuleNames[1], 0)
ikram09a65622020-07-22 10:28:15 -040047 pauseOnVfModuleInstantiation('node-' + uuidAndVfModuleNames[0], 0)
48 removePauseInstantiation('node-'+uuidAndVfModuleNames[0], 0)
Alexey Sandlerc8a3cff2020-05-06 18:58:14 +030049 mockAsyncBulkResponse();
50 cy.getDrawingBoardDeployBtn().click();
51
52 cy.wait('@expectedPostAsyncInstantiation')
53 .then(xhr => {
54 let vfModules = bodyOf(xhr).vnfs['vOCG_1804_VF 0'].vfModules;
55
56 let unPausedVModule = vfModules[vfModulesNames[0]];
57 const unPausedVModuleObject = unPausedVModule[Object.keys(unPausedVModule)[0]];
ikram09a65622020-07-22 10:28:15 -040058 expect(unPausedVModuleObject.pauseInstantiation).equals(null);
Alexey Sandlerc8a3cff2020-05-06 18:58:14 +030059
60 let pausedVModule = vfModules[vfModulesNames[1]];
61 const pausedVModuleObject = pausedVModule[Object.keys(pausedVModule)[0]];
62 expect(pausedVModuleObject.pauseInstantiation).equals("afterCompletion");
63 });
64 });
65 });
66
67 function addALaCarteVfModuleEcompGeneratedNamingTrue(vnfName: string, vfModulesName: string, uuidAndVfModuleName: string): Chainable<any> {
68 return cy.getElementByDataTestsId('node-' + vnfName).click({force: true}).then(() => {
69 cy.getElementByDataTestsId('node-' + vfModulesName + '-add-btn').click({force: true}).then(() => {
70 cy.getElementByDataTestsId('node-' + uuidAndVfModuleName + '-menu-btn')
71 .click({force: true}).then(() => {
72 cy.getElementByDataTestsId('context-menu-edit').click().then(() => {
73 cy.getElementByDataTestsId('form-set').click();
74 })
75 })
76 })
77 })
78 }
79
80 function bodyOf(xhr: Cypress.WaitXHR) {
81 return JSON.parse(JSON.stringify(xhr.request.body));
82 }
83
84 function mockAsyncBulkResponse() {
85 cy.server().route({
86 url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
87 method: 'POST',
88 status: 200,
89 response: "[]",
90 }).as("expectedPostAsyncInstantiation");
91 }
92
93
94 function pauseOnVfModuleInstantiation(nodeId: string, index: number) {
95 cy.drawingBoardTreeOpenContextMenuByElementDataTestId(`${nodeId}`, index)
96 .getElementByDataTestsId('context-menu-pause').click({force: true});
97 }
98
ikram09a65622020-07-22 10:28:15 -040099 function removePauseInstantiation(nodeId: string, index: number){
100 cy.getElementByDataTestsId(nodeId + '-menu-btn')
101 .click({force: true}).then(() => {
102 cy.wait(500);
103 cy.getElementByDataTestsId('context-menu-removePause').click();
104 })
105 }
106
Alexey Sandlerc8a3cff2020-05-06 18:58:14 +0300107});