Skip to content

Commit

Permalink
adds 'closes and opens signals'
Browse files Browse the repository at this point in the history
  • Loading branch information
MadameSheema committed Mar 12, 2020
1 parent 202fb11 commit b1d41e4
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 5 deletions.
119 changes: 119 additions & 0 deletions x-pack/legacy/plugins/siem/cypress/integration/detections.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { esArchiverLoad } from '../tasks/es_archiver';
import { loginAndWaitForPage } from '../tasks/login';
import { DETECTIONS } from '../urls/navigation';
import { REFRESH_BUTTON } from '../screens/siem_header';
import { waitForSignalsIndexToBeCreated } from '../tasks/detections';

describe('Detections', () => {
before(() => {
esArchiverLoad('signals');
loginAndWaitForPage(DETECTIONS);
});

it('Closes and opens signals', () => {
cy.get('[data-test-subj="loading-signals-panel"]').should('exist');
cy.get('[data-test-subj="loading-signals-panel"]').should('not.exist');

cy.get(REFRESH_BUTTON)
.invoke('text')
.should('not.equal', 'Updating');
cy.get('[data-test-subj="event"]').should('have.length', 25);

waitForSignalsIndexToBeCreated();

cy.get('[data-test-subj="server-side-event-count"]')
.invoke('text')
.then(numberOfSignals => {
cy.get('[data-test-subj="showingRules"]')
.invoke('text')
.should('eql', `Showing ${numberOfSignals} signals`);

for (let i = 0; i < 3; i++) {
cy.get('[data-test-subj="select-event-container"] .euiCheckbox__input')
.eq(i)
.click({ force: true });
}
// cy.wait(1000);
cy.get('[data-test-subj="openCloseSignal"] .siemLinkIcon__label').click({ force: true });

cy.get(REFRESH_BUTTON)
.invoke('text')
.should('not.equal', 'Updating');

waitForSignalsIndexToBeCreated();

const expected = +numberOfSignals - 3;
// cy.wait(5000);
// cy.pause();
cy.get('[data-test-subj="server-side-event-count"]')
.invoke('text')
.should('eq', expected.toString());
cy.get('[data-test-subj="showingRules"]')
.invoke('text')
.should('eql', `Showing ${expected.toString()} signals`);

cy.get('[data-test-subj="closedSignals"]').click({ force: true });

// cy.wait(3000);

cy.get(REFRESH_BUTTON)
.invoke('text')
.should('not.equal', 'Updating');

cy.get('[data-test-subj=server-side-event-count]')
.invoke('text')
.should('eql', '3');
cy.get('[data-test-subj="showingRules"]')
.invoke('text')
.should('eql', `Showing 3 signals`);
cy.get('[data-test-subj="event"]').should('have.length', 3);

for (let i = 0; i < 1; i++) {
cy.get('[data-test-subj="select-event-container"] .euiCheckbox__input')
.eq(i)
.click({ force: true });
}

// cy.wait(5000);
// cy.pause();

cy.get('[data-test-subj="openCloseSignal"] .siemLinkIcon__label').click({ force: true });

cy.get(REFRESH_BUTTON)
.invoke('text')
.should('not.equal', 'Updating');

waitForSignalsIndexToBeCreated();

// cy.wait(5000)

cy.get('[data-test-subj=server-side-event-count]')
.invoke('text')
.should('eql', '2');
cy.get('[data-test-subj="showingRules"]')
.invoke('text')
.should('eql', `Showing 2 signals`);

cy.get('[data-test-subj="event"]').should('have.length', 2);

cy.get('[data-test-subj=openSignals]').click({ force: true });

// cy.wait(5000);
// cy.pause();

cy.get('[data-test-subj="showingRules"]')
.invoke('text')
.should('eql', `Showing 106 signals`);

cy.get('[data-test-subj="server-side-event-count"]')
.invoke('text')
.should('eql', '106');
});
});
});
8 changes: 8 additions & 0 deletions x-pack/legacy/plugins/siem/cypress/tasks/es_archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export const esArchiverLoadEmptyKibana = () => {
);
};

export const esArchiverLoad = (folder: string) => {
cy.exec(
`node ../../../../scripts/es_archiver load ${folder} --dir ../../../test/siem_cypress/es_archives --config ../../../../test/functional/config.js --es-url ${Cypress.env(
'ELASTICSEARCH_URL'
)} --kibana-url ${Cypress.config().baseUrl}`
);
};

export const esArchiverUnloadEmptyKibana = () => {
cy.exec(
`node ../../../../scripts/es_archiver empty_kibana unload empty--dir ../../../test/siem_cypress/es_archives --config ../../../../test/functional/config.js --es-url ${Cypress.env(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,23 @@ Popover.displayName = 'Popover';

export interface UtilityBarActionProps extends LinkIconProps {
popoverContent?: (closePopover: () => void) => React.ReactNode;
dataTestSubj?: string;
}

export const UtilityBarAction = React.memo<UtilityBarActionProps>(
({ children, color, disabled, href, iconSide, iconSize, iconType, onClick, popoverContent }) => (
<BarAction>
({
children,
color,
dataTestSubj,
disabled,
href,
iconSide,
iconSize,
iconType,
onClick,
popoverContent,
}) => (
<BarAction data-test-subj={dataTestSubj}>
{popoverContent ? (
<Popover
color={color}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import { BarText } from './styles';

export interface UtilityBarTextProps {
children: string;
dataTestSubj?: string;
}

export const UtilityBarText = React.memo<UtilityBarTextProps>(({ children }) => (
<BarText>{children}</BarText>
export const UtilityBarText = React.memo<UtilityBarTextProps>(({ children, dataTestSubj }) => (
<BarText data-test-subj={dataTestSubj}>{children}</BarText>
));

UtilityBarText.displayName = 'UtilityBarText';
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const SignalsTableFilterGroupComponent: React.FC<Props> = ({ onFilterGroupChange
return (
<EuiFilterGroup>
<EuiFilterButton
data-test-subj="openSignals"
hasActiveFilters={filterGroup === FILTER_OPEN}
onClick={onClickOpenFilterCallback}
withNext
Expand All @@ -40,6 +41,7 @@ const SignalsTableFilterGroupComponent: React.FC<Props> = ({ onFilterGroupChange
</EuiFilterButton>

<EuiFilterButton
data-test-subj="closedSignals"
hasActiveFilters={filterGroup === FILTER_CLOSED}
onClick={onClickCloseFilterCallback}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const SignalsUtilityBarComponent: React.FC<SignalsUtilityBarProps> = ({
<UtilityBar>
<UtilityBarSection>
<UtilityBarGroup>
<UtilityBarText>{i18n.SHOWING_SIGNALS(formattedTotalCount, totalCount)}</UtilityBarText>
<UtilityBarText dataTestSubj="showingRules">
{i18n.SHOWING_SIGNALS(formattedTotalCount, totalCount)}
</UtilityBarText>
</UtilityBarGroup>

<UtilityBarGroup>
Expand All @@ -79,6 +81,7 @@ const SignalsUtilityBarComponent: React.FC<SignalsUtilityBarProps> = ({
</UtilityBarText>

<UtilityBarAction
dataTestSubj="openCloseSignal"
disabled={areEventsLoading || isEmpty(selectedEventIds)}
iconType={isFilteredToOpen ? 'securitySignalResolved' : 'securitySignalDetected'}
onClick={handleUpdateStatus}
Expand Down

0 comments on commit b1d41e4

Please sign in to comment.