blob: 5db0c751db1b59a4f442ed3a2e3abc17384ff2b4 [file] [log] [blame]
///<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);
});
}
}
);
});