///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
import {ServiceModel} from '../../support/jsonBuilders/models/service.model';
import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';

describe('Vnf Groups', function () {
  var jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();

  beforeEach(() => {
    cy.window().then((win) => {
      win.sessionStorage.clear();
      cy.setReduxState();
      cy.preventErrorsOnLoading();
      cy.initAAIMock();
      cy.initVidMock();
      cy.permissionVidMock();
      cy.setTestApiParamToVNF();
      cy.login();
    });
  });

  afterEach(() => {
    cy.screenshot();
  });

  describe('Vnf Group model basic view', function () {

      it('Vnf group open new view edit', function () {
        const instanceName: string = 'ABC';
        const groupName = 'groupingservicefortest..ResourceInstanceGroup..0';
        const nodeId = 'daeb6568-cef8-417f-9075-ed259ce59f48';
        const serviceId = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';
        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + "/rest/models/services/" + serviceId,
            200,
            0,
            "ServiceWithVnfGroup",
          );

          cy.buildReduxStateWithServiceRespone(res, serviceId, false);
          cy.openIframe('app/ui/#/servicePlanning?serviceModelId=' + serviceId);
          cy.getElementByDataTestsId('node-' + groupName).find(`[data-tests-id='node-type-indicator']`).contains('G');
          cy.getElementByDataTestsId('node-' + groupName).contains('' + groupName);
          cy.getElementByDataTestsId('node-' + groupName + '-add-btn').get('i').should('have.class', 'fa-plus-circle');
          cy.getElementByDataTestsId('node-' + groupName + '-add-btn').click({force: true});
          cy.getElementByDataTestsId('instanceName').clear();
          cy.typeToInput('instanceName', instanceName);
          cy.getElementByDataTestsId('form-set').click({force: true}).then(() => {
            cy.getElementByDataTestsId('numberButton').contains('1');
            cy.getElementByDataTestsId('node-' + nodeId + '-' + groupName).contains(instanceName);
            cy.getElementByDataTestsId('node-' + nodeId + '-' + groupName + '-menu-btn')
              .click({force: true});
            cy.getElementByDataTestsId('context-menu-edit').click();
            cy.getElementByDataTestsId('instanceName').clear();
            cy.typeToInput('instanceName', instanceName + instanceName);
            cy.getElementByDataTestsId('form-set').click({force: true}).then(() => {
              cy.getElementByDataTestsId('node-' + nodeId + '-' + groupName + '-menu-btn').click({force: true})
                .getElementByDataTestsId('context-menu-remove').click();
            });
          });
        });
      });

      it('Create new service with vnf group', () => {

        const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';
        const GROUP_NAME_TO_DEPLOY = 'groupingservicefortest..ResourceInstanceGroup..1';
        const NODE_ID = 'c2b300e6-45de-4e5e-abda-3032bee2de56';
        let serviceModel: JSON;
        let basicServiceInstance: JSON;

        cy.server().route({
          url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
          method: 'POST',
          status: 200,
          response: "[]",
        }).as("expectedPostAsyncInstantiation");

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          serviceModel = res;
        });

        cy.readFile('./cypress/support/jsonBuilders/mocks/jsons/vnfGroupBasicServiceInstance.json').then((res) => {
          basicServiceInstance = res;
        });

        cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((reduxRes) => {

          reduxRes.service.serviceHierarchy[SERVICE_MODEL_ID] = serviceModel;
          reduxRes.service.serviceInstance[SERVICE_MODEL_ID] = basicServiceInstance;

          cy.setReduxState(<any>reduxRes);

          cy.openIframe('app/ui/#/servicePlanning?serviceModelId=' + SERVICE_MODEL_ID);
          cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY).find(`[data-tests-id='node-type-indicator']`).contains('G');
          cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY).contains('' + GROUP_NAME_TO_DEPLOY);
          cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY + '-add-btn').get('i').should('have.class', 'fa-plus-circle');
          cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY + '-add-btn').click({force: true});
          cy.getElementByDataTestsId('node-' + NODE_ID + '-' + GROUP_NAME_TO_DEPLOY + '-menu-btn')
            .click({force: true});
          cy.getElementByDataTestsId('context-menu-edit').click();
          cy.getElementByDataTestsId('instanceName').clear();
          cy.typeToInput('instanceName', "ABC");
          cy.getElementByDataTestsId('form-set').click({force: true});
          cy.getElementByDataTestsId('deployBtn').should('have.text', 'DEPLOY').click();
          cy.getElementByDataTestsId('isViewOnly-status-test').contains('IN DESIGN');
          cy.getReduxState().then((state) => {
            const vnfGroup = state.service.serviceInstance[SERVICE_MODEL_ID].vnfGroups[GROUP_NAME_TO_DEPLOY];

            cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
                cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupCreateRequest.json').then((expectedResult) => {
                expectedResult.vnfGroups[GROUP_NAME_TO_DEPLOY].trackById = vnfGroup.trackById;
                cy.deepCompare(xhr.request.body, expectedResult);
              });
            });
          });

        });

      });

      it('Delete vnf group with members', () => {
        cy.initSearchVNFMemebers();
        const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';
        let serviceModel: JSON;
        let basicServiceInstance: JSON;

        cy.server().route({
          url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
          method: 'POST',
          status: 200,
          response: "[]",
        }).as("expectedPostAsyncInstantiation");

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          serviceModel = res;
        });

        cy.readFile('./cypress/support/jsonBuilders/mocks/jsons/vnfGroupBasicServiceInstance.json').then((res) => {
          basicServiceInstance = res;
        });

        cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((reduxRes) => {

          reduxRes.service.serviceHierarchy[SERVICE_MODEL_ID] = serviceModel;
          reduxRes.service.serviceInstance[SERVICE_MODEL_ID] = basicServiceInstance;

          cy.setReduxState(<any>reduxRes);

          cy.openIframe('app/ui/#/servicePlanning?serviceModelId=' + SERVICE_MODEL_ID);
          cy.getElementByDataTestsId('node-groupingservicefortest..ResourceInstanceGroup..0-add-btn').click({force: true});
          removeVnfGroup();
          cy.getElementByDataTestsId('node-groupingservicefortest..ResourceInstanceGroup..0-add-btn').click({force: true});
          cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn')
            .click({force: true});
          cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => {
            cy.get('.allCheckboxAreSelected input').click({force: true});
            cy.getElementByDataTestsId('setMembersBtn').click({force: true})
          });
          cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0').click({force: true});
          removeVnfGroup();
          cy.getElementByDataTestsId('button-remove-group').click({force: true});
          cy.get('#model-actions').should('not.exist');

        });

      });

      it('Vnf group edit mode delete empty service instance', () => {
        const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
        const SERVICE_TYPE: string = "TYLER SILVIA";
        const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
        const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';
        let expectedResult: JSON;

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`,
            200,
            0,
            "ServiceWithVnfGrouping_serviceModel",
          );
        });

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroping_serviceInstance.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`,
            200, 0,
            "serviceWithVnfGroping_serviceInstance",
          )
        });

        cy.server().route({
          url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
          method: 'POST',
          status: 200,
          response: "[]",
        }).as("expectedPostAsyncInstantiation");

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/ServiceWithVnfGroupsDeleteRequest.json').then((res) => {
          expectedResult = res;
        });

        cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
        cy.getElementByDataTestsId('openMenuBtn').click();
        cy.getElementByDataTestsId('context-menu-header-delete-item').should('have.text', 'Delete');
        cy.getElementByDataTestsId('context-menu-header-delete-item').click();
        cy.getElementByDataTestsId('serviceName').should('have.css', 'text-decoration');
        cy.getElementByDataTestsId('openMenuBtn').click();
        cy.getElementByDataTestsId('context-menu-header-delete-item').should('have.text', 'Undo delete');
        cy.getElementByDataTestsId('deployBtn').should('have.text', 'UPDATE').click();

        cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
          cy.deepCompare(xhr.request.body, expectedResult);

        });
      });

      it('Delete service with two vnf groups', () => {
        const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
        const SERVICE_TYPE: string = "TYLER SILVIA";
        const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';
        const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
        let expectedResult: JSON;

        cy.server().route({
          url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
          method: 'POST',
          status: 200,
          response: "[]",
        }).as("expectedPostAsyncInstantiation");

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`,
            200, 0,
            "serviceWithVnfGroupsChildren_serviceInstance",
          )
        });

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`,
            200,
            0,
            "ServiceTreeWithMultipleChildren_serviceModel",
          )
        });

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/deleteServiceWith2VnfGroupsRequest_AndThreeGroupMembers.json').then((expectedResult) => {
          cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
          cy.getElementByDataTestsId('openMenuBtn').click();
          cy.getElementByDataTestsId('context-menu-header-delete-item').should('have.text', 'Delete').click();
          cy.getElementByDataTestsId('deployBtn').should('have.text', 'UPDATE').click();
          cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
            cy.deepCompare(xhr.request.body, expectedResult);
          });
        });
      });

      it(`when open service with group in EDIT mode, service instance is shown as expected - e2e with input and output API's tests"`, function () {
        const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
        const SERVICE_TYPE: string = "TYLER SILVIA";
        const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
        const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';

        cy.server().route({
          url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
          method: 'POST',
          status: 200,
          response: "[]",
        }).as("expectedPostAsyncInstantiation");

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`,
            200,
            0,
            "ServiceTreeWithMultipleChildren_serviceModel",
          )
        });

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`,
            200, 0,
            "serviceWithVnfGroupsChildren_serviceInstance",
          )
        });

        cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);

        /*
        0. title area -> generic stuff
                         instance name
                         orch status
                         service name
        */
        cy.getElementByDataTestsId("serviceInstance").should('have.text', 'Service instance:');
        cy.getElementByDataTestsId("orchStatusLabel").should('have.text', 'Orch Status:');
        // ERROR! cy.getElementByDataTestsId("quantityLabel").should('not.be.visible');
        // ERROR! cy.getElementByDataTestsId("servicesQuantity").should('not.be.visible');

        // specific
        cy.getElementByDataTestsId("serviceName").should('have.text', 'SERVICE_INSTANCE_NAME');
        cy.getElementByDataTestsId("orchStatusValue").should('have.text', 'GARBAGE DATA');
        cy.get('span#service-model-name').contains('Grouping Service for Test');

        // no need to expand anything
        cy.get('available-models-tree').find('.toggle-children').should('not.exist');

        /*
        1. Left tree
        */
        const leftShouldHaves: { [dataTestId: string]: { [dataTestId: string]: string; }; } = {
          'node-groupingservicefortest..ResourceInstanceGroup..0': {
            'node-type-indicator': 'G',
            'node-name': 'groupingservicefortest..ResourceInstanceGroup..0',
            'numberButton': '2',
          },
          'node-groupingservicefortest..ResourceInstanceGroup..1': {
            'node-type-indicator': 'G',
            'node-name': 'groupingservicefortest..ResourceInstanceGroup..1',
            'numberButton': '',
          },
        };
        cy.getElementByDataTestsId('search-left-tree-input').type('group');
        for (let node in leftShouldHaves) {
          cy.getElementByDataTestsId(node).find(`[data-tests-id= '${'node-name'}']`).find('.highlight').eq(0).should('have.text', 'group');

          for (let span in leftShouldHaves[node]) {
            const expected = leftShouldHaves[node][span];
            cy.getElementByDataTestsId(node).find(`[data-tests-id='${span}']`).should(expected ? 'have.text' : 'not.exist', expected);
          }
        }


        /*
        2. Right tree
        */
        const rightShouldHaves: { [dataTestId: string]: { [dataTestId: string]: string; }; } = {
          'node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0:0': {
            'node-type-indicator': 'G',
            'node-name': 'VNF_GROUP1_INSTANCE_NAME',
            'status-property-orchStatus': '',
            'status-property-provStatus': '',
            // 'status-property-inMaint': '', not exists for false in maint
          },
          'node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0:1': {
            'node-type-indicator': 'G',
            'node-name': 'VNF_GROUP2_INSTANCE_NAME',
            'status-property-orchStatus': '',
            'status-property-provStatus': '',
            // 'status-property-inMaint': 'false',
          },
        };
        cy.getElementByDataTestsId('search-right-tree-input').type('vnf');

        for (let node in rightShouldHaves) {
          var [nodeName, nodeEq] = node.split(":");
          for (let span in rightShouldHaves[node]) {
            cy.getElementByDataTestsId(nodeName).eq(+nodeEq).find(`[data-tests-id='${span}']`).should('have.text', rightShouldHaves[node][span]);
            cy.getElementByDataTestsId(nodeName).eq(+nodeEq).find(`[data-tests-id= '${'node-name'}']`).find('.highlight').eq(0).should('have.text', 'VNF');

          }
        }

        /*
        3. Left to right connections
        */
        const leftShouldHighlight: { [text: string]: string[] } = {
          'groupingservicefortest..ResourceInstanceGroup..0': ['VNF_GROUP1_INSTANCE_NAME', 'VNF_GROUP2_INSTANCE_NAME'],
          'groupingservicefortest..ResourceInstanceGroup..1': [],
        };

        for (let text in leftShouldHighlight) {
          cy.get('available-models-tree').contains(text).click();
          cy.get('.node-content-wrapper-active').find(`[data-tests-id='node-name']`).should('have.text', text + leftShouldHighlight[text].join(''));
        }

        /*
        4. Right to left connections
         */
        const rightShouldHighlight: { [text: string]: string[] } = {
          'VNF_GROUP1_INSTANCE_NAME': ['groupingservicefortest..ResourceInstanceGroup..0'],
          'VNF_GROUP2_INSTANCE_NAME': ['groupingservicefortest..ResourceInstanceGroup..0'],
        };

        for (let node in rightShouldHighlight) {
          cy.get('drawing-board-tree').contains(node).click();
          cy.get('.node-content-wrapper-active').find(`[data-tests-id='node-name']`).should('have.text', rightShouldHighlight[node].join('') + node);
        }

        /*
        Menus
         */
        // SETUP: delete one group on the right; add one group from the left
        const myNode = 'node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0';

        cy.getElementByDataTestsId(`${myNode}-menu-btn`).eq(0).click({force: true})
          .getElementByDataTestsId('context-menu-delete').click();

        cy.getElementByDataTestsId('node-groupingservicefortest..ResourceInstanceGroup..0-add-btn').click({force: true});
        cy.getElementByDataTestsId(`${myNode}-menu-btn`).eq(2).click({force: true})
          .getElementByDataTestsId('context-menu-edit').click();
        cy.getElementByDataTestsId('instanceName').clear();
        cy.typeToInput('instanceName', 'VNF_GROUP3_INSTANCE_NAME');
        cy.getElementByDataTestsId('form-set').click({force: true});

        // TEST:
        // #2 is just added
        // #1 is from AAI
        // #0 is deleted
        const menuShouldHave: { [text: string]: string[] } = {
          [`${myNode}-menu-btn:2`]: ['remove', 'addGroupMember'],
          [`${myNode}-menu-btn:1`]: ['showAuditInfo', 'addGroupMember', 'delete'],
          [`${myNode}-menu-btn:0`]: ['showAuditInfo', 'undoDelete'],
        };

        for (let node in menuShouldHave) {
          const [nodeName, nodeEq] = node.split(":");
          let enabledActions:string[] = menuShouldHave[node];
          cy.assertMenuItemsForNode(enabledActions, nodeName, +nodeEq);
        }

        const GROUP_NAME_TO_DEPLOY: string = 'groupingservicefortest..ResourceInstanceGroup..0';
        cy.getElementByDataTestsId('deployBtn').should('have.text', 'UPDATE').click();

        cy.getReduxState().then((state) => {
          const addedVnfGroup = state.service.serviceInstance[SERVICE_MODEL_ID].vnfGroups[GROUP_NAME_TO_DEPLOY];

          cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
            cy.readFile('../vid-automation/src/test/resources/VnfGroup/VnfGroupCreate1Delete1None1Request.json').then((expectedResult) => {
              expectedResult.vnfGroups[GROUP_NAME_TO_DEPLOY].trackById = addedVnfGroup.trackById;
              cy.deepCompare(xhr.request.body, expectedResult);
            });
          });
        });
      });

      it(`vnf group with vnf members should display correctly and should have delete option"`, function () {
        const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
        const SERVICE_TYPE: string = "TYLER SILVIA";
        const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
        const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`,
            200,
            0,
            "ServiceTreeWithMultipleChildren_serviceModel",
          )
        });

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`,
            200, 0,
            "serviceWithVnfGroupsChildren_serviceInstance",
          )
        });

        cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&mode=EDIT`);
        cy.getElementByDataTestsId('deployBtn').should('have.attr', 'disabled');
        cy.get('#VnfGroup_VNF .icon-browse').eq(0).click({force: true}).then(() => {
          cy.getElementByDataTestsId('context-menu-delete').click({force: true});
          cy.getElementByDataTestsId('deployBtn').should('not.have.attr', 'disabled');

          cy.get('#VnfGroup_VNF .icon-browse').eq(0).click({force: true}).then(() => {
            cy.getElementByDataTestsId('context-menu-undoDelete').click({force: true});
            cy.getElementByDataTestsId('deployBtn').should('have.attr', 'disabled');
          });
        });


        cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn')
          .eq(0).click({force: true}).then(() => {
          cy.getElementByDataTestsId('context-menu-delete').click({force: true});
          cy.getElementByDataTestsId('deployBtn').should('not.have.attr', 'disabled');
        })
      });

      it('Delete 2 from 3 VNF members and check request body of deploy', function () {
        const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
        const SERVICE_TYPE: string = "TYLER SILVIA";
        const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
        const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';

        cy.server().route({
          url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
          method: 'POST',
          status: 200,
          response: "[]",
        }).as("expectedPostAsyncInstantiation");

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`,
            200,
            0,
            "ServiceTreeWithMultipleChildren_serviceModel",
          )
        });

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => {

          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`,
            200, 0,
            "serviceWithVnfGroupsChildren_serviceInstance",
          )
        });

        cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&mode=EDIT`);
        cy.getElementByDataTestsId('deployBtn').should('have.attr', 'disabled');

        for (let index = 0; index < 2; index++) {
          cy.get('#VnfGroup_VNF .icon-browse').eq(index).click({force: true}).then(() => {
            cy.getElementByDataTestsId('context-menu-delete').click({force: true});
            cy.getElementByDataTestsId('deployBtn').should('not.have.attr', 'disabled');
          });
        }

        cy.getElementByDataTestsId('deployBtn').should('have.text', 'UPDATE').click();

        cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
          cy.readFile('../vid-automation/src/test/resources/VnfGroup/payloadTemplate1VnfGroupWith3MembersRequest.json').then((expectedResult) => {
            expectedResult.vnfGroups.VNF_GROUP1_INSTANCE_ID.action = 'None';
            expectedResult.vnfGroups.VNF_GROUP1_INSTANCE_ID.vnfs.RELATED_VNF1_INSTANCE_ID.action = 'None_Delete';
            expectedResult.vnfGroups.VNF_GROUP1_INSTANCE_ID.vnfs.RELATED_VNF2_INSTANCE_ID.action = 'None_Delete';
            cy.deepCompare(xhr.request.body, expectedResult);
          });
        });
      });

      it(`vnf group with vnf members, add group members option open modal"`, () => {
        const SUBSCRIBER_ID: string = "global-customer-id";
        const SERVICE_TYPE: string = "service-instance-type";
        const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
        const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';
        const SERVICE_INVARIANT_ID: string = '24632e6b-584b-4f45-80d4-fefd75fd9f14';
        const GROUP_ROLE: string = 'SERVICE-ACCESS';
        const GROUP_TYPE: string = 'LOAD-GROUP';

        cy.server().route({
          url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
          method: 'POST',
          status: 200,
          response: "[]",
        }).as("expectedPostAsyncInstantiation");

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`,
            200,
            0,
            "ServiceTreeWithMultipleChildren_serviceModel",
          )
        });

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => {

          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`,
            200, 0,
            "serviceWithVnfGroupsChildren_serviceInstance",
          )
        });
        cy.readFile('../vid-automation/src/test/resources/VnfGroup/searchMembersResponse.json').then((res) => {

          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/aai_search_group_members/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INVARIANT_ID}/${GROUP_TYPE}/${GROUP_ROLE}`,
            200, 0,
            "VnfGroup_searchMembersResponse",
          )
        });
        cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&mode=EDIT`);

        cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn')
          .eq(0).click({force: true}).then(() => {
          cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => {
            cy.getElementByDataTestsId('sourceModelName').contains("vDBE_Svc_vPRS");
            cy.getElementByDataTestsId('sourceModelInvariant').contains("24632e6b-584b-4f45-80d4-fefd75fd9f14");
            cy.get('#vnfName').eq(0).get('#VNF1_INSTANCE_NAME').contains('VNF1_INSTANCE_NAME');
            cy.get('#vnfName').eq(0).get('#VNF1_INSTANCE_ID').contains('VNF1_INSTANCE_ID');
            cy.getElementByDataTestsId('total-amount').should('have.text', '4 VNFs match your criteria');
            cy.getElementByDataTestsId('total-selected').should('have.text', '0 VNF selected');
            cy.getElementByDataTestsId('setMembersBtn').should('have.attr', 'disabled');
            testCheckbox();
            testResetAddMemberModal();
            testUpdateBtn();

          });
        });
      });

      it(`vnf group add member get optional members return empty table"`, () => {
        const SUBSCRIBER_ID: string = "global-customer-id";
        const SERVICE_TYPE: string = "service-instance-type";
        const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
        const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';
        const SERVICE_INVARIANT_ID: string = '24632e6b-584b-4f45-80d4-fefd75fd9f14';
        const GROUP_ROLE: string = 'SERVICE-ACCESS';
        const GROUP_TYPE: string = 'LOAD-GROUP';

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`,
            200,
            0,
            "ServiceTreeWithMultipleChildren_serviceModel",
          )
        });

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => {

          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`,
            200, 0,
            "serviceWithVnfGroupsChildren_serviceInstance",
          )
        });
        cy.server()
          .route({
            method: 'GET',
            status: 200,
            url: Cypress.config('baseUrl') + `/aai_search_group_members/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INVARIANT_ID}/${GROUP_TYPE}/${GROUP_ROLE}`,
            response: []
          }).as('VnfGroup_searchMembersResponse');

        cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&mode=EDIT`);

        cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn')
          .eq(0).click({force: true}).then(() => {
          cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => {
            cy.getElementByDataTestsId('total-amount').should('have.text', '0 VNFs match your criteria');
            cy.getElementByDataTestsId('total-selected').should('have.text', '0 VNF selected');
            cy.get('.no-result').should('have.text', 'No VNFs were found that can belong to this group.');
          });
        })
      });

      it('Check scaling policy - in Create new service mode', () => {
        const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
        const SERVICE_TYPE: string = "TYLER SILVIA";
        const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';
        const SERVICE_INVARIANT_ID: string = 'c989ab9a-33c7-46ec-b521-1b2daef5f047';
        const GROUP_ROLE: string = 'SERVICE-ACCESS';
        const GROUP_TYPE: string = 'LOAD-GROUP';
        const GROUP_NAME_TO_DEPLOY = 'groupingservicefortest..ResourceInstanceGroup..1';
        const NODE_ID = 'c2b300e6-45de-4e5e-abda-3032bee2de56';
        const FULL_GROUP_NAME = 'node-' + NODE_ID + '-' + GROUP_NAME_TO_DEPLOY;
        let serviceModel: JSON;
        let basicServiceInstance: JSON;

        cy.server().route({
          url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
          method: 'POST',
          status: 200,
          response: "[]",
        }).as("expectedPostAsyncInstantiation");

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          serviceModel = res;
        });

        cy.readFile('./cypress/support/jsonBuilders/mocks/jsons/vnfGroupBasicServiceInstance.json').then((res) => {
          res.optionalGroupMembersMap = {};
          basicServiceInstance = res;
        });

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/searchMembersResponse.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/aai_search_group_members/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INVARIANT_ID}/${GROUP_TYPE}/${GROUP_ROLE}`,
            200, 0,
            "VnfGroup_searchMembersResponse",
          )
        });

        cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((reduxRes) => {

          reduxRes.service.serviceHierarchy[SERVICE_MODEL_ID] = serviceModel;

          reduxRes.service.serviceInstance[SERVICE_MODEL_ID] = basicServiceInstance;

          cy.setReduxState(<any>reduxRes);

          cy.openIframe('app/ui/#/servicePlanning?serviceModelId=' + SERVICE_MODEL_ID);
          cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY).find(`[data-tests-id='node-type-indicator']`).contains('G');
          cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY).contains('' + GROUP_NAME_TO_DEPLOY);
          cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY + '-add-btn').get('i').should('have.class', 'fa-plus-circle');

          cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY + '-add-btn').click({force: true});
          cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY + '-add-btn').click({force: true});

          cy.getElementByDataTestsId('node-' + NODE_ID + '-' + GROUP_NAME_TO_DEPLOY + '-menu-btn').each((row, index) => {
            cy.wrap(row).click({force: true}).then(() => {
              cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => {
                cy.getElementByDataTestsId('total-amount').should('have.text', '4 VNFs match your criteria');
                cy.get('.allCheckboxAreSelected input').click({force: true});
                cy.getElementByDataTestsId('setMembersBtn').click({force: true}).then(() => {
                  checkIsErrorAppear(true, 'node-' + NODE_ID + '-' + GROUP_NAME_TO_DEPLOY, 3, index);
                  cy.get('.toggle-children').click({force: true}).then(() => {
                    let memberIndex = 3;
                    while (!index && memberIndex >= 0) {
                      clickOnVnfMemberAndAssertScaling(memberIndex--, 'context-menu-remove', false, FULL_GROUP_NAME, 3, index);
                    }
                  });
                });
              });
            });
          });
          clickOnVnfMemberAndAssertScaling(0, 'context-menu-remove', false, FULL_GROUP_NAME, 3, 1);
          cy.getElementByDataTestsId('deployBtn').should('have.text', 'DEPLOY').click();
        });
      });

      it(`Check scaling policy in Edit mode`, () => {
        const SUBSCRIBER_ID: string = "global-customer-id";
        const SERVICE_TYPE: string = "service-instance-type";
        const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
        const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc';
        const SERVICE_INVARIANT_ID: string = '24632e6b-584b-4f45-80d4-fefd75fd9f14';
        const GROUP_ROLE: string = 'SERVICE-ACCESS';
        const GROUP_TYPE: string = 'LOAD-GROUP';
        const NODE_ID = 'daeb6568-cef8-417f-9075-ed259ce59f48';
        const GROUP_NAME_TO_DEPLOY = 'groupingservicefortest..ResourceInstanceGroup..0';
        const FULL_GROUP_NAME = 'node-' + NODE_ID + '-' + GROUP_NAME_TO_DEPLOY;

        cy.server().route({
          url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
          method: 'POST',
          status: 200,
          response: "[]",
        }).as("expectedPostAsyncInstantiation");

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => {
          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`,
            200,
            0,
            "ServiceTreeWithMultipleChildren_serviceModel",
          )
        });

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => {

          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`,
            200, 0,
            "serviceWithVnfGroupsChildren_serviceInstance",
          )
        });

        cy.readFile('../vid-automation/src/test/resources/VnfGroup/searchMembersResponse.json').then((res) => {

          jsonBuilderAndMock.basicJson(
            res,
            Cypress.config('baseUrl') + `/aai_search_group_members/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INVARIANT_ID}/${GROUP_TYPE}/${GROUP_ROLE}`,
            200, 0,
            "VnfGroup_searchMembersResponse",
          )
        });

        cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&mode=EDIT`);
        cy.getElementByDataTestsId('node-' + NODE_ID + '-' + GROUP_NAME_TO_DEPLOY + '-menu-btn')
          .eq(0).click({force: true}).then(() => {
          cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => {
            cy.getElementByDataTestsId('total-amount').should('have.text', '4 VNFs match your criteria');
            cy.get('.allCheckboxAreSelected input').click({force: true});
            cy.getElementByDataTestsId('setMembersBtn').click({force: true}).then(() => {
              checkIsErrorAppear(true, FULL_GROUP_NAME, 4, 0);

              clickOnVnfMemberAndAssertScaling(6, 'context-menu-remove', true, FULL_GROUP_NAME, 4, 0);
              clickOnVnfMemberAndAssertScaling(5, 'context-menu-remove', true, FULL_GROUP_NAME, 4, 0);
              clickOnVnfMemberAndAssertScaling(0, 'context-menu-delete', false, FULL_GROUP_NAME, 4, 0);
              clickOnVnfMemberAndAssertScaling(0, 'context-menu-undoDelete', true, FULL_GROUP_NAME, 4, 0);
              clickOnVnfMemberAndAssertScaling(4, 'context-menu-remove', false, FULL_GROUP_NAME, 4, 0);
              testResetAddMemberModal();
              testUpdateBtn();
            })
          });
        });
      });

      function removeVnfGroup() {
        cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn')
          .click({force: true});
        cy.getElementByDataTestsId('context-menu-remove').click({force: true});
      }

      function testUpdateBtn() {
        cy.getElementByDataTestsId('deployBtn').should('have.text', 'UPDATE').click();
        cy.getReduxState().then((state) => {
          cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
            cy.readFile('../vid-automation/src/test/resources/VnfGroup/vnfGroupWithExistingAndNewVnfMembers.json').then((expectedResult) => {
              cy.deepCompare(xhr.request.body, expectedResult);
            });
          });
        });
      }

      function testCheckbox() {
        let totalNumber = 4;
        cy.get('.allCheckboxAreSelected input').click({force: true});
        cy.getElementByDataTestsId('setMembersBtn').should('not.have.attr', 'disabled');
        cy.getElementByDataTestsId('numberOfNotHideVnfMembers').contains(totalNumber);
        cy.getElementByDataTestsId('numberOfSelectedVnfMembers').contains(totalNumber);
        cy.get('.sdcCheckboxMember input').eq(0).click({force: true});
        cy.getElementByDataTestsId('numberOfSelectedVnfMembers').contains(totalNumber - 1);
        cy.get('.sdcCheckboxMember input').eq(1).click({force: true});
        cy.getElementByDataTestsId('numberOfSelectedVnfMembers').contains(totalNumber - 2);
        cy.get('.allCheckboxAreSelected input').click({force: true});
        cy.getElementByDataTestsId('numberOfSelectedVnfMembers').contains(totalNumber);
        cy.get('.allCheckboxAreSelected input').click({force: true});
        cy.getElementByDataTestsId('numberOfSelectedVnfMembers').contains(0);

        cy.getElementByDataTestsId("vnf-members-search").find('input').type("2.0");
        cy.getElementByDataTestsId('numberOfNotHideVnfMembers').contains(1);
        cy.getElementByDataTestsId("vnf-members-search").find('input').clear().type("vnf1");
        cy.getElementByDataTestsId('numberOfNotHideVnfMembers').contains(1);
        cy.get('.allCheckboxAreSelected input').click({force: true});
        cy.getElementByDataTestsId('numberOfSelectedVnfMembers').contains(1);
        cy.getElementByDataTestsId("vnf-members-search").find('input').clear();
        cy.getElementByDataTestsId('numberOfSelectedVnfMembers').contains(1);

        cy.getElementByDataTestsId('setMembersBtn').click({force: true});
        //check second time behavior (selected VNFs should be filtered)
        cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn')
          .eq(1).click({force: true}).then(() => {
          cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => {
            cy.getElementByDataTestsId('numberOfNotHideVnfMembers').contains(totalNumber - 1);
            cy.getElementByDataTestsId('cancelBtn').click({force: true});
          });
        });

      }
      function testResetAddMemberModal(): void{
        cy.getElementByDataTestsId('node-groupingservicefortest..ResourceInstanceGroup..1-add-btn').click({force: true})
          .getElementByDataTestsId('node-c2b300e6-45de-4e5e-abda-3032bee2de56-groupingservicefortest..ResourceInstanceGroup..1-menu-btn').eq(0).click({force: true}).then(() => {
          cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => {
            cy.getElementByDataTestsId('numberOfNotHideVnfMembers').contains(0);
            cy.getElementByDataTestsId('cancelBtn').click({force: true});
          });
          cy.getElementByDataTestsId('node-c2b300e6-45de-4e5e-abda-3032bee2de56-groupingservicefortest..ResourceInstanceGroup..1-menu-btn').eq(0).click({force: true}).then(() => {
            cy.getElementByDataTestsId('context-menu-remove').click({force: true});
          });
        });
      }
      function checkIsErrorAppear(isError: boolean, groupRowId: string, limit: number, index: number) {
        const isErrorPrefix = isError ? '' : 'not.';
        cy.getElementByDataTestsId('error-msg-wrapper').should(isErrorPrefix + 'exist');
        cy.getElementByDataTestsId('deployBtn').should(isErrorPrefix + 'have.attr', 'disabled');
        cy.getElementByDataTestsId(groupRowId).eq(index).find("[data-tests-id='scaling-policy']").should(isErrorPrefix + 'have.text', 'Limit' + limit);
        cy.getElementByDataTestsId('error-msg-title').should(isErrorPrefix + 'exist');
        cy.getElementByDataTestsId('error-msg-sub-title').should(isErrorPrefix + 'exist');
        cy.getElementByDataTestsId('error-msg-description').should(isErrorPrefix + 'exist');
      }

      function clickOnVnfMemberAndAssertScaling(childIndex: number, menuItemTestId: string, isError: boolean, groupRowId: string, limit: number, index: number) {
        cy.get('.tree-children').find('.node-wrapper').eq(childIndex).find('.icon-browse').click({force: true})
          .getElementByDataTestsId(menuItemTestId).click({force: true}).then(() => {
          checkIsErrorAppear(isError, groupRowId, limit, index);
        });
      }


    }
  );
});
