Introduce cy.clearSessionStorage

Issue-ID: VID-647

Change-Id: I51471f736577599c1ace8e330a4db089deccc8ca
Signed-off-by: Ittay Stern <ittay.stern@att.com>
diff --git a/vid-webpack-master/cypress/integration/iFrames/ala-carte.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/ala-carte.e2e.ts
index 5c6d28e..57c6732 100644
--- a/vid-webpack-master/cypress/integration/iFrames/ala-carte.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/ala-carte.e2e.ts
@@ -14,8 +14,7 @@
     const CONFIRM_BUTTON: string = 'confirmButton';
 
     beforeEach(() => {
-      cy.window().then((win) => {
-        win.sessionStorage.clear();
+        cy.clearSessionStorage();
         cy.setReduxState();
         cy.preventErrorsOnLoading();
         cy.initAAIMock();
@@ -24,7 +23,6 @@
         cy.initAlaCarteService();
         cy.initZones();
         cy.login();
-      });
     });
 
     afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/auditInfo.modal.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/auditInfo.modal.e2e.ts
index 77eca91..ee147a9 100644
--- a/vid-webpack-master/cypress/integration/iFrames/auditInfo.modal.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/auditInfo.modal.e2e.ts
@@ -9,8 +9,7 @@
     var jsonBuilderInstantiationBuilder: JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
     var jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
     beforeEach(() => {
-      cy.window().then((win) => {
-        win.sessionStorage.clear();
+        cy.clearSessionStorage();
         cy.setReduxState();
         cy.preventErrorsOnLoading();
         jsonBuilderInstantiationBuilder.basicMock('cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json',
@@ -19,7 +18,6 @@
         cy.initVidMock();
         cy.initAsyncInstantiation();
         cy.login();
-      })
     });
 
     afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/browse-sdc.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/browse-sdc.e2e.ts
index ff43936..b3ef7f0 100644
--- a/vid-webpack-master/cypress/integration/iFrames/browse-sdc.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/browse-sdc.e2e.ts
@@ -8,15 +8,13 @@
 
 
     beforeEach(() => {
-      cy.window().then((win) => {
-        win.sessionStorage.clear();
+        cy.clearSessionStorage();
         cy.preventErrorsOnLoading();
         cy.initAAIMock();
         cy.initVidMock();
         cy.initZones();
         cy.login();
         cy.visit("welcome.htm")
-      });
     });
 
     afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/collectionResource.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/collectionResource.e2e.ts
index d598713..a9649fa 100644
--- a/vid-webpack-master/cypress/integration/iFrames/collectionResource.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/collectionResource.e2e.ts
@@ -8,13 +8,11 @@
   let jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
   const serviceModelId: string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
       cy.initVidMock();
       cy.login();
-    });
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/drawingBoard.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/drawingBoard.e2e.ts
index a9cddfc..e379f78 100644
--- a/vid-webpack-master/cypress/integration/iFrames/drawingBoard.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/drawingBoard.e2e.ts
@@ -4,15 +4,13 @@
 
 describe('Drawing board', function () {
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.setReduxState();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
       cy.initVidMock();
       cy.initActiveNetworks();
       cy.login();
-    });
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/instantiationStatus.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/instantiationStatus.e2e.ts
index 90dbcdd..6abd6a3 100644
--- a/vid-webpack-master/cypress/integration/iFrames/instantiationStatus.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/instantiationStatus.e2e.ts
@@ -3,15 +3,13 @@
 
 import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
 import {AsyncInstantiationModel} from '../../support/jsonBuilders/models/asyncInstantiation.model';
-import {ServiceModel} from "../../support/jsonBuilders/models/service.model";
 
 describe('Instantiation status', function () {
   var jsonBuilderInstantiationBuilder : JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
   var asyncRes: Array<any>;
 
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.setReduxState();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
@@ -23,7 +21,6 @@
             return res;
       });
       cy.login();
-    })
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/network.popup.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/network.popup.e2e.ts
index 387f347..8768e34 100644
--- a/vid-webpack-master/cypress/integration/iFrames/network.popup.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/network.popup.e2e.ts
@@ -8,8 +8,7 @@
   var jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
 
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.setReduxState();
       cy.preventErrorsOnLoading();
       cy.permissionVidMock();
@@ -17,7 +16,6 @@
       cy.initAAIMock();
       cy.initVidMock();
       cy.login();
-    })
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/permission.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/permission.e2e.ts
index f14bc1b..22460a0 100644
--- a/vid-webpack-master/cypress/integration/iFrames/permission.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/permission.e2e.ts
@@ -6,15 +6,11 @@
   var jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
 
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
       cy.initVidMock();
       cy.login();
