Skip to content

Commit

Permalink
adding more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yctercero committed Mar 1, 2021
1 parent 02b5e91 commit 4fecd10
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ import {
} from '../../tasks/create_new_rule';
import { saveEditedRule, waitForKibana } from '../../tasks/edit_rule';
import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login';
import { activatesRule } from '../../tasks/rule_details';

import { DETECTIONS_URL } from '../../urls/navigation';

Expand Down Expand Up @@ -308,6 +309,21 @@ describe('Custom detection rules deletion and edition', () => {
reload();
});

it('Only modifies rule active status on enable/disable', () => {
activatesRule();

cy.intercept('GET', `/api/detection_engine/rules?id=`).as('fetchRuleDetails');

goToRuleDetails();

cy.wait('@fetchRuleDetails').then(({ response }) => {
cy.wrap(response!.statusCode).should('eql', 200);

cy.wrap(response!.body.max_signals).should('eql', existingRule.maxSignals);
cy.wrap(response!.body.enabled).should('eql', false);
});
});

it('Allows a rule to be edited', () => {
editFirstRule();
waitForKibana();
Expand Down Expand Up @@ -354,7 +370,7 @@ describe('Custom detection rules deletion and edition', () => {

cy.wait('@getRule').then(({ response }) => {
cy.wrap(response!.statusCode).should('eql', 200);
// ensure that editing rule does not modify
// ensure that editing rule does not modify max_signals
cy.wrap(response!.body.max_signals).should('eql', existingRule.maxSignals);
});

Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/security_solution/cypress/objects/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ export const existingRule: CustomRule = {
runsEvery,
lookBack,
timeline,
// Please do not change, or if you do, needs
// to be any number other than default value
maxSignals: 500,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ export const activatesRule = () => {
});
};

export const deactivatesRule = () => {
cy.get(RULE_SWITCH).should('be.visible');
cy.get(RULE_SWITCH).click();
};

export const addsException = (exception: Exception) => {
cy.get(LOADING_SPINNER).should('exist');
cy.get(LOADING_SPINNER).should('not.exist');
Expand Down

0 comments on commit 4fecd10

Please sign in to comment.