[SIEM] Improves fields browser Cypress tests time execution (#54236)
* groups fields browser tests by context * saves cookies between tests * fix types * renames 'cleansFieldsBrowser' to 'clearFieldsBrowser' * adds 'SID cookie to whitelist' * fixes type check Co-authored-by: patrykkopycinski <contact@patrykkopycinski.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
c0d6b932f1
commit
cc09f61d3b
|
@ -42,3 +42,7 @@ export const clickOutsideFieldsBrowser = () => {
|
|||
export const filterFieldsBrowser = (fieldName: string) => {
|
||||
cy.get(FIELDS_BROWSER_FILTER_INPUT).type(fieldName);
|
||||
};
|
||||
|
||||
export const clearFieldsBrowser = () => {
|
||||
cy.get(FIELDS_BROWSER_FILTER_INPUT).type('{selectall}{backspace}');
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { drag, drop } from '../../lib/drag_n_drop/helpers';
|
||||
import {
|
||||
clearFieldsBrowser,
|
||||
clickOutsideFieldsBrowser,
|
||||
openTimelineFieldsBrowser,
|
||||
populateTimeline,
|
||||
|
@ -37,233 +38,200 @@ const defaultHeaders = [
|
|||
];
|
||||
|
||||
describe('Fields Browser', () => {
|
||||
beforeEach(() => {
|
||||
loginAndWaitForPage(HOSTS_PAGE);
|
||||
});
|
||||
|
||||
it('renders the fields browser with the expected title when the Fields button is clicked', () => {
|
||||
populateTimeline();
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
cy.get(FIELDS_BROWSER_TITLE)
|
||||
.invoke('text')
|
||||
.should('eq', 'Customize Columns');
|
||||
});
|
||||
|
||||
it('closes the fields browser when the user clicks outside of it', () => {
|
||||
populateTimeline();
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
clickOutsideFieldsBrowser();
|
||||
|
||||
cy.get(FIELDS_BROWSER_CONTAINER).should('not.exist');
|
||||
});
|
||||
|
||||
it('displays the `default ECS` category (by default)', () => {
|
||||
populateTimeline();
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
cy.get(FIELDS_BROWSER_SELECTED_CATEGORY_TITLE)
|
||||
.invoke('text')
|
||||
.should('eq', 'default ECS');
|
||||
});
|
||||
|
||||
it('the `defaultECS` (selected) category count matches the default timeline header count', () => {
|
||||
populateTimeline();
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
cy.get(FIELDS_BROWSER_SELECTED_CATEGORY_COUNT)
|
||||
.invoke('text')
|
||||
.should('eq', `${defaultHeaders.length}`);
|
||||
});
|
||||
|
||||
it('displays a checked checkbox for all of the default timeline columns', () => {
|
||||
populateTimeline();
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
defaultHeaders.forEach(header =>
|
||||
cy.get(`[data-test-subj="field-${header.id}-checkbox"]`).should('be.checked')
|
||||
);
|
||||
});
|
||||
|
||||
it('removes the message field from the timeline when the user un-checks the field', () => {
|
||||
const toggleField = 'message';
|
||||
|
||||
populateTimeline();
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'exist'
|
||||
);
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="field-${toggleField}-checkbox"]`).uncheck({
|
||||
force: true,
|
||||
context('Fields Browser rendering', () => {
|
||||
before(() => {
|
||||
loginAndWaitForPage(HOSTS_PAGE);
|
||||
populateTimeline();
|
||||
openTimelineFieldsBrowser();
|
||||
});
|
||||
|
||||
clickOutsideFieldsBrowser();
|
||||
afterEach(() => {
|
||||
clearFieldsBrowser();
|
||||
});
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'not.exist'
|
||||
);
|
||||
it('renders the fields browser with the expected title when the Fields button is clicked', () => {
|
||||
cy.get(FIELDS_BROWSER_TITLE)
|
||||
.invoke('text')
|
||||
.should('eq', 'Customize Columns');
|
||||
});
|
||||
|
||||
it('displays the `default ECS` category (by default)', () => {
|
||||
cy.get(FIELDS_BROWSER_SELECTED_CATEGORY_TITLE)
|
||||
.invoke('text')
|
||||
.should('eq', 'default ECS');
|
||||
});
|
||||
|
||||
it('the `defaultECS` (selected) category count matches the default timeline header count', () => {
|
||||
cy.get(FIELDS_BROWSER_SELECTED_CATEGORY_COUNT)
|
||||
.invoke('text')
|
||||
.should('eq', `${defaultHeaders.length}`);
|
||||
});
|
||||
|
||||
it('displays a checked checkbox for all of the default timeline columns', () => {
|
||||
defaultHeaders.forEach(header =>
|
||||
cy.get(`[data-test-subj="field-${header.id}-checkbox"]`).should('be.checked')
|
||||
);
|
||||
});
|
||||
|
||||
it('displays the expected count of categories that match the filter input', () => {
|
||||
const filterInput = 'host.mac';
|
||||
|
||||
filterFieldsBrowser(filterInput);
|
||||
|
||||
cy.get(FIELDS_BROWSER_CATEGORIES_COUNT)
|
||||
.invoke('text')
|
||||
.should('eq', '2 categories');
|
||||
});
|
||||
|
||||
it('displays a search results label with the expected count of fields matching the filter input', () => {
|
||||
const filterInput = 'host.mac';
|
||||
|
||||
filterFieldsBrowser(filterInput);
|
||||
|
||||
cy.get(FIELDS_BROWSER_FILTER_INPUT, { timeout: DEFAULT_TIMEOUT }).should(
|
||||
'not.have.class',
|
||||
'euiFieldSearch-isLoading'
|
||||
);
|
||||
|
||||
cy.get(FIELDS_BROWSER_HOST_CATEGORIES_COUNT)
|
||||
.invoke('text')
|
||||
.then(hostCategoriesCount => {
|
||||
cy.get(FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT)
|
||||
.invoke('text')
|
||||
.then(systemCategoriesCount => {
|
||||
cy.get(FIELDS_BROWSER_FIELDS_COUNT)
|
||||
.invoke('text')
|
||||
.should('eq', `${+hostCategoriesCount + +systemCategoriesCount} fields`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('displays a count of only the fields in the selected category that match the filter input', () => {
|
||||
const filterInput = 'host.geo.c';
|
||||
|
||||
filterFieldsBrowser(filterInput);
|
||||
|
||||
cy.get(FIELDS_BROWSER_SELECTED_CATEGORY_COUNT)
|
||||
.invoke('text')
|
||||
.should('eq', '4');
|
||||
});
|
||||
});
|
||||
|
||||
it('displays the expected count of categories that match the filter input', () => {
|
||||
const filterInput = 'host.mac';
|
||||
context('Editing the timeline', () => {
|
||||
before(() => {
|
||||
loginAndWaitForPage(HOSTS_PAGE);
|
||||
populateTimeline();
|
||||
openTimelineFieldsBrowser();
|
||||
});
|
||||
|
||||
populateTimeline();
|
||||
afterEach(() => {
|
||||
openTimelineFieldsBrowser();
|
||||
clearFieldsBrowser();
|
||||
});
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
it('removes the message field from the timeline when the user un-checks the field', () => {
|
||||
const toggleField = 'message';
|
||||
|
||||
filterFieldsBrowser(filterInput);
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'exist'
|
||||
);
|
||||
|
||||
cy.get(FIELDS_BROWSER_CATEGORIES_COUNT)
|
||||
.invoke('text')
|
||||
.should('eq', '2 categories');
|
||||
});
|
||||
|
||||
it('displays a search results label with the expected count of fields matching the filter input', () => {
|
||||
const filterInput = 'host.mac';
|
||||
|
||||
populateTimeline();
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
filterFieldsBrowser(filterInput);
|
||||
|
||||
cy.get(FIELDS_BROWSER_FILTER_INPUT, { timeout: DEFAULT_TIMEOUT }).should(
|
||||
'not.have.class',
|
||||
'euiFieldSearch-isLoading'
|
||||
);
|
||||
|
||||
cy.get(FIELDS_BROWSER_HOST_CATEGORIES_COUNT)
|
||||
.invoke('text')
|
||||
.then(hostCategoriesCount => {
|
||||
cy.get(FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT)
|
||||
.invoke('text')
|
||||
.then(systemCategoriesCount => {
|
||||
cy.get(FIELDS_BROWSER_FIELDS_COUNT)
|
||||
.invoke('text')
|
||||
.should('eq', `${+hostCategoriesCount + +systemCategoriesCount} fields`);
|
||||
});
|
||||
cy.get(
|
||||
`[data-test-subj="timeline"] [data-test-subj="field-${toggleField}-checkbox"]`
|
||||
).uncheck({
|
||||
force: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('selects a search results label with the expected count of categories matching the filter input', () => {
|
||||
const category = 'host';
|
||||
clickOutsideFieldsBrowser();
|
||||
|
||||
populateTimeline();
|
||||
cy.get(FIELDS_BROWSER_CONTAINER).should('not.exist');
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
filterFieldsBrowser(`${category}.`);
|
||||
|
||||
cy.get(FIELDS_BROWSER_SELECTED_CATEGORY_TITLE)
|
||||
.invoke('text')
|
||||
.should('eq', category);
|
||||
});
|
||||
|
||||
it('displays a count of only the fields in the selected category that match the filter input', () => {
|
||||
const filterInput = 'host.geo.c';
|
||||
|
||||
populateTimeline();
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
filterFieldsBrowser(filterInput);
|
||||
|
||||
cy.get(FIELDS_BROWSER_SELECTED_CATEGORY_COUNT)
|
||||
.invoke('text')
|
||||
.should('eq', '4');
|
||||
});
|
||||
|
||||
it('adds a field to the timeline when the user clicks the checkbox', () => {
|
||||
const filterInput = 'host.geo.c';
|
||||
const toggleField = 'host.geo.city_name';
|
||||
|
||||
populateTimeline();
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
filterFieldsBrowser(filterInput);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'not.exist'
|
||||
);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="field-${toggleField}-checkbox"]`).check({
|
||||
force: true,
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'not.exist'
|
||||
);
|
||||
});
|
||||
|
||||
clickOutsideFieldsBrowser();
|
||||
it('selects a search results label with the expected count of categories matching the filter input', () => {
|
||||
const category = 'host';
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'exist'
|
||||
);
|
||||
});
|
||||
filterFieldsBrowser(`${category}.`);
|
||||
|
||||
it('adds a field to the timeline when the user drags and drops a field', () => {
|
||||
const filterInput = 'host.geo.c';
|
||||
const toggleField = 'host.geo.city_name';
|
||||
|
||||
populateTimeline();
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
filterFieldsBrowser(filterInput);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'not.exist'
|
||||
);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="field-name-${toggleField}"]`).then(field =>
|
||||
drag(field)
|
||||
);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="headers-group"]`).then(headersDropArea =>
|
||||
drop(headersDropArea)
|
||||
);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`, {
|
||||
timeout: DEFAULT_TIMEOUT,
|
||||
}).should('exist');
|
||||
});
|
||||
|
||||
it('resets all fields in the timeline when `Reset Fields` is clicked', () => {
|
||||
const filterInput = 'host.geo.c';
|
||||
const toggleField = 'host.geo.city_name';
|
||||
|
||||
populateTimeline();
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
filterFieldsBrowser(filterInput);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'not.exist'
|
||||
);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="field-${toggleField}-checkbox"]`).check({
|
||||
force: true,
|
||||
cy.get(FIELDS_BROWSER_SELECTED_CATEGORY_TITLE)
|
||||
.invoke('text')
|
||||
.should('eq', category);
|
||||
});
|
||||
|
||||
clickOutsideFieldsBrowser();
|
||||
it('adds a field to the timeline when the user clicks the checkbox', () => {
|
||||
const filterInput = 'host.geo.c';
|
||||
const toggleField = 'host.geo.city_name';
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'exist'
|
||||
);
|
||||
filterFieldsBrowser(filterInput);
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'not.exist'
|
||||
);
|
||||
|
||||
cy.get('[data-test-subj="timeline"] [data-test-subj="reset-fields"]').click({ force: true });
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="field-${toggleField}-checkbox"]`).check({
|
||||
force: true,
|
||||
});
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'not.exist'
|
||||
);
|
||||
clickOutsideFieldsBrowser();
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`, {
|
||||
timeout: DEFAULT_TIMEOUT,
|
||||
}).should('exist');
|
||||
});
|
||||
|
||||
it('adds a field to the timeline when the user drags and drops a field', () => {
|
||||
const filterInput = 'host.geo.c';
|
||||
const toggleField = 'host.geo.country_name';
|
||||
|
||||
filterFieldsBrowser(filterInput);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'not.exist'
|
||||
);
|
||||
|
||||
cy.get(
|
||||
`[data-test-subj="timeline"] [data-test-subj="field-name-${toggleField}"]`
|
||||
).then(field => drag(field));
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="headers-group"]`).then(headersDropArea =>
|
||||
drop(headersDropArea)
|
||||
);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`, {
|
||||
timeout: DEFAULT_TIMEOUT,
|
||||
}).should('exist');
|
||||
});
|
||||
|
||||
it('resets all fields in the timeline when `Reset Fields` is clicked', () => {
|
||||
const filterInput = 'host.geo.c';
|
||||
const toggleField = 'host.geo.continent_name';
|
||||
|
||||
filterFieldsBrowser(filterInput);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'not.exist'
|
||||
);
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="field-${toggleField}-checkbox"]`).check({
|
||||
force: true,
|
||||
});
|
||||
|
||||
clickOutsideFieldsBrowser();
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'exist'
|
||||
);
|
||||
|
||||
openTimelineFieldsBrowser();
|
||||
|
||||
cy.get('[data-test-subj="timeline"] [data-test-subj="reset-fields"]').click({ force: true });
|
||||
|
||||
cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${toggleField}"]`).should(
|
||||
'not.exist'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,5 +22,9 @@
|
|||
// Import commands.js using ES2015 syntax:
|
||||
import './commands';
|
||||
|
||||
Cypress.Cookies.defaults({
|
||||
whitelist: 'sid',
|
||||
});
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
|
|
Loading…
Reference in a new issue