summaryrefslogtreecommitdiffstats
path: root/public/cypress/integration/mocks/ruleEngine-spec.ts
diff options
context:
space:
mode:
authorStone, Avi (as206k) <as206k@att.com>2018-04-12 16:36:39 +0300
committerStone, Avi (as206k) <as206k@att.com>2018-04-12 16:36:39 +0300
commit9b2ceb347a3371819fcad6bbe2268203afecaf4e (patch)
treefbb5ea2c147d71dfeeec0882b215423e7b7206b4 /public/cypress/integration/mocks/ruleEngine-spec.ts
parent72dc8e3298d3e4315cdd9717b778671cb0b625bc (diff)
DCAE-D fe initial commit
DCAE-D fe initial commit Change-Id: Ica8ccb7c7ef769c969664d1e168d205eb9fc67f2 Issue-ID: SDC-1218 Signed-off-by: Stone, Avi (as206k) <as206k@att.com>
Diffstat (limited to 'public/cypress/integration/mocks/ruleEngine-spec.ts')
-rw-r--r--public/cypress/integration/mocks/ruleEngine-spec.ts168
1 files changed, 168 insertions, 0 deletions
diff --git a/public/cypress/integration/mocks/ruleEngine-spec.ts b/public/cypress/integration/mocks/ruleEngine-spec.ts
new file mode 100644
index 0000000..9a75b87
--- /dev/null
+++ b/public/cypress/integration/mocks/ruleEngine-spec.ts
@@ -0,0 +1,168 @@
+export const mappingTragetDDL = () => {
+ return cy.get('select[data-tests-id="mappingDdl"]');
+};
+
+export const selectVersionAndTypeAndAddFirstRule = () => {
+ return cy
+ .get('select[data-tests-id="selectVersion"]')
+ .select('4.1')
+ .get('select[data-tests-id="selectEventType"]')
+ .select('syslog')
+ .get('button[data-tests-id="btnAddFirstRule"]')
+ .click();
+};
+
+export const fillRuleDecription = text => {
+ return cy
+ .get('input[data-tests-id="inputDescription"]')
+ .clear()
+ .type(text);
+};
+
+export const addCopyAction = () => {
+ return cy
+ .get('select[data-tests-id="selectAction"]')
+ .select('copy')
+ .get('button[data-tests-id="btnAddAction"]')
+ .click()
+ .get('input[data-tests-id="valueInput"]')
+ .type('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();
+ }
+ });
+};
+
+export const editFirstRule = () => {
+ return cy
+ .get('div[data-tests-id="ruleElement"]')
+ .first()
+ .trigger('mouseover')
+ .get('button[data-tests-id="editRule"]')
+ .should('be.visible')
+ .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"}]}]}';
+};
+
+describe('Rule engine - E2E test flow with mock', () => {
+ describe('Mapping target select', () => {
+ 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();
+ cy
+ .get('#ui-tabpanel-1-label')
+ .should('contain', 'map')
+ .click();
+ });
+
+ it('should exist and contain options', () => {
+ mappingTragetDDL()
+ .should('be.visible')
+ .contains('json');
+ });
+
+ it('should page refrash after change select value in mapping target ddl', () => {
+ cy.httpTargetTree();
+ 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);
+ });
+ });
+
+ describe('Translate And Save Rule List', () => {
+ 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();
+ fillRuleDecription('newRule');
+ addCopyAction();
+ cy.doneSaveRule();
+ });
+
+ context('Play with save, back and done button', () => {
+ it('should rule exist in list after save rule and click back', () => {
+ cy
+ .get('button[data-tests-id="btnSave"]')
+ .click()
+ .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('newRule');
+ });
+ });
+
+ it('should rule exist in list after done edit rule', () => {
+ cy
+ .get('button[data-tests-id="btnDone"]')
+ .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('newRule');
+ });
+ });
+ });
+
+ context('Translate', () => {
+ it('should open advanced setting when translate successfuly', () => {
+ cy.get('button[data-tests-id="btnDone"]').click();
+ cy.httpTransalte();
+ cy
+ .get('button[data-tests-id="btnTranslate"]')
+ .click()
+ .get('.toast-container')
+ .should('be.visible')
+ .get('.map-setting-list > #Type1 > input')
+ .should('be.visible')
+ .and('have.value', translateValue());
+ });
+ });
+ });
+});