From 548c5a220333c7cd666b861e737bff0b45461f18 Mon Sep 17 00:00:00 2001 From: "Stone, Avi (as206k)" Date: Sun, 3 Jun 2018 13:12:12 +0300 Subject: Update FE project Update FE to latest version so that fe can run on docker Change-Id: I9c5dee756b567dbe64fac6d3d6fd89362813bdcc Issue-ID: SDC-1359 Signed-off-by: Stone, Avi (as206k) --- .../integration/e2e/e2eWithIntegration-spec.ts | 98 ++-- .../cypress/integration/mocks/errorDialog-spec.ts | 10 +- .../cypress/integration/mocks/generalPage-spec.ts | 108 +++- public/cypress/integration/mocks/homePage-spec.ts | 75 +-- .../cypress/integration/mocks/importPage-spec.ts | 19 +- .../cypress/integration/mocks/ruleEngine-spec.ts | 643 ++++++++++++++++++++- 6 files changed, 835 insertions(+), 118 deletions(-) (limited to 'public/cypress/integration') diff --git a/public/cypress/integration/e2e/e2eWithIntegration-spec.ts b/public/cypress/integration/e2e/e2eWithIntegration-spec.ts index 459a7de..949e966 100644 --- a/public/cypress/integration/e2e/e2eWithIntegration-spec.ts +++ b/public/cypress/integration/e2e/e2eWithIntegration-spec.ts @@ -3,7 +3,6 @@ const randomNodeName = () => .toString(36) .substr(2, 7); const NODE_NAME = randomNodeName(); - const serverGetDDLData = () => { return cy .server() @@ -12,14 +11,9 @@ const serverGetDDLData = () => { Cypress.env('backendUrl') + '/getResourcesByMonitoringTemplateCategory' ) .as('templateAPi') - .route( - 'GET', - Cypress.env('backendUrl') + - '/service/06c7d927-4e2f-47e1-a29d-b6ed229ebc0a' - ) + .route('GET', Cypress.env('backendUrl') + '/service/**') .as('vfniListAPi'); }; - const saveAndDoneHttp = () => { cy.server(); cy @@ -29,7 +23,6 @@ const saveAndDoneHttp = () => { }) .as('doneSaveCopyRule'); }; - const createNewMC = () => { cy .get('input[data-tests-id="nameMc"]') @@ -64,18 +57,33 @@ const createNewMC = () => { .click() .wait('@newMC'); }; - import { buttonCreateMC } from '../mocks/homePage-spec'; import { selectVersionAndTypeAndAddFirstRule, - fillRuleDecription, + fillRuleDescription, addCopyAction, editFirstRule } from '../mocks/ruleEngine-spec'; +describe('DCAED - forntend e2e and inagration test ', () => { + // context(('home page'), () => { it.only('should open env', () => { cy + // .visit('https://www.e-access.att.com/DevOps02/sdc1/portal#!/dashboard') + // .get(':nth-child(2) > :nth-child(1) > [border="0"][width="100%"] > + // :nth-child(1) > :nt' + 'h-child(1) > td > input') .type('ym903w') + // .get(':nth-child(3) > td > input') .type('Apple1qazxsw2') + // .get('[border="0"][width="100%"] > :nth-child(1) > :nth-child(5) > td > + // input') .click() .get('#srv_successok > input') .click() + // .get(':nth-child(1) > .w-sdc-dashboard-card-new-content') + // .trigger('mouseover') .get('button[data-tests-id="createServiceButton"]') + // .click() .get('input[data-tests-id="name"]') + // .type(`DCAE_SRV_${NODE_NAME}`) + // .get('select[data-tests-id="selectGeneralCategory"]') .select('Mobility') + // .get('textarea[data-tests-id="description"]') .type('bla') + // .get('input[data-tests-id="projectCode"]') .type('att01') + // .get('button[data-tests-id="create/save"]') .click() + // .get('div[data-tests-id="CompositionLeftSideMenu"]') .click() }); }); -describe('DCAED - forntend e2e and inagration test', () => { - context('Empty Monitoring Configuration list for service', () => { - it('Loads', () => { + context('Empty Monitoring Configuration list for service ', () => { + it(' Loads ', () => { cy.homePage(); }); }); @@ -96,50 +104,24 @@ describe('DCAED - forntend e2e and inagration test', () => { .and('be.disabled'); }); - it('click on create mc - more then one tab should be visible', () => { - createNewMC(); - cy - .get('ul[p-tabviewnav]') - .children() - .should($el => { - expect($el.length).to.be.greaterThan(1); - }); - }); - - it('should enter rule engine in map tab and create new rule', () => { - createNewMC(); - cy - .get('#ui-tabpanel-1-label') - .should('contain', 'map') - .click(); - selectVersionAndTypeAndAddFirstRule(); - fillRuleDecription('newRule'); - addCopyAction(); - saveAndDoneHttp(); - cy.get('button[data-tests-id="btnDone"]').click(); - cy - .wait('@doneSaveCopyRule') - .get('div[data-tests-id="ruleElement"]') - .should('be.visible') - .then(function($lis) { - expect($lis).to.have.length(1); - expect($lis.eq(0)).to.contain('newRule'); - }); - editFirstRule(); - fillRuleDecription('LiavRule'); - saveAndDoneHttp(); - cy - .get('button[data-tests-id="btnSave"]') - .click() - .wait('@doneSaveCopyRule') - .get('a[data-tests-id="btnBackRule"]') - .click() - .get('div[data-tests-id="ruleElement"]') - .should('be.visible') - .then(function($lis) { - expect($lis).to.have.length(1); - expect($lis.eq(0)).to.contain('LiavRule'); - }); - }); + // it('click on create mc - more then one tab should be visible', () => { + // createNewMC(); cy .get('ul[p-tabviewnav]') .children() + // .should($el => { expect($el.length).to.be.greaterThan(1); }); }); + // it('should enter rule engine in map tab and create new rule', () => { + // createNewMC(); cy .get('#ui-tabpanel-1-label') .should('contain', + // 'map') .click(); selectVersionAndTypeAndAddFirstRule(); + // fillRuleDescription('newRule'); addCopyAction(); saveAndDoneHttp(); + // cy.get('button[data-tests-id="btnDone"]').click(); cy + // .wait('@doneSaveCopyRule') .get('div[data-tests-id="ruleElement"]') + // .should('be.visible') .then(function($lis) { + // expect($lis).to.have.length(1); + // expect($lis.eq(0)).to.contain('newRule'); }); editFirstRule(); + // fillRuleDescription('LiavRule'); saveAndDoneHttp(); cy + // .get('button[data-tests-id="btnSave"]') .click() + // .wait('@doneSaveCopyRule') .get('a[data-tests-id="btnBackRule"]') + // .click() .get('div[data-tests-id="ruleElement"]') + // .should('be.visible') .then(function($lis) { + // expect($lis).to.have.length(1); + // expect($lis.eq(0)).to.contain('LiavRule'); }); }); }); }); diff --git a/public/cypress/integration/mocks/errorDialog-spec.ts b/public/cypress/integration/mocks/errorDialog-spec.ts index 9141ab2..e879a9f 100644 --- a/public/cypress/integration/mocks/errorDialog-spec.ts +++ b/public/cypress/integration/mocks/errorDialog-spec.ts @@ -10,12 +10,18 @@ describe('Dialog error - E2E test flow with mock', () => { }); it('Simulate error dialog is close by cancel button', () => { - cy.get('button[data-tests-id="error-cancel"]').click(); + cy + .get('button[data-tests-id="error-cancel"]') + .first() + .click({ force: true }); cy.get('.ui-dialog').should('not.be.visible'); }); it('Simulate error dialog is close by X button', () => { - cy.get('.ui-dialog-titlebar-icon').click(); + cy + .get('span[data-tests-id="error-cancel-icon"]') + .first() + .click({ force: true }); cy.get('.ui-dialog').should('not.be.visible'); }); }); diff --git a/public/cypress/integration/mocks/generalPage-spec.ts b/public/cypress/integration/mocks/generalPage-spec.ts index 1297de8..58a4bc8 100644 --- a/public/cypress/integration/mocks/generalPage-spec.ts +++ b/public/cypress/integration/mocks/generalPage-spec.ts @@ -1,4 +1,55 @@ describe('General Page - E2E test flow with mock', () => { + describe('Check Boolean DDL', () => { + beforeEach(() => { + cy.httpGenerateMappingRulesFileName(); + cy.httpGetDDLData(); + cy.httpCreateNewMcWithBooleanDDL(); + cy.getMCListEmpty(); + cy.homePage(); + cy.get('button[data-tests-id="btn-create-mc"]').click(); + }); + + it( + 'Check boolean DDL with value undefined - using true, true - using true and false' + + ' - using false.', + () => { + cy.fillNewMcForm(); + cy + .get('button[data-tests-id="createMonitoring"]') + .as('createButton') + .not('[disabled]') + .should('not.contain', 'Disabled'); + + cy.httpCreateNewMcWithBooleanDDL(); + cy.emptyRuleEngine('Type1'); + + cy.get('@createButton').click(); + cy + .get('#ui-tabpanel-1-label') + .should('contain', 'map') + .click(); + cy + .get('button[data-tests-id="setting-gear"]') + .should('be.visible') + .first() + .click({ multiple: true }); + + cy + .get('.map-setting-list #mappingType > .field-text') + .should('have.value', 'multiple'); + cy + .get('.map-setting-list > form > #valueUndefined > select') + .should('have.value', 'true'); + cy + .get('.map-setting-list > form > #valueTrue > select') + .should('have.value', 'true'); + cy + .get('.map-setting-list > form > #valueFalse > select') + .should('have.value', 'false'); + } + ); + }); + describe('Create new MC', () => { beforeEach(() => { cy.httpGetDDLData(); @@ -14,6 +65,39 @@ describe('General Page - E2E test flow with mock', () => { .and('be.disabled'); }); + it('After submit advenced setting description exist in first input', () => { + cy.fillNewMcForm(); + cy + .get('button[data-tests-id="createMonitoring"]') + .as('createButton') + .not('[disabled]') + .should('not.contain', 'Disabled'); + + cy.httpCreateNewMc(); + cy.emptyRuleEngine('Type1'); + + cy.get('@createButton').click(); + cy + .get('#ui-tabpanel-1-label') + .should('contain', 'map') + .click(); + cy + .get('button[data-tests-id="setting-gear"]') + .should('be.visible') + .first() + .click({ multiple: true }); + + cy + .get('.map-setting-list #Type1 .help-description') + .trigger('mouseenter') + .get('.ui-tooltip') + .should('be.visible') + .should( + 'contain', + 'CSV to VES mapping, from the file to generate multiple events or single event' + ); + }); + it('Fill form then click to submit verify setting button and constrain ddl', () => { cy.fillNewMcForm(); cy @@ -42,6 +126,29 @@ describe('General Page - E2E test flow with mock', () => { }); }); + describe('Flow diagram', () => { + beforeEach(() => { + cy.httpGetDDLData(); + cy.getMCListEmpty(); + cy.homePage(); + cy.get('button[data-tests-id="btn-create-mc"]').click(); + cy.fillNewMcForm(); + cy.httpCreateNewMc(); + cy.get('button[data-tests-id="createMonitoring"]').click(); + }); + + it.only('should flow diagram need to exist', () => { + cy.get('#diagram').should('be.visible'); + }); + + it('should flow diagram need to contain 4 connections', () => { + cy + .get('#diagram line') + .its('length') + .should('be.equal', 4); + }); + }); + describe('Tabs after MC created', () => { beforeEach(() => { cy.httpGetDDLData(); @@ -50,7 +157,6 @@ describe('General Page - E2E test flow with mock', () => { cy.get('button[data-tests-id="btn-create-mc"]').click(); cy.fillNewMcForm(); cy.httpCreateNewMc(); - cy.emptyRuleEngine('Type1'); cy.get('button[data-tests-id="createMonitoring"]').click(); }); diff --git a/public/cypress/integration/mocks/homePage-spec.ts b/public/cypress/integration/mocks/homePage-spec.ts index 2889390..5f96c98 100644 --- a/public/cypress/integration/mocks/homePage-spec.ts +++ b/public/cypress/integration/mocks/homePage-spec.ts @@ -6,11 +6,11 @@ export const buttonCreateMCSpan = () => { }; export const tableItems = () => { - return cy.get('tr[data-tests-id="monitoringComponentTableItems"]'); + return cy.get('datatable-row-wrapper'); }; -export const tableHeaders = () => { - return cy.get('tr[data-tests-id="monitoringComponentTableHeaders"]'); +export const monitoringComponentTable = () => { + return cy.get('ngx-datatable[data-tests-id="monitoringComponentTable"]'); }; export const tableItemsDeleteButton = () => { return cy.get('button[data-tests-id="tableItemsButtonDelete"]'); @@ -64,9 +64,9 @@ describe('Home Page - E2E test flow with mock', () => { }); it("Shouldn't have create table with headers", () => { - tableHeaders().should('not.be.visible'); + monitoringComponentTable().should('not.be.visible'); }); - it("Shouldn't have create table without items", () => { + it("Shouldn't have create table with items", () => { buttonCreateMC() .get('div[data-tests-id="new-monitoring-title"]') .should('contain', 'Monitoring'); @@ -100,20 +100,13 @@ describe('Home Page - E2E test flow with mock', () => { }); it('Should have create table with headers', () => { - tableHeaders().should('be.visible'); + monitoringComponentTable().should('be.visible'); }); it('Should have create table with items', () => { tableItems().should('have.length', NUMBER_OF_ITEMS); }); }); - describe('MC List Edit Tests', () => { - beforeEach(() => { - cy.getMCList(); - cy.homePage(); - }); - }); - describe('MC List Delete Tests', () => { beforeEach(() => { cy.getMCList(); @@ -126,26 +119,34 @@ describe('Home Page - E2E test flow with mock', () => { tableItemsDeleteButton().should('be.visible'); tableItemsInfoButton().should('not.be.visible'); }); - it('Mouse hover over item, call delete and remove not submitted (call delete without blueprint api)', () => { - tableItems().should('have.length', NUMBER_OF_ITEMS); - doHoverOverFirstLine(); - tableItemsDeleteButton() - .should('be.visible') - .click({ force: true }); - popupGetDeleteBtn().click({ force: true }); - tableItems().should('have.length', NUMBER_OF_ITEMS - 1); - }); - it('Mouse hover over item, call delete and remove submitted (call delete with blueprint api)', () => { - tableItems() - .should('have.length', NUMBER_OF_ITEMS) - .last() - .trigger('mouseover'); - tableItemsDeleteButton() - .should('be.visible') - .click({ force: true }); - popupGetDeleteBtn().click({ force: true }); - tableItems().should('have.length', NUMBER_OF_ITEMS - 1); - }); + it( + 'Mouse hover over item, call delete and remove not submitted (call delete without' + + ' blueprint api)', + () => { + tableItems().should('have.length', NUMBER_OF_ITEMS); + doHoverOverFirstLine(); + tableItemsDeleteButton() + .should('be.visible') + .click({ force: true }); + popupGetDeleteBtn().click({ force: true }); + tableItems().should('have.length', NUMBER_OF_ITEMS - 1); + } + ); + it( + 'Mouse hover over item, call delete and remove submitted (call delete with bluepr' + + 'int api)', + () => { + tableItems() + .should('have.length', NUMBER_OF_ITEMS) + .last() + .trigger('mouseover'); + tableItemsDeleteButton() + .should('be.visible') + .click({ force: true }); + popupGetDeleteBtn().click({ force: true }); + tableItems().should('have.length', NUMBER_OF_ITEMS - 1); + } + ); it('Mouse hover over item, call delete and cancelOperation', () => { tableItems().should('have.length', NUMBER_OF_ITEMS); doHoverOverFirstLine(); @@ -171,6 +172,7 @@ describe('Home Page - E2E test flow with mock', () => { describe('Successfully Entry Home Page Monitoring Configuration', () => { beforeEach(() => { + cy.httpGetDDLData(); cy.getMCListEmpty(); cy.homePage(); }); @@ -190,12 +192,17 @@ describe('Home Page - E2E test flow with mock', () => { it('Buttons Functionality Assertion', () => { buttonCreateMC() .click() - .get('div[data-tests-id="new-monitoring-title"]') + .get('div[data-tests-id="new-monitorying-titie"]') .should('contain', 'Monitoring'); }); }); describe('Not Auth Entry Home Page Monitoring Configuration', () => { + beforeEach(() => { + cy.httpGetDDLData(); + cy.getMCListEmpty(); + }); + it('Buttons disabled when user not owner', () => { cy.sdcIsOwnerFalse(); navigateButtonDisabled(); diff --git a/public/cypress/integration/mocks/importPage-spec.ts b/public/cypress/integration/mocks/importPage-spec.ts index 7af904e..446409c 100644 --- a/public/cypress/integration/mocks/importPage-spec.ts +++ b/public/cypress/integration/mocks/importPage-spec.ts @@ -5,13 +5,10 @@ const loadVfcmtList = () => { method: 'GET', url: Cypress.env('backendUrl') + - '/SERVICE/06c7d927-4e2f-47e1-a29d-b6ed229ebc0a/0.1/getVfcmtsForMigration', + '/SERVICES/06c7d927-4e2f-47e1-a29d-b6ed229ebc0a/0.1/getVfcmtsForMigration', response: 'fixture:importVfcmt' }) - .as('importVfcmtList') - .visit( - 'http://localhost:4300/#/main/SERVICE/06c7d927-4e2f-47e1-a29d-b6ed229ebc0a/0.1/import' - ); + .as('importVfcmtList'); }; const getVfcmtRefData = data => { @@ -93,7 +90,11 @@ const getImportButton = () => { describe('Import Page', () => { context('First step - get vfcmts list and pick one', () => { beforeEach(() => { + cy.httpGetDDLData(); + cy.getMCListEmpty(); + cy.homePage(); loadVfcmtList(); + cy.get('button[data-tests-id="btn-import-mc"]').click(); }); it('should have values in ddl', () => { @@ -129,7 +130,11 @@ describe('Import Page', () => { context('second step - fill fileds according to server response', () => { beforeEach(() => { + cy.httpGetDDLData(); + cy.getMCListEmpty(); + cy.homePage(); loadVfcmtList(); + cy.get('button[data-tests-id="btn-import-mc"]').click(); }); it('get flow type true and service is match to context service', () => { @@ -208,7 +213,11 @@ describe('Import Page', () => { context('final step - import vfcmt and getting cdump for tabs', () => { beforeEach(() => { + cy.httpGetDDLData(); + cy.getMCListEmpty(); + cy.homePage(); loadVfcmtList(); + cy.get('button[data-tests-id="btn-import-mc"]').click(); getVfcmtRefData({ serviceUuid: '06c7d927-4e2f-47e1-a29d-b6ed229ebc0a', name: 'test', diff --git a/public/cypress/integration/mocks/ruleEngine-spec.ts b/public/cypress/integration/mocks/ruleEngine-spec.ts index 9a75b87..d2c0b69 100644 --- a/public/cypress/integration/mocks/ruleEngine-spec.ts +++ b/public/cypress/integration/mocks/ruleEngine-spec.ts @@ -2,6 +2,14 @@ export const mappingTragetDDL = () => { return cy.get('select[data-tests-id="mappingDdl"]'); }; +export const getExistRulesList = () => { + return cy.get('option[data-tests-id="templateOptionsExist"]'); +}; + +export const getNotExistRulesList = () => { + return cy.get('option[data-tests-id="templateOptionsNotExist"]'); +}; + export const selectVersionAndTypeAndAddFirstRule = () => { return cy .get('select[data-tests-id="selectVersion"]') @@ -12,13 +20,55 @@ export const selectVersionAndTypeAndAddFirstRule = () => { .click(); }; -export const fillRuleDecription = text => { +export const fillRuleDescription = text => { return cy .get('input[data-tests-id="inputDescription"]') .clear() .type(text); }; +export const addMapAndDeleteRowAction = () => { + cy.get('select[data-tests-id="selectAction"]').select('map'); + cy.get('button[data-tests-id="btnAddAction"]').click(); + // fill map action + cy + .get('input[data-tests-id="valueInput"]') + .first() + .type('B') + .should('have.value', 'B'); + + return cy + .get('input[data-tests-id="key"]') + .type('Key1') + .should('have.value', 'Key1') + .get('input[data-tests-id="value"]') + .type('Key1') + .should('have.value', 'Key1') + .get('button[data-tests-id="btn-add-row"]') + .click() + .get('input[data-tests-id="key"]') + .last() + .type('Key2') + .should('have.value', 'Key2') + .get('input[data-tests-id="value"]') + .last() + .type('Key2') + .should('have.value', 'Key2') + .get('button[data-tests-id="btn-add-row"]') + .click() + .get('input[data-tests-id="key"]') + .last() + .type('Key3') + .should('have.value', 'Key3') + .get('input[data-tests-id="value"]') + .last() + .type('Key3') + .should('have.value', 'Key3') + .get('button[data-tests-id="btn-remove-row"]') + .last() + .click(); +}; + export const addCopyAction = () => { return cy .get('select[data-tests-id="selectAction"]') @@ -27,6 +77,7 @@ export const addCopyAction = () => { .click() .get('input[data-tests-id="valueInput"]') .type('A') + .should('have.value', 'A') .get('span[data-tests-id="openTargetTree"]') .click() .get('.bottom-select') @@ -56,11 +107,71 @@ export const editFirstRule = () => { .click(); }; -export const translateValue = () => { - return '{"processing":[{"phase":"snmp_map","processors":[{"array":"varbinds","datacolumn":"varbind_value","keycolumn":"varbind_oid","class":"SnmpConvertor"},{"phase":"sto2","class":"RunPhase"}]},{"phase":"sto2","processors":[{"updates":{"event.commonEventHeader.domain":"a"},"class":"Set"}]},{"phase":"sto2","processors":[{"phase":"map_publish","class":"RunPhase"}]}]}'; +export const editLastRule = () => { + return cy + .get('div[data-tests-id="ruleElement"]') + .last() + .trigger('mouseover') + .get('button[data-tests-id="editRule"]') + .should('be.visible') + .click(); }; +export const deleteFirstRule = () => { + cy + .get('div[data-tests-id="ruleElement"]') + .first() + .trigger('mouseover') + .get('button[data-tests-id="deleteRule"]') + .should('be.visible') + .click() + .get('div[data-tests-id="delete-popup"]'); + + cy.deleteRule(); + return cy.get('button[data-tests-id="btnDelete"]').click(); +}; + +export const translateValue = () => { + return ( + '{"processing":[{"phase":"snmp_map","processors":[{"array":"varbinds","datacolumn' + + '":"varbind_value","keycolumn":"varbind_oid","class":"SnmpConvertor"},{"phase":"s' + + 'to2","class":"RunPhase"}]},{"phase":"sto2","processors":[{"updates":{"event.comm' + + 'onEventHeader.domain":"a"},"class":"Set"}]},{"phase":"sto2","processors":[{"phas' + + 'e":"map_publish","class":"RunPhase"}]}]}' + ); +}; +const NUMBER_OF_EXIST_ITEMS = 3; +const NUMBER_OF_NOT_EXIST_ITEMS = 16; describe('Rule engine - E2E test flow with mock', () => { + describe('Checking rules exist and not exist separation', () => { + beforeEach(() => { + cy.httpGenerateMappingRulesFileName(); + cy.httpGetDDLData(); + cy.getMCListEmpty(); + cy.homePage(); + cy.get('button[data-tests-id="btn-create-mc"]').click(); + cy.fillNewMcForm(); + cy.httpCreateNewMc(); + cy.emptyRuleEngine('Type1'); + cy.get('button[data-tests-id="createMonitoring"]').click(); + cy + .get('#ui-tabpanel-1-label') + .should('contain', 'map') + .click(); + }); + it('In exist group contain 3 visible options and not exist 16 visible', () => { + mappingTragetDDL() + .should('be.visible') + .contains('json'); + getExistRulesList() + .not('[hidden]') + .should('have.length', NUMBER_OF_EXIST_ITEMS); + getNotExistRulesList() + .not('[hidden]') + .should('have.length', NUMBER_OF_NOT_EXIST_ITEMS); + }); + }); + describe('Mapping target select', () => { beforeEach(() => { cy.httpGetDDLData(); @@ -82,25 +193,521 @@ describe('Rule engine - E2E test flow with mock', () => { .should('be.visible') .contains('json'); }); + }); - it('should page refrash after change select value in mapping target ddl', () => { + describe('Fill all available Actions', () => { + beforeEach(() => { + cy.httpGetDDLData(); + cy.getMCListEmpty(); + cy.homePage(); + cy.get('button[data-tests-id="btn-create-mc"]').click(); + cy.fillNewMcForm(); + cy.httpCreateNewMc(); + cy.emptyRuleEngine('Type1'); + cy + .get('button[data-tests-id="createMonitoring"]') + .click() + .get('#ui-tabpanel-1-label') + .should('contain', 'map') + .click(); cy.httpTargetTree(); + selectVersionAndTypeAndAddFirstRule(); + fillRuleDescription('newRule'); + }); + + it('add copy action', () => { + addCopyAction(); + }); + + it('add concat action', () => { + cy.get('select[data-tests-id="selectAction"]').select('concat'); + cy.get('button[data-tests-id="btnAddAction"]').click(); + // fill concat action cy - .get('select[data-tests-id="selectVersion"]') - .select('4.1') - .get('select[data-tests-id="selectEventType"]') - .select('syslog') - .get('button[data-tests-id="btnAddFirstRule"]') - .should('be.visible'); - cy.emptyRuleEngine('json'); - mappingTragetDDL() - .select('json') - .get('select[data-tests-id="selectVersion"]') - .should('have.value', null); + .get('input[data-tests-id="valueInput"]') + .first() + .type('A') + .should('have.value', 'A'); + cy + .get('input[data-tests-id="valueInput"]') + .last() + .type('B') + .should('have.value', 'B'); + cy + .get('span[data-tests-id="openTargetTree"]') + .click() + .get('.bottom-select') + .should('be.visible') + .find('.toggle-children') + .first() + .click(); + + cy + .get('span[data-tests-id="targetNode"]') + .should(node => { + expect(node.eq(0)).to.contain('commonEventHeader'); + expect(node.eq(1)).to.contain('domain'); + }) + .each(($el, index) => { + if (index === 1) { + cy.wrap($el).click(); + } + }); + + cy + .get('input[data-tests-id="inputTarget"]') + .should('have.value', 'event.commonEventHeader.domain'); + }); + + it('add map action', () => { + addMapAndDeleteRowAction(); + + cy + .get('span[data-tests-id="openTargetTree"]') + .click() + .get('.bottom-select') + .should('be.visible') + .find('.toggle-children') + .first() + .click(); + + cy + .get('span[data-tests-id="targetNode"]') + .should(node => { + expect(node.eq(0)).to.contain('commonEventHeader'); + expect(node.eq(1)).to.contain('domain'); + }) + .each(($el, index) => { + if (index === 1) { + cy.wrap($el).click(); + } + }); + + cy.get('input[data-tests-id="defaultCheckbox"]').click(); + cy.get('input[data-tests-id="defaultInput"]').type('default value'); + + cy + .get('input[data-tests-id="inputTarget"]') + .should('have.value', 'event.commonEventHeader.domain'); + }); + + it('add date-formatter action', () => { + cy.get('select[data-tests-id="selectAction"]').select('date formatter'); + cy.get('button[data-tests-id="btnAddAction"]').click(); + + // fill date-formatter action Section 1 + cy + .get('input[data-tests-id="valueInput"]') + .first() + .type('A') + .should('have.value', 'A') + .get('span[data-tests-id="openTargetTree"]') + .click() + .get('.bottom-select') + .should('be.visible') + .find('.toggle-children') + .first() + .click() + .get('span[data-tests-id="targetNode"]') + .should(node => { + expect(node.eq(0)).to.contain('commonEventHeader'); + expect(node.eq(1)).to.contain('domain'); + }) + .each(($el, index) => { + if (index === 1) { + cy.wrap($el).click(); + } + }); + cy + .get('input[data-tests-id="inputTarget"]') + .should('have.value', 'event.commonEventHeader.domain'); + + // Section 2 + cy + .get('input[data-tests-id="InputFromFormat"]') + .type('04/03/2018') + .should('have.value', '04/03/2018') + .get('input[data-tests-id="InputFromTimezone"]') + .type('11:50:00') + .should('have.value', '11:50:00') + .get('input[data-tests-id="InputToFormat"]') + .type('04/08/2018') + .should('have.value', '04/08/2018') + .get('input[data-tests-id="InputToTimezone"]') + .type('11:50:00') + .should('have.value', '11:50:00'); + }); + + it('add conditional action', () => { + cy + .get('input[data-tests-id="isCondition"]') + .click() + .get('input[data-tests-id="left"]') + .type('ABC') + .should('have.value', 'ABC'); + + cy + .get('select[data-tests-id="selectOperator"]') + .select('startsWith') + .get('input[data-tests-id="right"]') + .type('A') + .should('have.value', 'A'); + + cy + .get('button[data-tests-id="addCondition"]') + .click() + .get('input[data-tests-id="left"]') + .last() + .type('DEF') + .should('have.value', 'DEF'); + + cy + .get('select[data-tests-id="selectOperator"]') + .last() + .select('endsWith') + .get('input[data-tests-id="right"]') + .last() + .type('F') + .should('have.value', 'F'); + + cy + .get('button[data-tests-id="addCondition"]') + .click() + .get('input[data-tests-id="left"]') + .last() + .type('HIJ') + .should('have.value', 'HIJ'); + + cy + .get('select[data-tests-id="selectOperator"]') + .last() + .select('equals') + .get('input[data-tests-id="right"]') + .last() + .type('HHH') + .should('have.value', 'HHH'); + + cy + .get('button[data-tests-id="RemoveCondition"]') + .last() + .click() + .get('button[data-tests-id="addConditionGroup"]') + .click(); + + // try to delete element (1 of 2 items in group) + cy + .get('button[data-tests-id="RemoveCondition"]') + .last() + .click() + .get('input[data-tests-id="left"]') + .eq(2) + .type('KLM') + .should('have.value', 'KLM'); + + cy + .get('select[data-tests-id="selectOperator"]') + .eq(2) + .select('notEqual') + .get('input[data-tests-id="right"]') + .eq(2) + .type('MMM') + .should('have.value', 'MMM') + .get('input[data-tests-id="left"]') + .last() + .type('NOP') + .should('have.value', 'NOP'); + + cy + .get('select[data-tests-id="selectOperator"]') + .last() + .select('contains') + .get('input[data-tests-id="right"]') + .last() + .type('PPP') + .should('have.value', 'PPP'); + + cy + .get('button[data-tests-id="addCondition"]') + .last() + .click() + .get('input[data-tests-id="left"]') + .last() + .type('QQQ') + .should('have.value', 'QQQ'); + + cy + .get('select[data-tests-id="selectOperator"]') + .last() + .select('endsWith') + .get('input[data-tests-id="right"]') + .last() + .type('Q') + .should('have.value', 'Q') + .get('button[data-tests-id="RemoveCondition"]') + .last() + .click(); + + cy + .get('button[data-tests-id="removeConditionNode"]') + .last() + .click(); + }); + + it('add clear action', () => { + cy + .get('select[data-tests-id="selectAction"]') + .select('clear') + .get('button[data-tests-id="btnAddAction"]') + .click() + .get('input[data-tests-id="valueInput"]') + .type('ABC') + .should('have.value', 'ABC'); + + cy + .get('button[data-tests-id="btnAddInput"]') + .click() + .get('input[data-tests-id="valueInput"]') + .last() + .type('DEA') + .should('have.value', 'DEA'); + + cy + .get('button[data-tests-id="btnDelete"]') + .first() + .click(); + }); + + it('add replace text action', () => { + cy + .get('select[data-tests-id="selectAction"]') + .select('replace text') + .get('button[data-tests-id="btnAddAction"]') + .click(); + + cy + .get('input[data-tests-id="valueInput"]') + .type('ABC') + .should('have.value', 'ABC'); + + cy + .get('input[data-tests-id="InputFindWhat"]') + .type('AAA') + .should('have.value', 'AAA'); + + cy + .get('input[data-tests-id="InputReplaceWith"]') + .type('BBB') + .should('have.value', 'BBB'); + }); + + it('add log text action', () => { + cy + .get('select[data-tests-id="selectAction"]') + .select('log text') + .get('button[data-tests-id="btnAddAction"]') + .click(); + + cy + .get('input[data-tests-id="InputLogText"]') + .type('ABC') + .should('have.value', 'ABC'); + + cy + .get('input[data-tests-id="InputLogName"]') + .type('AAA') + .should('have.value', 'AAA'); + + cy + .get('input[data-tests-id="InputLogLevel"]') + .type('BBB') + .should('have.value', 'BBB'); + }); + + it('add log event action', () => { + cy + .get('select[data-tests-id="selectAction"]') + .select('log event') + .get('button[data-tests-id="btnAddAction"]') + .click(); + + cy + .get('input[data-tests-id="InputLogTitle"]') + .type('Title test') + .should('have.value', 'Title test'); + }); + }); + + describe('rule and Actions CRUD Procedure', () => { + beforeEach(() => { + cy.httpGetDDLData(); + cy.getMCListEmpty(); + cy.homePage(); + cy.get('button[data-tests-id="btn-create-mc"]').click(); + cy.fillNewMcForm(); + cy.httpCreateNewMc(); + cy.emptyRuleEngine('Type1'); + cy + .get('button[data-tests-id="createMonitoring"]') + .click() + .get('#ui-tabpanel-1-label') + .should('contain', 'map') + .click(); + cy.httpTargetTree(); + selectVersionAndTypeAndAddFirstRule(); + fillRuleDescription('newRule'); + }); + + it('add clear action', () => { + cy + .get('select[data-tests-id="selectAction"]') + .select('copy') + .get('button[data-tests-id="btnAddAction"]') + .click() + .get('select[data-tests-id="selectAction"]') + .select('concat') + .get('button[data-tests-id="btnAddAction"]') + .click() + .get('select[data-tests-id="selectAction"]') + .select('map') + .get('button[data-tests-id="btnAddAction"]') + .click() + .get('select[data-tests-id="selectAction"]') + .select('date formatter') + .get('button[data-tests-id="btnAddAction"]') + .click() + .get('select[data-tests-id="selectAction"]') + .select('log text') + .get('button[data-tests-id="btnAddAction"]') + .click() + .get('select[data-tests-id="selectAction"]') + .select('log event') + .get('button[data-tests-id="btnAddAction"]') + .click() + .get('select[data-tests-id="selectAction"]') + .select('replace text') + .get('button[data-tests-id="btnAddAction"]') + .click() + .get('select[data-tests-id="selectAction"]') + .select('clear') + .get('button[data-tests-id="btnAddAction"]') + .click(); + }); + + it('add rule with copy action CRUD procedure', () => { + // Create action + addCopyAction(); + + cy.doneSaveRule(); + cy.get('button[data-tests-id="btnDone"]').click(); + + // value approve + editFirstRule(); + + cy + .get('input[data-tests-id="valueInput"]') + .should('have.value', 'a') + .get('input[data-tests-id="inputTarget"]') + .should('have.value', 'event.commonEventHeader.domain') + + // change value + .get('input[data-tests-id="valueInput"]') + .type('B') + .get('button[data-tests-id="btnSave"]') + .click(); + cy.doneSaveAndEditRule(); + cy.get('button[data-tests-id="btnDone"]').click(); + + // Delete copy action + deleteFirstRule(); + }); + + it('add multiple rules CRUD procedure', () => { + // Create actions + addCopyAction(); + cy.doneSaveRule(); + cy.get('button[data-tests-id="btnDone"]').click(); + + // Edit copy action - verify values + editFirstRule(); + + cy + .get('input[data-tests-id="valueInput"]') + .should('have.value', 'a') + .get('input[data-tests-id="inputTarget"]') + .should('have.value', 'event.commonEventHeader.domain') + .get('button[data-tests-id="btnDone"]') + .click(); + + // Add new rule with map action + cy.get('button[data-tests-id="addMoreRule"]').click(); + fillRuleDescription('newRule2'); + addMapAndDeleteRowAction(); + cy.doneSaveMapRule(); + cy.get('button[data-tests-id="btnDone"]').click(); + + // Verify map values + editLastRule(); + + cy + .get('input[data-tests-id="key"]') + .first() + .should('have.value', 'Key1') + .get('input[data-tests-id="value"]') + .first() + .should('have.value', 'Key1') + .get('input[data-tests-id="key"]') + .last() + .should('have.value', 'Key2') + .get('input[data-tests-id="value"]') + .last() + .should('have.value', 'Key2'); + cy.get('button[data-tests-id="btnDone"]').click(); + + // Delete copy Action + deleteFirstRule(); + }); + + it('add rule with log text action CRUD procedure', () => { + cy + .get('select[data-tests-id="selectAction"]') + .select('log text') + .get('button[data-tests-id="btnAddAction"]') + .click(); + + cy + .get('input[data-tests-id="InputLogText"]') + .type('ABC') + .should('have.value', 'ABC'); + + cy + .get('input[data-tests-id="InputLogName"]') + .type('AAA') + .should('have.value', 'AAA'); + + cy + .get('input[data-tests-id="InputLogLevel"]') + .type('BBB') + .should('have.value', 'BBB'); + + cy.doneSaveLogTextRule(); + cy.get('button[data-tests-id="btnDone"]').click(); + + // value assertion + editFirstRule(); + + cy + .get('input[data-tests-id="InputLogText"]') + .should('have.value', 'ABC') + .get('input[data-tests-id="InputLogName"]') + .should('have.value', 'AAA') + .get('input[data-tests-id="InputLogLevel"]') + .should('have.value', 'BBB'); + + cy.get('button[data-tests-id="btnDone"]').click(); }); }); - describe('Translate And Save Rule List', () => { + describe('Translate and save Rule List', () => { beforeEach(() => { cy.httpGetDDLData(); cy.getMCListEmpty(); @@ -117,7 +724,7 @@ describe('Rule engine - E2E test flow with mock', () => { .click(); cy.httpTargetTree(); selectVersionAndTypeAndAddFirstRule(); - fillRuleDecription('newRule'); + fillRuleDescription('newRule'); addCopyAction(); cy.doneSaveRule(); }); @@ -159,7 +766,7 @@ describe('Rule engine - E2E test flow with mock', () => { .click() .get('.toast-container') .should('be.visible') - .get('.map-setting-list > #Type1 > input') + .get('.map-setting-list > form > #Type1 > input') .should('be.visible') .and('have.value', translateValue()); }); -- cgit 1.2.3-korg