aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/cypress/support/application
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2018-08-29 17:01:32 +0300
committerIttay Stern <ittay.stern@att.com>2019-02-18 18:35:30 +0200
commit6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 (patch)
tree936005c364dc5a7264d6304d4777c3d83494db22 /vid-webpack-master/cypress/support/application
parent67d99f816cc583643c35193197594cf78d8ce60a (diff)
merge from ecomp a88f0072 - Modern UI
Issue-ID: VID-378 Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/cypress/support/application')
-rw-r--r--vid-webpack-master/cypress/support/application/application.session.actions.ts57
1 files changed, 56 insertions, 1 deletions
diff --git a/vid-webpack-master/cypress/support/application/application.session.actions.ts b/vid-webpack-master/cypress/support/application/application.session.actions.ts
index 490016bf6..19f6881f6 100644
--- a/vid-webpack-master/cypress/support/application/application.session.actions.ts
+++ b/vid-webpack-master/cypress/support/application/application.session.actions.ts
@@ -1,6 +1,10 @@
declare namespace Cypress {
interface Chainable {
setReduxState : typeof setReduxState;
+ getReduxState : typeof getReduxState;
+ setTestApiParamToGR: typeof setTestApiParamToGR;
+ setTestApiParamToVNF: typeof setTestApiParamToVNF;
+ buildReduxStateWithServiceRespone: typeof buildReduxStateWithServiceRespone;
}
}
@@ -14,8 +18,59 @@ function setReduxState(state?: string) : void {
});
});
}
+function getReduxState(): Chainable<any> {
+ return cy.window().then((win) => {
+ let stateRaw = win.sessionStorage.getItem('reduxState');
+ return JSON.parse(stateRaw ? stateRaw : '{}');
+ });
+}
+
+function setTestApiParamToGR() : void {
+ cy.window().then((win) => {
+ win.sessionStorage.setItem('msoRequestParametersTestApiValue', 'GR_API');
+ });
+}
+
+function setTestApiParamToVNF() : void {
+ cy.window().then((win) => {
+ win.sessionStorage.setItem('msoRequestParametersTestApiValue', 'VNF_API');
+ });
+}
+function updateObject(obj: any, key: string, val: any, value:any) {
+ return JSON.parse(JSON.stringify(obj)
+ .replace(new RegExp(`"${key}":"${val}"`), `"${key}":"${value}"`))
+}
+function buildReduxStateWithServiceRespone(res: any, serviceId:string, isEcompGeneratedNaming:boolean) :void {
+ res = updateObject(res, "ecomp_generated_naming", !isEcompGeneratedNaming, isEcompGeneratedNaming);
+ cy.window().then((win) => {
+ win.sessionStorage.setItem('reduxState', JSON.stringify({
+ "global": {
+ "name": null
+ },
+ "service": {
+ "serviceHierarchy": {
+ [serviceId] : res
+ },
+ "serviceInstance": {
+ [serviceId]: {
+ "existingVNFCounterMap": {},
+ "existingVnfGroupCounterMap": {},
+ "existingNetworksCounterMap": {},
+ "vnfs": {},
+ "vnfGroups": {},
+ "isEcompGeneratedNaming": isEcompGeneratedNaming,
+ "existingNames": {}
+ }
+ }
+ }
+ }));
+ });
+}
Cypress.Commands.add('setReduxState', setReduxState);
-
+Cypress.Commands.add('getReduxState', getReduxState);
+Cypress.Commands.add('setTestApiParamToGR', setTestApiParamToGR);
+Cypress.Commands.add('setTestApiParamToVNF',setTestApiParamToVNF);
+Cypress.Commands.add('buildReduxStateWithServiceRespone', buildReduxStateWithServiceRespone);