Skip to content

Commit

Permalink
adds 'Open one signal when more than one closed signals are selected'…
Browse files Browse the repository at this point in the history
… test'
  • Loading branch information
MadameSheema committed Mar 18, 2020
1 parent ab6fbc9 commit a67a82f
Show file tree
Hide file tree
Showing 2 changed files with 182 additions and 123 deletions.
299 changes: 176 additions & 123 deletions x-pack/legacy/plugins/siem/cypress/integration/detections.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
closeSignals,
goToClosedSignals,
goToOpenedSignals,
openFirstSignal,
openSignals,
selectNumberOfSignals,
waitForSignalsPanelToBeLoaded,
Expand All @@ -28,129 +29,181 @@ import { loginAndWaitForPage } from '../tasks/login';
import { DETECTIONS } from '../urls/navigation';

describe('Detections', () => {
beforeEach(() => {
esArchiverLoad('signals');
loginAndWaitForPage(DETECTIONS);
context('Closing signals', () => {
beforeEach(() => {
esArchiverLoad('signals');
loginAndWaitForPage(DETECTIONS);
});

it('Closes and opens signals', () => {
waitForSignalsPanelToBeLoaded();
waitForSignalsToBeLoaded();

cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.then(numberOfSignals => {
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${numberOfSignals} signals`);

const numberOfSignalsToBeClosed = 3;
selectNumberOfSignals(numberOfSignalsToBeClosed);

cy.get(SELECTED_SIGNALS)
.invoke('text')
.should('eql', `Selected ${numberOfSignalsToBeClosed} signals`);

closeSignals();
waitForSignals();
cy.reload();
waitForSignals();

const expectedNumberOfSignalsAfterClosing = +numberOfSignals - numberOfSignalsToBeClosed;
cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eq', expectedNumberOfSignalsAfterClosing.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfSignalsAfterClosing.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()} signals`);
cy.get(SIGNALS).should('have.length', numberOfSignalsToBeClosed);

const numberOfSignalsToBeOpened = 1;
selectNumberOfSignals(numberOfSignalsToBeOpened);

cy.get(SELECTED_SIGNALS)
.invoke('text')
.should('eql', `Selected ${numberOfSignalsToBeOpened} signal`);

openSignals();
waitForSignals();
cy.reload();
waitForSignalsToBeLoaded();
waitForSignals();
goToClosedSignals();
waitForSignals();

const expectedNumberOfClosedSignalsAfterOpened = 2;
cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eql', expectedNumberOfClosedSignalsAfterOpened.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should(
'eql',
`Showing ${expectedNumberOfClosedSignalsAfterOpened.toString()} signals`
);
cy.get(SIGNALS).should('have.length', expectedNumberOfClosedSignalsAfterOpened);

goToOpenedSignals();
waitForSignals();

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

cy.get('[data-test-subj="server-side-event-count"]')
.invoke('text')
.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);
});
});
});

it('Closes and opens signals', () => {
waitForSignalsPanelToBeLoaded();
waitForSignalsToBeLoaded();

cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.then(numberOfSignals => {
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${numberOfSignals} signals`);

const numberOfSignalsToBeClosed = 3;
selectNumberOfSignals(numberOfSignalsToBeClosed);

cy.get(SELECTED_SIGNALS)
.invoke('text')
.should('eql', `Selected ${numberOfSignalsToBeClosed} signals`);

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

const expectedNumberOfSignalsAfterClosing = +numberOfSignals - numberOfSignalsToBeClosed;
cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eq', expectedNumberOfSignalsAfterClosing.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfSignalsAfterClosing.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()} signals`);
cy.get(SIGNALS).should('have.length', numberOfSignalsToBeClosed);

const numberOfSignalsToBeOpened = 1;
selectNumberOfSignals(numberOfSignalsToBeOpened);

cy.get(SELECTED_SIGNALS)
.invoke('text')
.should('eql', `Selected ${numberOfSignalsToBeOpened} signal`);

openSignals();
waitForSignals();
cy.reload();
waitForSignalsToBeLoaded();
waitForSignals();
goToClosedSignals();
waitForSignals();

const expectedNumberOfClosedSignalsAfterOpened = 2;
cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eql', expectedNumberOfClosedSignalsAfterOpened.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfClosedSignalsAfterOpened.toString()} signals`);
cy.get(SIGNALS).should('have.length', expectedNumberOfClosedSignalsAfterOpened);

goToOpenedSignals();
waitForSignals();

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

cy.get('[data-test-subj="server-side-event-count"]')
.invoke('text')
.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);
});
context('Opening signals', () => {
beforeEach(() => {
esArchiverLoad('closed_signals');
loginAndWaitForPage(DETECTIONS);
});

it('Open one signal when more than one closed signals are selected', () => {
waitForSignals();
goToClosedSignals();
waitForSignalsToBeLoaded();

cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.then(numberOfSignals => {
const numberOfSignalsToBeOpened = 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');

openFirstSignal();
cy.reload();
goToClosedSignals();
waitForSignalsToBeLoaded();
waitForSignals();

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

goToOpenedSignals();
waitForSignals();

cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eql', numberOfSignalsToBeOpened.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${numberOfSignalsToBeOpened.toString()} signal`);
cy.get(SIGNALS).should('have.length', numberOfSignalsToBeOpened);
});
});
});
});
6 changes: 6 additions & 0 deletions x-pack/legacy/plugins/siem/cypress/tasks/detections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export const goToOpenedSignals = () => {
cy.get(OPENED_SIGNALS_BTN).click({ force: true });
};

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

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

0 comments on commit a67a82f

Please sign in to comment.