-
-
-    });
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/pnf.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/pnf.e2e.ts
index a13094a..0e10618 100644
--- a/vid-webpack-master/cypress/integration/iFrames/pnf.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/pnf.e2e.ts
@@ -3,14 +3,12 @@
 
 describe('Drawing board: PNF ',  function()  {
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.setReduxState();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
       cy.initVidMock();
       cy.login();
-    });
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/retry.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/retry.e2e.ts
index 60c07f4..e544720 100644
--- a/vid-webpack-master/cypress/integration/iFrames/retry.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/retry.e2e.ts
@@ -6,8 +6,7 @@
 describe('Retry Page', function () {
   let jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
       jsonBuilderAndMock.basicMock('cypress/support/jsonBuilders/mocks/jsons/serviceModels/ecompNamingFalseModel.json',
@@ -16,7 +15,6 @@
       cy.initZones();
       cy.permissionVidMock();
       cy.login();
-    });
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/searchExistingInstance.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/searchExistingInstance.e2e.ts
index 2617354..e4fe593 100644
--- a/vid-webpack-master/cypress/integration/iFrames/searchExistingInstance.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/searchExistingInstance.e2e.ts
@@ -7,15 +7,13 @@
   var jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
 
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
       cy.initVidMock();
       cy.initZones();
       cy.permissionVidMock();
       cy.login();
-    });
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/service.popup.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/service.popup.e2e.ts
index d95cfdb..d1d41d0 100644
--- a/vid-webpack-master/cypress/integration/iFrames/service.popup.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/service.popup.e2e.ts
@@ -3,14 +3,12 @@
   describe('basic UI tests', () => {
 
     beforeEach(() => {
-      cy.window().then((win) => {
-        win.sessionStorage.clear();
+        cy.clearSessionStorage();
         cy.setReduxState();
         cy.preventErrorsOnLoading();
         cy.initAAIMock();
         cy.initVidMock();
         cy.login();
-      })
     });
 
     afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts
index 79f6a8d..40ba258 100644
--- a/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts
@@ -17,9 +17,7 @@
     let jsonBuilderAaiServiceInstances: JsonBuilder<AaiServiceInstancesModel> = new JsonBuilder<AaiServiceInstancesModel>();
     let jsonBuilderEmpty: JsonBuilder<Object> = new JsonBuilder<Object>();
     beforeEach(() => {
-      cy.window().then((win) => {
-        win.sessionStorage.clear();
-      });
+      cy.clearSessionStorage();
       cy.readFile('cypress/support/jsonBuilders/mocks/jsons/basicService.json').then((res) => {
         jsonBuilderAAIService.basicJson(
           res,
diff --git a/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts
index 0d94e60..f111189 100644
--- a/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts
@@ -47,9 +47,7 @@
     let jsonBuilderAaiServiceInstances: JsonBuilder<AaiServiceInstancesModel> = new JsonBuilder<AaiServiceInstancesModel>();
 
     beforeEach(() => {
-      cy.window().then((win) => {
-        win.sessionStorage.clear();
-      });
+      cy.clearSessionStorage();
       cy.readFile('cypress/support/jsonBuilders/mocks/jsons/basicService.json').then((res) => {
         jsonBuilderAAIService.basicJson(
           res,
@@ -130,7 +128,7 @@
   describe('More UI tests', () => {
 
     beforeEach(() => {
-      cy.window().then((win) => {win.sessionStorage.clear();});
+      cy.clearSessionStorage();
       cy.setTestApiParamToVNF();
       cy.initVidMock();
       cy.login();
diff --git a/vid-webpack-master/cypress/integration/iFrames/viewOnlyDrawingBoard.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/viewOnlyDrawingBoard.e2e.ts
index 26d206d..688d42e 100644
--- a/vid-webpack-master/cypress/integration/iFrames/viewOnlyDrawingBoard.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/viewOnlyDrawingBoard.e2e.ts
@@ -42,8 +42,7 @@
   const _VIEW = "VIEW";
 
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
       cy.initVidMock();
@@ -51,7 +50,6 @@
       cy.initZones();
       cy.permissionVidMock();
       cy.login();
-    });
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/vnf.popup.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/vnf.popup.e2e.ts
index 2c98500..a014400 100644
--- a/vid-webpack-master/cypress/integration/iFrames/vnf.popup.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/vnf.popup.e2e.ts
@@ -4,14 +4,12 @@
   describe('basic UI tests', () => {
 
     beforeEach(() => {
-      cy.window().then((win) => {
-        win.sessionStorage.clear();
+        cy.clearSessionStorage();
         cy.setReduxState();
         cy.preventErrorsOnLoading();
         cy.initAAIMock();
         cy.initVidMock();
         cy.login();
-      })
     });
 
     afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/vnf.update.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/vnf.update.e2e.ts
index 7c942ea..a314424 100644
--- a/vid-webpack-master/cypress/integration/iFrames/vnf.update.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/vnf.update.e2e.ts
@@ -9,15 +9,13 @@
   let jsonBuilderInstantiationBuilder: JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
 
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
       cy.initVidMock();
       cy.initZones();
       cy.permissionVidMock();
       cy.login();
-    });
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/vnfGroups.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/vnfGroups.e2e.ts
index cd21f4e..dc1b4bb 100644
--- a/vid-webpack-master/cypress/integration/iFrames/vnfGroups.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/vnfGroups.e2e.ts
@@ -6,8 +6,7 @@
   var jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
 
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.setReduxState();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
@@ -15,7 +14,6 @@
       cy.permissionVidMock();
       cy.setTestApiParamToVNF();
       cy.login();
-    });
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/iFrames/vrf.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/vrf.e2e.ts
index 717d3a9..6700ff4 100644
--- a/vid-webpack-master/cypress/integration/iFrames/vrf.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/vrf.e2e.ts
@@ -6,8 +6,7 @@
   var jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
 
   beforeEach(() => {
-    cy.window().then((win) => {
-      win.sessionStorage.clear();
+      cy.clearSessionStorage();
       cy.setReduxState();
       cy.preventErrorsOnLoading();
       cy.initAAIMock();
@@ -22,7 +21,6 @@
         status: 200,
         response: "[]",
       }).as("expectedPostAsyncInstantiation");
-    });
   });
 
   afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/shared/error.message.popup.e2e.ts b/vid-webpack-master/cypress/integration/shared/error.message.popup.e2e.ts
index 55f90cc..6bbbd7a 100644
--- a/vid-webpack-master/cypress/integration/shared/error.message.popup.e2e.ts
+++ b/vid-webpack-master/cypress/integration/shared/error.message.popup.e2e.ts
@@ -1,21 +1,19 @@
 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
 /// <reference types="Cypress" />
 
-import { JsonBuilder } from '../../support/jsonBuilders/jsonBuilder';
-import { AsyncInstantiationModel } from '../../support/jsonBuilders/models/asyncInstantiation.model';
+import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
+import {AsyncInstantiationModel} from '../../support/jsonBuilders/models/asyncInstantiation.model';
 
 describe('Error message popup', function () {
   describe('show error on status 500', () => {
     var jsonBuilderInstantiationBuilder : JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
     beforeEach(() => {
-      cy.window().then((win) => {
-        win.sessionStorage.clear();
+        cy.clearSessionStorage();
         cy.setReduxState();
         cy.preventErrorsOnLoading();
         cy.initAAIMock();
         cy.initVidMock();
         cy.login();
-      })
     });
 
     afterEach(() => {
diff --git a/vid-webpack-master/cypress/integration/shared/spinner.e2e.ts b/vid-webpack-master/cypress/integration/shared/spinner.e2e.ts
index cd14a12..51e084b 100644
--- a/vid-webpack-master/cypress/integration/shared/spinner.e2e.ts
+++ b/vid-webpack-master/cypress/integration/shared/spinner.e2e.ts
@@ -1,20 +1,18 @@
 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
 /// <reference types="Cypress" />
-import { JsonBuilder } from '../../support/jsonBuilders/jsonBuilder';
-import { AsyncInstantiationModel } from '../../support/jsonBuilders/models/asyncInstantiation.model';
+import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
+import {AsyncInstantiationModel} from '../../support/jsonBuilders/models/asyncInstantiation.model';
 
 describe('Spinner', function () {
   describe('spinner', () => {
     var jsonBuilderInstantiationBuilder : JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
     beforeEach(() => {
-      cy.window().then((win) => {
-        win.sessionStorage.clear();
+        cy.clearSessionStorage();
         cy.setReduxState();
         cy.preventErrorsOnLoading();
         cy.initAAIMock();
         cy.initVidMock();
         cy.login();
-      })
     });
 
     afterEach(() => {
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 42d4d67..c054b26 100644
--- a/vid-webpack-master/cypress/support/application/application.session.actions.ts
+++ b/vid-webpack-master/cypress/support/application/application.session.actions.ts
@@ -2,6 +2,7 @@
   interface Chainable {
     setReduxState : typeof setReduxState;
     getReduxState : typeof getReduxState;
+    clearSessionStorage: typeof clearSessionStorage;
     setTestApiParamToGR: typeof setTestApiParamToGR;
     setTestApiParamToVNF: typeof setTestApiParamToVNF;
     buildReduxStateWithServiceRespone: typeof buildReduxStateWithServiceRespone;
@@ -25,6 +26,12 @@
   });
 }
 
+function clearSessionStorage() : void {
+  cy.window().then((win) => {
+    win.sessionStorage.clear();
+  });
+}
+
 function setTestApiParamToGR() : void {
   cy.window().then((win) => {
     win.sessionStorage.setItem('msoRequestParametersTestApiValue', 'GR_API');
@@ -72,6 +79,7 @@
 
 Cypress.Commands.add('setReduxState', setReduxState);
 Cypress.Commands.add('getReduxState', getReduxState);
+Cypress.Commands.add('clearSessionStorage', clearSessionStorage);
 Cypress.Commands.add('setTestApiParamToGR', setTestApiParamToGR);
 Cypress.Commands.add('setTestApiParamToVNF',setTestApiParamToVNF);
 Cypress.Commands.add('buildReduxStateWithServiceRespone', buildReduxStateWithServiceRespone);