From 3f216a5ba38d70c193256f05c634093da9599984 Mon Sep 17 00:00:00 2001 From: Yoav Schneiderman Date: Wed, 22 Jan 2020 11:07:00 +0200 Subject: When feature toggle is active then SDNC preload files is enable. Issue-ID: VID-752 Change-Id: I96ef914bfe37d82da20085227b930523fcdba8fc Signed-off-by: Yoav Schneiderman --- vid-webpack-master/cypress/support/index.js | 5 ++- .../jsonBuilders/mocks/jsons/flags.cypress.json | 2 +- .../drawingBoard/drawingBoardRecreate.steps.ts | 52 ++++++++++++++++++++++ .../support/steps/drawingBoard/general.steps.ts | 37 ++++++++++++++- .../uploadFiles/sdncPreLoadFileExample.json | 3 ++ 5 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 vid-webpack-master/cypress/support/steps/drawingBoard/drawingBoardRecreate.steps.ts create mode 100644 vid-webpack-master/cypress/support/uploadFiles/sdncPreLoadFileExample.json (limited to 'vid-webpack-master/cypress/support') diff --git a/vid-webpack-master/cypress/support/index.js b/vid-webpack-master/cypress/support/index.js index 5062f5100..d9e64c0f5 100644 --- a/vid-webpack-master/cypress/support/index.js +++ b/vid-webpack-master/cypress/support/index.js @@ -15,6 +15,7 @@ // Import commands.js using ES2015 syntax: import './commands'; +import 'cypress-file-upload'; import './steps/login.step'; import './steps/fill.service.popup.step'; import './steps/fill.vnf.popup.step'; @@ -36,12 +37,14 @@ import './steps/drawingBoard/drawingBoardModel.steps'; import './steps/drawingBoard/drawingBoardTree.steps'; import './steps/genericForm/genericFormAction.steps'; import './steps/genericForm/popupViewport.step'; -import './steps/drawingBoard/drawingBoardHeader.steps'; import './steps/drawingBoard/general.steps'; +import './steps/drawingBoard/drawingBoardRecreate.steps'; +import './steps/drawingBoard/drawingBoardHeader.steps'; import './steps/general/clickOutside.step'; import './steps/drawingBoard/drawingBoardComponentInfo.steps'; import './steps/genericForm/checkPopover.step'; + // Alternatively you can use CommonJS syntax: // require('./commands') diff --git a/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/flags.cypress.json b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/flags.cypress.json index bd9fb9025..e2b9d8ad7 100644 --- a/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/flags.cypress.json +++ b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/flags.cypress.json @@ -23,5 +23,5 @@ "FLAG_2004_INSTANTIATION_TEMPLATES_POPUP" : false, "FLAG_2002_UNLIMITED_MAX" : true, "FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE": true, - "FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY": true + "FLAG_2006_VFM_SDNC_PRELOAD_FILES" : true } diff --git a/vid-webpack-master/cypress/support/steps/drawingBoard/drawingBoardRecreate.steps.ts b/vid-webpack-master/cypress/support/steps/drawingBoard/drawingBoardRecreate.steps.ts new file mode 100644 index 000000000..16f418bc9 --- /dev/null +++ b/vid-webpack-master/cypress/support/steps/drawingBoard/drawingBoardRecreate.steps.ts @@ -0,0 +1,52 @@ +declare namespace Cypress { + interface Chainable { + loadDrawingBoardWithRecreateMode: typeof loadDrawingBoardWithRecreateMode , + loadDrawingBoardWithRecreateModeNetwork: typeof loadDrawingBoardWithRecreateModeNetwork, + loadDrawingBoardWithRecreateModeInternal: typeof loadDrawingBoardWithRecreateModeInternal + } +} + +function loadDrawingBoardWithRecreateMode(templateWithVnfSetup : any) { + cy.loadDrawingBoardWithRecreateModeInternal( + '../../' + templateWithVnfSetup.instanceTemplateFile, + templateWithVnfSetup.serviceModelId, + templateWithVnfSetup.serviceModelFile); +} + +function loadDrawingBoardWithRecreateModeNetwork(templateWithNetworkSetup : any) { + cy.loadDrawingBoardWithRecreateModeInternal( + '../../' + templateWithNetworkSetup.instanceTemplateFile, + templateWithNetworkSetup.serviceModelId, + templateWithNetworkSetup.serviceModelFile); +} + +function loadDrawingBoardWithRecreateModeInternal(instanceTemplate: string, serviceModelIdToLoad: any, serviceModel: string) { + const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b"; + + const drawingBoardAction = `RECREATE`; + const templateTopologyEndpoint = "templateTopology"; + cy.route(`**/rest/models/services/${serviceModelIdToLoad}`, + 'fixture:' + serviceModel) + .as('serviceModel'); + + cy.route(`**/instantiationTemplates/${templateTopologyEndpoint}/${templateUuid}`, + 'fixture:' + instanceTemplate) + .as('templateTopology'); + + // When... + + cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` + + `?jobId=${templateUuid}` + + `&serviceModelId=${serviceModelIdToLoad}`); + + cy.wait('@serviceModel'); + cy.wait('@templateTopology'); +} + + + + + +Cypress.Commands.add('loadDrawingBoardWithRecreateMode', loadDrawingBoardWithRecreateMode); +Cypress.Commands.add('loadDrawingBoardWithRecreateModeNetwork', loadDrawingBoardWithRecreateModeNetwork); +Cypress.Commands.add('loadDrawingBoardWithRecreateModeInternal', loadDrawingBoardWithRecreateModeInternal); diff --git a/vid-webpack-master/cypress/support/steps/drawingBoard/general.steps.ts b/vid-webpack-master/cypress/support/steps/drawingBoard/general.steps.ts index 8d2bb8a24..797fff095 100644 --- a/vid-webpack-master/cypress/support/steps/drawingBoard/general.steps.ts +++ b/vid-webpack-master/cypress/support/steps/drawingBoard/general.steps.ts @@ -1,7 +1,10 @@ declare namespace Cypress { interface Chainable { updateServiceShouldNotOverrideChild: typeof updateServiceShouldNotOverrideChild - openServiceContextMenu: typeof openServiceContextMenu + openServiceContextMenu: typeof openServiceContextMenu, + drawingBoardTreeClickOnContextMenuOptionByName : typeof drawingBoardTreeClickOnContextMenuOptionByName, + nodeAction: typeof nodeAction, + editNode : typeof editNode } } @@ -18,7 +21,6 @@ function updateServiceShouldNotOverrideChild() : void { }); }); }); - } @@ -26,5 +28,36 @@ function openServiceContextMenu() : Chainable { return cy.getElementByDataTestsId('openMenuBtn').click({force: true}); } +function nodeAction(dataTestId: string, action: string, index ?: number) { + return cy.drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId, index) + .drawingBoardTreeClickOnContextMenuOptionByName(action) +} + +function drawingBoardTreeClickOnContextMenuOptionByName(optionName : string) : Chainable { + switch (optionName) { + case 'Duplicate': + return cy.getElementByDataTestsId('context-menu-duplicate').click({force : true}); + case 'Remove': + return cy.getElementByDataTestsId('context-menu-remove').click({force : true}); + case 'Edit': + return cy.getElementByDataTestsId('context-menu-edit').click({force : true}); + case 'Delete': + return cy.getElementByDataTestsId('context-menu-delete').trigger('mouseover').click(); + case 'Upgrade': + return cy.getElementByDataTestsId('context-menu-upgrade').trigger('mouseover').click(); + case 'Undo Upgrade': + return cy.getElementByDataTestsId('context-menu-undoUpgrade').trigger('mouseover').click(); + default: + return cy.getElementByDataTestsId('context-menu-duplicate').click({force : true}); + } +} + +function editNode(dataTestId: string, index ?: number) { + return cy.nodeAction(dataTestId, 'Edit', index); +} + Cypress.Commands.add('updateServiceShouldNotOverrideChild', updateServiceShouldNotOverrideChild); Cypress.Commands.add('openServiceContextMenu', openServiceContextMenu); +Cypress.Commands.add('drawingBoardTreeClickOnContextMenuOptionByName', drawingBoardTreeClickOnContextMenuOptionByName); +Cypress.Commands.add('nodeAction', nodeAction); +Cypress.Commands.add('editNode', editNode); diff --git a/vid-webpack-master/cypress/support/uploadFiles/sdncPreLoadFileExample.json b/vid-webpack-master/cypress/support/uploadFiles/sdncPreLoadFileExample.json new file mode 100644 index 000000000..c317c4183 --- /dev/null +++ b/vid-webpack-master/cypress/support/uploadFiles/sdncPreLoadFileExample.json @@ -0,0 +1,3 @@ +{ + "comment" : "invalid file, just for upload mock file" +} -- cgit 1.2.3-korg