Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIEM] Adds 'Closes one signal when more than one opened signals are selected' test again #60380

Merged
merged 2 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
*/
import {
NUMBER_OF_SIGNALS,
OPEN_CLOSE_SIGNALS_BTN,
SELECTED_SIGNALS,
SHOWING_SIGNALS,
SIGNALS,
} from '../screens/detections';

import {
closeFirstSignal,
closeSignals,
goToClosedSignals,
goToOpenedSignals,
Expand All @@ -26,7 +28,7 @@ import { loginAndWaitForPage } from '../tasks/login';
import { DETECTIONS } from '../urls/navigation';

describe('Detections', () => {
before(() => {
beforeEach(() => {
esArchiverLoad('signals');
loginAndWaitForPage(DETECTIONS);
});
Expand All @@ -53,6 +55,7 @@ describe('Detections', () => {
waitForSignals();
cy.reload();
waitForSignals();
waitForSignalsToBeLoaded();

const expectedNumberOfSignalsAfterClosing = +numberOfSignals - numberOfSignalsToBeClosed;
cy.get(NUMBER_OF_SIGNALS)
Expand Down Expand Up @@ -111,4 +114,43 @@ describe('Detections', () => {
.should('eql', expectedNumberOfOpenedSignals.toString());
});
});

it('Closes one signal when more than one opened signals are selected', () => {
waitForSignalsToBeLoaded();

cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.then(numberOfSignals => {
const numberOfSignalsToBeClosed = 1;
const numberOfSignalsToBeSelected = 3;

cy.get(OPEN_CLOSE_SIGNALS_BTN).should('have.attr', 'disabled');
selectNumberOfSignals(numberOfSignalsToBeSelected);
cy.get(OPEN_CLOSE_SIGNALS_BTN).should('not.have.attr', 'disabled');

closeFirstSignal();
cy.reload();
waitForSignalsToBeLoaded();
waitForSignals();

const expectedNumberOfSignals = +numberOfSignals - numberOfSignalsToBeClosed;
cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eq', expectedNumberOfSignals.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfSignals.toString()} signals`);

goToClosedSignals();
waitForSignals();

cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eql', numberOfSignalsToBeClosed.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${numberOfSignalsToBeClosed.toString()} signal`);
cy.get(SIGNALS).should('have.length', numberOfSignalsToBeClosed);
});
});
});
4 changes: 3 additions & 1 deletion x-pack/legacy/plugins/siem/cypress/screens/detections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export const MANAGE_SIGNAL_DETECTION_RULES_BTN = '[data-test-subj="manage-signal

export const NUMBER_OF_SIGNALS = '[data-test-subj="server-side-event-count"]';

export const OPEN_CLOSE_SIGNALS_BTN = '[data-test-subj="openCloseSignal"] .siemLinkIcon__label';
export const OPEN_CLOSE_SIGNAL_BTN = '[data-test-subj="update-signal-status-button"]';

export const OPEN_CLOSE_SIGNALS_BTN = '[data-test-subj="openCloseSignal"] button';

export const OPENED_SIGNALS_BTN = '[data-test-subj="openSignals"]';

Expand Down
7 changes: 7 additions & 0 deletions x-pack/legacy/plugins/siem/cypress/tasks/detections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ import {
CLOSED_SIGNALS_BTN,
LOADING_SIGNALS_PANEL,
MANAGE_SIGNAL_DETECTION_RULES_BTN,
OPEN_CLOSE_SIGNAL_BTN,
OPEN_CLOSE_SIGNALS_BTN,
OPENED_SIGNALS_BTN,
SIGNALS,
SIGNAL_CHECKBOX,
} from '../screens/detections';
import { REFRESH_BUTTON } from '../screens/siem_header';

export const closeFirstSignal = () => {
cy.get(OPEN_CLOSE_SIGNAL_BTN)
.first()
.click({ force: true });
};

export const closeSignals = () => {
cy.get(OPEN_CLOSE_SIGNALS_BTN).click({ force: true });
};
Expand Down