1 declare namespace Cypress {
3 setReduxState : typeof setReduxState;
4 getReduxState : typeof getReduxState;
5 clearSessionStorage: typeof clearSessionStorage;
6 setTestApiParamToGR: typeof setTestApiParamToGR;
7 setTestApiParamToVNF: typeof setTestApiParamToVNF;
8 buildReduxStateWithServiceRespone: typeof buildReduxStateWithServiceRespone;
12 /**********************************
13 Type to input with id some text
14 *********************************/
15 function setReduxState(state?: string) : void {
16 cy.readFile('cypress/support/jsonBuilders/mocks/jsons/basicRedux.json').then((res) => {
17 cy.window().then((win) => {
18 win.sessionStorage.setItem('reduxState', JSON.stringify(state ? state : res));
22 function getReduxState(): Chainable<any> {
23 return cy.window().then((win) => {
24 let stateRaw = win.sessionStorage.getItem('reduxState');
25 return JSON.parse(stateRaw ? stateRaw : '{}');
29 function clearSessionStorage() : void {
30 cy.window().then((win) => {
31 win.sessionStorage.clear();
35 function setTestApiParamToGR() : void {
36 cy.window().then((win) => {
37 win.sessionStorage.setItem('msoRequestParametersTestApiValue', 'GR_API');
41 function setTestApiParamToVNF() : void {
42 cy.window().then((win) => {
43 win.sessionStorage.setItem('msoRequestParametersTestApiValue', 'VNF_API');
47 function updateObject(obj: any, key: string, val: any, value:any) {
48 return JSON.parse(JSON.stringify(obj)
49 .replace(new RegExp(`"${key}":"${val}"`), `"${key}":"${value}"`))
52 function buildReduxStateWithServiceRespone(res: any, serviceId:string, isEcompGeneratedNaming:boolean) :void {
53 res = updateObject(res, "ecomp_generated_naming", !isEcompGeneratedNaming, isEcompGeneratedNaming);
54 cy.window().then((win) => {
55 win.sessionStorage.setItem('reduxState', JSON.stringify({
65 "existingVNFCounterMap": {},
66 "existingVnfGroupCounterMap": {},
67 "existingNetworksCounterMap": {},
70 "isEcompGeneratedNaming": isEcompGeneratedNaming,
72 "vidNotions": res.service.vidNotions
80 Cypress.Commands.add('setReduxState', setReduxState);
81 Cypress.Commands.add('getReduxState', getReduxState);
82 Cypress.Commands.add('clearSessionStorage', clearSessionStorage);
83 Cypress.Commands.add('setTestApiParamToGR', setTestApiParamToGR);
84 Cypress.Commands.add('setTestApiParamToVNF',setTestApiParamToVNF);
85 Cypress.Commands.add('buildReduxStateWithServiceRespone', buildReduxStateWithServiceRespone);