Skip to content

Commit

Permalink
Add cypress tests to paginated anomalies table
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum committed Apr 25, 2023
1 parent e187fd7 commit 34ebddc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
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,35 @@ describe('Entity Analytics Dashboard', () => {
});

describe('With anomalies data', () => {
before(() => {
esArchiverLoad('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', 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

0 comments on commit 34ebddc

Please sign in to comment.