parent
07ceb70278
commit
70fcc3d887
13 changed files with 142 additions and 77 deletions
|
@ -4,107 +4,77 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { HOSTS_PAGE_TAB_URLS } from '../../lib/urls';
|
||||
import {
|
||||
AUTHENTICATIONS_TABLE,
|
||||
getDraggableField,
|
||||
getPageButtonSelector,
|
||||
NAVIGATION_AUTHENTICATIONS,
|
||||
NAVIGATION_UNCOMMON_PROCESSES,
|
||||
NUMBERED_PAGINATION,
|
||||
SUPER_DATE_PICKER_APPLY_BUTTON,
|
||||
UNCOMMON_PROCCESSES_TABLE,
|
||||
} from '../../lib/pagination/selectors';
|
||||
import { DEFAULT_TIMEOUT, loginAndWaitForPage, waitForTableLoad } from '../../lib/util/helpers';
|
||||
import { HOSTS_PAGE_TAB_URLS } from '../../../urls/navigation';
|
||||
import { loginAndWaitForPage } from '../../../tasks/login';
|
||||
import { refreshPage } from '../../../tasks/header';
|
||||
import { goToFirstPage, goToThirdPage } from '../../../tasks/pagination';
|
||||
import { FIRST_PAGE_SELECTOR, THIRD_PAGE_SELECTOR } from '../../../screens/pagination';
|
||||
import { PROCESS_NAME_FIELD } from '../../../screens/uncommon_processes';
|
||||
import { waitForUncommonProcessesToBeLoaded } from '../../../tasks/uncommon_processes';
|
||||
import { waitForAuthenticationsToBeLoaded } from '../../../tasks/authentications';
|
||||
import { openAuthentications, openUncommonProcesses } from '../../../tasks/hosts/main';
|
||||
|
||||
describe('Pagination', () => {
|
||||
before(() => {
|
||||
loginAndWaitForPage(HOSTS_PAGE_TAB_URLS.uncommonProcesses);
|
||||
waitForTableLoad(UNCOMMON_PROCCESSES_TABLE);
|
||||
waitForUncommonProcessesToBeLoaded();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cy.get(getPageButtonSelector(0)).click({ force: true });
|
||||
goToFirstPage();
|
||||
});
|
||||
|
||||
it('pagination updates results and page number', () => {
|
||||
cy.get(getPageButtonSelector(0)).should('have.class', 'euiPaginationButton-isActive');
|
||||
cy.get(FIRST_PAGE_SELECTOR).should('have.class', 'euiPaginationButton-isActive');
|
||||
|
||||
cy.get(getDraggableField('process.name'))
|
||||
cy.get(PROCESS_NAME_FIELD)
|
||||
.first()
|
||||
.invoke('text')
|
||||
.then(text1 => {
|
||||
cy.get(getPageButtonSelector(2)).click({ force: true });
|
||||
// wait for table to be done loading
|
||||
waitForTableLoad(UNCOMMON_PROCCESSES_TABLE);
|
||||
cy.get(getDraggableField('process.name'))
|
||||
.then(processNameFirstPage => {
|
||||
goToThirdPage();
|
||||
waitForUncommonProcessesToBeLoaded();
|
||||
cy.get(PROCESS_NAME_FIELD)
|
||||
.first()
|
||||
.invoke('text')
|
||||
.should(text2 => {
|
||||
expect(text1).not.to.eq(text2);
|
||||
.should(processNameSecondPage => {
|
||||
expect(processNameFirstPage).not.to.eq(processNameSecondPage);
|
||||
});
|
||||
});
|
||||
cy.get(getPageButtonSelector(0)).should('not.have.class', 'euiPaginationButton-isActive');
|
||||
cy.get(getPageButtonSelector(2)).should('have.class', 'euiPaginationButton-isActive');
|
||||
cy.get(FIRST_PAGE_SELECTOR).should('not.have.class', 'euiPaginationButton-isActive');
|
||||
cy.get(THIRD_PAGE_SELECTOR).should('have.class', 'euiPaginationButton-isActive');
|
||||
});
|
||||
|
||||
it('pagination keeps track of page results when tabs change', () => {
|
||||
cy.get(getPageButtonSelector(0)).should('have.class', 'euiPaginationButton-isActive');
|
||||
let thirdPageResult: string;
|
||||
cy.get(getPageButtonSelector(2)).click({ force: true });
|
||||
// wait for table to be done loading
|
||||
waitForTableLoad(UNCOMMON_PROCCESSES_TABLE);
|
||||
cy.get(FIRST_PAGE_SELECTOR).should('have.class', 'euiPaginationButton-isActive');
|
||||
goToThirdPage();
|
||||
waitForUncommonProcessesToBeLoaded();
|
||||
|
||||
cy.get(getDraggableField('process.name'))
|
||||
cy.get(PROCESS_NAME_FIELD)
|
||||
.first()
|
||||
.invoke('text')
|
||||
.then(text2 => {
|
||||
thirdPageResult = `${text2}`;
|
||||
});
|
||||
cy.get(NAVIGATION_AUTHENTICATIONS).click({ force: true });
|
||||
waitForTableLoad(AUTHENTICATIONS_TABLE);
|
||||
// check authentications table starts at 1
|
||||
cy.get(getPageButtonSelector(0)).should('have.class', 'euiPaginationButton-isActive');
|
||||
|
||||
cy.get(NAVIGATION_UNCOMMON_PROCESSES).click({ force: true });
|
||||
waitForTableLoad(UNCOMMON_PROCCESSES_TABLE);
|
||||
// check uncommon processes table picks up at 3
|
||||
cy.get(getPageButtonSelector(2)).should('have.class', 'euiPaginationButton-isActive');
|
||||
cy.get(getDraggableField('process.name'))
|
||||
.first()
|
||||
.invoke('text')
|
||||
.should(text1 => {
|
||||
expect(text1).to.eq(thirdPageResult);
|
||||
.then(expectedThirdPageResult => {
|
||||
openAuthentications();
|
||||
waitForAuthenticationsToBeLoaded();
|
||||
cy.get(FIRST_PAGE_SELECTOR).should('have.class', 'euiPaginationButton-isActive');
|
||||
openUncommonProcesses();
|
||||
waitForUncommonProcessesToBeLoaded();
|
||||
cy.get(THIRD_PAGE_SELECTOR).should('have.class', 'euiPaginationButton-isActive');
|
||||
cy.get(PROCESS_NAME_FIELD)
|
||||
.first()
|
||||
.invoke('text')
|
||||
.should(actualThirdPageResult => {
|
||||
expect(expectedThirdPageResult).to.eq(actualThirdPageResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
* We only want to comment this code/test for now because it can be nondeterministic
|
||||
* when we figure out a way to really mock the data, we should come back to it
|
||||
*/
|
||||
it('pagination resets results and page number to first page when refresh is clicked', () => {
|
||||
cy.get(NUMBERED_PAGINATION, { timeout: DEFAULT_TIMEOUT });
|
||||
cy.get(getPageButtonSelector(0)).should('have.class', 'euiPaginationButton-isActive');
|
||||
// let firstResult: string;
|
||||
// cy.get(getDraggableField('user.name'))
|
||||
// .first()
|
||||
// .invoke('text')
|
||||
// .then(text1 => {
|
||||
// firstResult = `${text1}`;
|
||||
// });
|
||||
cy.get(getPageButtonSelector(2)).click({ force: true });
|
||||
waitForTableLoad(UNCOMMON_PROCCESSES_TABLE);
|
||||
cy.get(getPageButtonSelector(0)).should('not.have.class', 'euiPaginationButton-isActive');
|
||||
cy.get(SUPER_DATE_PICKER_APPLY_BUTTON)
|
||||
.last()
|
||||
.click({ force: true });
|
||||
waitForTableLoad(UNCOMMON_PROCCESSES_TABLE);
|
||||
cy.get(getPageButtonSelector(2)).should('have.class', 'euiPaginationButton-isActive');
|
||||
// cy.get(getDraggableField('user.name'))
|
||||
// .first()
|
||||
// .invoke('text')
|
||||
// .should(text1 => {
|
||||
// expect(text1).to.eq(firstResult);
|
||||
// });
|
||||
cy.get(FIRST_PAGE_SELECTOR).should('have.class', 'euiPaginationButton-isActive');
|
||||
goToThirdPage();
|
||||
waitForUncommonProcessesToBeLoaded();
|
||||
cy.get(FIRST_PAGE_SELECTOR).should('not.have.class', 'euiPaginationButton-isActive');
|
||||
refreshPage();
|
||||
waitForUncommonProcessesToBeLoaded();
|
||||
cy.get(FIRST_PAGE_SELECTOR).should('have.class', 'euiPaginationButton-isActive');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const AUTHENTICATIONS_TABLE = '[data-test-subj="table-authentications-loading-false"]';
|
|
@ -13,3 +13,5 @@ export const NETWORK = '[data-test-subj="navigation-network"]';
|
|||
export const OVERVIEW = '[data-test-subj="navigation-overview"]';
|
||||
|
||||
export const TIMELINES = '[data-test-subj="navigation-timelines"]';
|
||||
|
||||
export const REFRESH_BUTTON = '[data-test-subj="querySubmitButton"]';
|
||||
|
|
|
@ -6,4 +6,8 @@
|
|||
|
||||
export const EVENTS_TAB = '[data-test-subj="navigation-events"]';
|
||||
|
||||
export const AUTHENTICATIONS_TAB = '[data-test-subj="navigation-authentications"]';
|
||||
|
||||
export const UNCOMMON_PROCESSES_TAB = '[data-test-subj="navigation-uncommonProcesses"]';
|
||||
|
||||
export const KQL_SEARCH_BAR = '[data-test-subj="queryInput"]';
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const PROCESS_NAME = '[data-test-subj="draggable-content-process.name"]';
|
8
x-pack/legacy/plugins/siem/cypress/screens/pagination.ts
Normal file
8
x-pack/legacy/plugins/siem/cypress/screens/pagination.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const FIRST_PAGE_SELECTOR = '[data-test-subj="pagination-button-0"]';
|
||||
export const THIRD_PAGE_SELECTOR = '[data-test-subj="pagination-button-2"]';
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const PROCESS_NAME_FIELD = '[data-test-subj="draggable-content-process.name"]';
|
||||
export const UNCOMMON_PROCESSES_TABLE = '[data-test-subj="table-uncommonProcesses-loading-false"]';
|
12
x-pack/legacy/plugins/siem/cypress/tasks/authentications.ts
Normal file
12
x-pack/legacy/plugins/siem/cypress/tasks/authentications.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* 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 { AUTHENTICATIONS_TABLE } from '../screens/authentications';
|
||||
import { DEFAULT_TIMEOUT } from '../tasks/login';
|
||||
|
||||
export const waitForAuthenticationsToBeLoaded = () => {
|
||||
cy.get(AUTHENTICATIONS_TABLE, { timeout: DEFAULT_TIMEOUT }).should('exist');
|
||||
};
|
|
@ -4,8 +4,8 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { KQL_INPUT } from '../screens/header';
|
||||
import { DEFAULT_TIMEOUT } from '../tasks/login';
|
||||
import { REFRESH_BUTTON, KQL_INPUT } from '../screens/header';
|
||||
|
||||
export const navigateFromHeaderTo = (page: string) => {
|
||||
cy.get(page).click({ force: true });
|
||||
|
@ -16,3 +16,10 @@ export const clearSearchBar = () => {
|
|||
.clear()
|
||||
.type('{enter}');
|
||||
};
|
||||
|
||||
export const refreshPage = () => {
|
||||
cy.get(REFRESH_BUTTON)
|
||||
.click({ force: true })
|
||||
.invoke('text', { timeout: DEFAULT_TIMEOUT })
|
||||
.should('not.equal', 'Updating');
|
||||
};
|
||||
|
|
|
@ -6,8 +6,14 @@
|
|||
|
||||
import { DEFAULT_TIMEOUT } from '../../integration/lib/util/helpers';
|
||||
|
||||
import { EVENTS_TAB } from '../../screens/hosts/main';
|
||||
import { EVENTS_TAB, AUTHENTICATIONS_TAB, UNCOMMON_PROCESSES_TAB } from '../../screens/hosts/main';
|
||||
|
||||
/** Clicks the Events tab on the hosts page */
|
||||
export const openEvents = () =>
|
||||
cy.get(EVENTS_TAB, { timeout: DEFAULT_TIMEOUT }).click({ force: true });
|
||||
|
||||
export const openAuthentications = () =>
|
||||
cy.get(AUTHENTICATIONS_TAB, { timeout: DEFAULT_TIMEOUT }).click({ force: true });
|
||||
|
||||
export const openUncommonProcesses = () =>
|
||||
cy.get(UNCOMMON_PROCESSES_TAB, { timeout: DEFAULT_TIMEOUT }).click({ force: true });
|
||||
|
|
15
x-pack/legacy/plugins/siem/cypress/tasks/pagination.ts
Normal file
15
x-pack/legacy/plugins/siem/cypress/tasks/pagination.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* 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 { FIRST_PAGE_SELECTOR, THIRD_PAGE_SELECTOR } from '../screens/pagination';
|
||||
|
||||
export const goToFirstPage = () => {
|
||||
cy.get(FIRST_PAGE_SELECTOR).click({ force: true });
|
||||
};
|
||||
|
||||
export const goToThirdPage = () => {
|
||||
cy.get(THIRD_PAGE_SELECTOR).click({ force: true });
|
||||
};
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* 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 { UNCOMMON_PROCESSES_TABLE } from '../screens/uncommon_processes';
|
||||
import { DEFAULT_TIMEOUT } from '../tasks/login';
|
||||
|
||||
export const waitForUncommonProcessesToBeLoaded = () => {
|
||||
cy.get(UNCOMMON_PROCESSES_TABLE, { timeout: DEFAULT_TIMEOUT }).should('exist');
|
||||
};
|
|
@ -6,3 +6,10 @@
|
|||
|
||||
export const TIMELINES_PAGE = '/app/siem#/timelines';
|
||||
export const OVERVIEW_PAGE = '/app/siem#/overview';
|
||||
export const HOSTS_PAGE_TAB_URLS = {
|
||||
allHosts: '/app/siem#/hosts/allHosts',
|
||||
anomalies: '/app/siem#/hosts/anomalies',
|
||||
authentications: '/app/siem#/hosts/authentications',
|
||||
events: '/app/siem#/hosts/events',
|
||||
uncommonProcesses: '/app/siem#/hosts/uncommonProcesses',
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue