Skip to content

Commit

Permalink
[Security Solutions] Display additional anomaly jobs in Entity Analyt…
Browse files Browse the repository at this point in the history
…ics Dashboard (#155520)

issue: elastic/security-team#6161
## Summary

* Adds more hardcoded jobs to the list of jobs displayed on the Notable
anomalies table
* Add pagination to the table
* Remove the logic that refreshes the table when a job is installed
* Move enableDataFeed logic to `<EnableJob />` and use the response from
the API to determine if the job was successfully installed.
* Recently installed jobs are no longer sorted so users can find the
jobs they have just installed.
* When the page refreshes all jobs are sorted


![Apr-21-2023
17-47-28](https://user-images.githubusercontent.com/1490444/233953871-e2583aa8-4d7b-402a-aef3-e001dfc7ae18.gif)

* I also replaced the loading spinner with a "Waiting" status when jobs
are waiting for machine learning nodes to start because the loading
spinner gave the false impression that the table would update at any
moment.

<img width="900" alt="Screenshot 2023-04-24 at 11 22 57"
src="https://user-images.githubusercontent.com/1490444/233956148-6c057d7c-7f89-4881-8d5c-88cbc27f9dff.png">


TODO 
- [x] Cypress tests


### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
machadoum authored Apr 25, 2023
1 parent 862103a commit 0ecb2cb
Show file tree
Hide file tree
Showing 19 changed files with 744 additions and 269 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ import {
USERS_TABLE_ALERT_CELL,
HOSTS_TABLE_ALERT_CELL,
HOSTS_TABLE,
ANOMALIES_TABLE_NEXT_PAGE_BUTTON,
ANOMALIES_TABLE_ENABLE_JOB_BUTTON,
ANOMALIES_TABLE_ENABLE_JOB_LOADER,
ANOMALIES_TABLE_COUNT_COLUMN,
} from '../../screens/entity_analytics';
import { openRiskTableFilterAndSelectTheLowOption } from '../../tasks/host_risk';
import { createRule } from '../../tasks/api_calls/rules';
import { waitForAlertsToPopulate } from '../../tasks/create_new_rule';
import { getNewRule } from '../../objects/rule';
import { clickOnFirstHostsAlerts, clickOnFirstUsersAlerts } from '../../tasks/risk_scores';
import { OPTION_LIST_LABELS, OPTION_LIST_VALUES } from '../../screens/common/filter_group';
import { setRowsPerPageTo } from '../../tasks/table_pagination';

const TEST_USER_ALERTS = 2;
const TEST_USER_NAME = 'test';
Expand Down Expand Up @@ -239,13 +244,39 @@ describe('Entity Analytics Dashboard', () => {
});

describe('With anomalies data', () => {
before(() => {
esArchiverLoad('network');
});

after(() => {
esArchiverUnload('network');
});

beforeEach(() => {
visit(ENTITY_ANALYTICS_URL);
});

it('renders table', () => {
it('renders table with pagination', () => {
cy.get(ANOMALIES_TABLE).should('be.visible');
cy.get(ANOMALIES_TABLE_ROWS).should('have.length', 6);
cy.get(ANOMALIES_TABLE_ROWS).should('have.length', 10);

// navigates to next page
cy.get(ANOMALIES_TABLE_NEXT_PAGE_BUTTON).click();
cy.get(ANOMALIES_TABLE_ROWS).should('have.length', 10);

// updates rows per page to 25 items
setRowsPerPageTo(25);
cy.get(ANOMALIES_TABLE_ROWS).should('have.length', 25);
});

it('enables a job', () => {
cy.get(ANOMALIES_TABLE_ROWS)
.eq(5)
.within(() => {
cy.get(ANOMALIES_TABLE_ENABLE_JOB_BUTTON).click();
cy.get(ANOMALIES_TABLE_ENABLE_JOB_LOADER).should('be.visible');
cy.get(ANOMALIES_TABLE_COUNT_COLUMN).should('include.text', '0');
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ export const ANOMALIES_TABLE =

export const ANOMALIES_TABLE_ROWS = '[data-test-subj="entity_analytics_anomalies"] .euiTableRow';

export const ANOMALIES_TABLE_ENABLE_JOB_BUTTON = '[data-test-subj="enable-job"]';

export const ANOMALIES_TABLE_ENABLE_JOB_LOADER = '[data-test-subj="job-switch-loader"]';

export const ANOMALIES_TABLE_COUNT_COLUMN = '[data-test-subj="anomalies-table-column-count"]';

export const ANOMALIES_TABLE_NEXT_PAGE_BUTTON =
'[data-test-subj="entity_analytics_anomalies"] [data-test-subj="pagination-button-next"]';

export const UPGRADE_CONFIRMATION_MODAL = (riskScoreEntity: RiskScoreEntity) =>
`[data-test-subj="${riskScoreEntity}-risk-score-upgrade-confirmation-modal"]`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,9 @@ describe('useNotableAnomaliesSearch', () => {
await waitForNextUpdate();

const names = result.current.data.map(({ name }) => name);
expect(names).toEqual([
firstJobSecurityName,
secondJobSecurityName,
'packetbeat_dns_tunneling',
'packetbeat_rare_dns_question',
'packetbeat_rare_server_domain',
'suspicious_login_activity',
]);

expect(names[0]).toEqual(firstJobSecurityName);
expect(names[1]).toEqual(secondJobSecurityName);
});
});

Expand Down
Loading

0 comments on commit 0ecb2cb

Please sign in to comment.