Skip to content

Commit

Permalink
[SecuritySolution] Unskip fields browser timeline tests (#174597)
Browse files Browse the repository at this point in the history
  • Loading branch information
janmonschke authored Jan 12, 2024
1 parent 8a443a2 commit a8d3173
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ describe('FieldsBrowser', () => {

result.getByTestId('show-field-browser').click();
await waitFor(() => {
// the container is rendered now
expect(result.getByTestId('fields-browser-container')).toBeInTheDocument();
// by default, no categories are selected
expect(result.getByTestId('category-badges')).toHaveTextContent('');
// the view: all button is shown by default
result.getByText('View: all');
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import {
FIELDS_BROWSER_MESSAGE_HEADER,
FIELDS_BROWSER_FILTER_INPUT,
FIELDS_BROWSER_CATEGORIES_FILTER_CONTAINER,
FIELDS_BROWSER_SELECTED_CATEGORIES_BADGES,
FIELDS_BROWSER_CATEGORY_BADGE,
FIELDS_BROWSER_VIEW_BUTTON,
} from '../../../screens/fields_browser';
import { TIMELINE_FIELDS_BUTTON } from '../../../screens/timeline';

Expand All @@ -29,12 +27,11 @@ import {
resetFields,
toggleCategory,
activateViewSelected,
activateViewAll,
} from '../../../tasks/fields_browser';
import { login } from '../../../tasks/login';
import { visitWithTimeRange } from '../../../tasks/navigation';
import { openTimelineUsingToggle } from '../../../tasks/security_main';
import { openTimelineFieldsBrowser, populateTimeline } from '../../../tasks/timeline';
import { openTimelineFieldsBrowser } from '../../../tasks/timeline';

import { hostsUrl } from '../../../urls/navigation';

Expand All @@ -49,110 +46,83 @@ const defaultHeaders = [
{ id: 'user.name' },
];

// Flaky in serverless tests
// FLAKY: https://github.com/elastic/kibana/issues/169363
describe.skip('Fields Browser', { tags: ['@ess', '@serverless'] }, () => {
context('Fields Browser rendering', () => {
beforeEach(() => {
login();
visitWithTimeRange(hostsUrl('allHosts'));
openTimelineUsingToggle();
populateTimeline();
openTimelineFieldsBrowser();
});

it('displays all categories (by default)', () => {
cy.get(FIELDS_BROWSER_SELECTED_CATEGORIES_BADGES).should('be.empty');
});

it('displays "view all" option by default', () => {
cy.get(FIELDS_BROWSER_VIEW_BUTTON).should('contain.text', 'View: all');
});
describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
login();
visitWithTimeRange(hostsUrl('allHosts'));
openTimelineUsingToggle();
openTimelineFieldsBrowser();
});

it('displays the expected count of categories that match the filter input', () => {
describe('Fields Browser rendering', () => {
it('should display the expected count of categories and fields that match the filter input', () => {
const filterInput = 'host.mac';

filterFieldsBrowser(filterInput);

cy.get(FIELDS_BROWSER_CATEGORIES_COUNT).should('have.text', '2');
});

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_FIELDS_COUNT).should('contain.text', '2');
});

it('displays only the selected fields when "view selected" option is enabled', () => {
it('should display only the selected fields when "view selected" option is enabled', () => {
activateViewSelected();
cy.get(FIELDS_BROWSER_FIELDS_COUNT).should('contain.text', `${defaultHeaders.length}`);
defaultHeaders.forEach((header) => {
cy.get(`[data-test-subj="field-${header.id}-checkbox"]`).should('be.checked');
});
activateViewAll();
});

it('creates the category badge when it is selected', () => {
it('should create the category badge when it is selected', () => {
const category = 'host';
const categoryCheck = 'event';

cy.get(FIELDS_BROWSER_CATEGORY_BADGE(category)).should('not.exist');

toggleCategory(category);

cy.get(FIELDS_BROWSER_CATEGORY_BADGE(category)).should('exist');

toggleCategory(category);
});

it('search a category should match the category in the category filter', () => {
const category = 'host';
cy.log('the category filter should contain the filtered category');

filterFieldsBrowser(category);
toggleCategoryFilter();

cy.get(FIELDS_BROWSER_CATEGORIES_FILTER_CONTAINER).should('contain.text', category);
});

it('search a category should filter out non matching categories in the category filter', () => {
const category = 'host';
const categoryCheck = 'event';
filterFieldsBrowser(category);
toggleCategoryFilter();
cy.log('non-matching categories should not be listed in the category filter');

cy.get(FIELDS_BROWSER_CATEGORIES_FILTER_CONTAINER).should('not.contain.text', categoryCheck);
});
});

context('Editing the timeline', () => {
beforeEach(() => {
login();
visitWithTimeRange(hostsUrl('allHosts'));
openTimelineUsingToggle();
populateTimeline();
openTimelineFieldsBrowser();
});
describe('Editing the timeline', () => {
it('should add/remove columns from the alerts table when the user checks/un-checks them', () => {
const filterInput = 'host.geo.c';

cy.log('removing the message column');

it('removes the message field from the timeline when the user un-checks the field', () => {
cy.get(FIELDS_BROWSER_MESSAGE_HEADER).should('exist');

removesMessageField();
closeFieldsBrowser();

cy.get(FIELDS_BROWSER_MESSAGE_HEADER).should('not.exist');
});

it('adds a field to the timeline when the user clicks the checkbox', () => {
const filterInput = 'host.geo.c';
cy.log('add host.geo.city_name column');

closeFieldsBrowser();
cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER).should('not.exist');

openTimelineFieldsBrowser();

filterFieldsBrowser(filterInput);
addsHostGeoCityNameToTimeline();
closeFieldsBrowser();

cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER).should('exist');
});

it('resets all fields in the timeline when `Reset Fields` is clicked', () => {
it('should reset all fields in the timeline when `Reset Fields` is clicked', () => {
const filterInput = 'host.geo.c';

filterFieldsBrowser(filterInput);
Expand All @@ -168,19 +138,16 @@ describe.skip('Fields Browser', { tags: ['@ess', '@serverless'] }, () => {
resetFields();

cy.get(FIELDS_BROWSER_HEADER_HOST_GEO_CONTINENT_NAME_HEADER).should('not.exist');
});

it('restores focus to the Customize Columns button when `Reset Fields` is clicked', () => {
openTimelineFieldsBrowser();
resetFields();
cy.log('restores focus to the Customize Columns button when `Reset Fields` is clicked');

cy.get(TIMELINE_FIELDS_BUTTON).should('have.focus');
});

it('restores focus to the Customize Columns button when Esc is pressed', () => {
cy.log('restores focus to the Customize Columns button when Esc is pressed');

openTimelineFieldsBrowser();
cy.get(FIELDS_BROWSER_FILTER_INPUT).type('{esc}');

cy.get(FIELDS_BROWSER_FILTER_INPUT).type('{esc}');
cy.get(TIMELINE_FIELDS_BUTTON).should('have.focus');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@ export const addsFields = (fields: string[]) => {
};

export const addsHostGeoCityNameToTimeline = () => {
cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_CHECKBOX).check({
force: true,
});
cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_CHECKBOX).check();
};

export const addsHostGeoContinentNameToTimeline = () => {
cy.get(FIELDS_BROWSER_HOST_GEO_CONTINENT_NAME_CHECKBOX).check({
force: true,
});
cy.get(FIELDS_BROWSER_HOST_GEO_CONTINENT_NAME_CHECKBOX).check();
};

export const clearFieldsBrowser = () => {
Expand Down Expand Up @@ -67,7 +63,7 @@ export const filterFieldsBrowser = (fieldName: string) => {
};

export const toggleCategoryFilter = () => {
cy.get(FIELDS_BROWSER_CATEGORIES_FILTER_BUTTON).click({ force: true });
cy.get(FIELDS_BROWSER_CATEGORIES_FILTER_BUTTON).click();
};

export const toggleCategory = (category: string) => {
Expand All @@ -79,24 +75,22 @@ export const toggleCategory = (category: string) => {
};

export const removesMessageField = () => {
cy.get(FIELDS_BROWSER_MESSAGE_CHECKBOX).uncheck({
force: true,
});
cy.get(FIELDS_BROWSER_MESSAGE_CHECKBOX).uncheck();
};

export const removeField = (fieldName: string) => {
cy.get(GET_FIELD_CHECKBOX(fieldName)).uncheck();
};

export const resetFields = () => {
cy.get(FIELDS_BROWSER_RESET_FIELDS).click({ force: true });
cy.get(FIELDS_BROWSER_RESET_FIELDS).click();
};

export const activateViewSelected = () => {
cy.get(FIELDS_BROWSER_VIEW_BUTTON).click({ force: true });
cy.get(FIELDS_BROWSER_VIEW_SELECTED).click({ force: true });
cy.get(FIELDS_BROWSER_VIEW_BUTTON).click();
cy.get(FIELDS_BROWSER_VIEW_SELECTED).click();
};
export const activateViewAll = () => {
cy.get(FIELDS_BROWSER_VIEW_BUTTON).click({ force: true });
cy.get(FIELDS_BROWSER_VIEW_ALL).click({ force: true });
cy.get(FIELDS_BROWSER_VIEW_BUTTON).click();
cy.get(FIELDS_BROWSER_VIEW_ALL).click();
};
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export const markAsFavorite = () => {
};

export const openTimelineFieldsBrowser = () => {
cy.get(TIMELINE_FIELDS_BUTTON).first().click({ force: true });
cy.get(TIMELINE_FIELDS_BUTTON).first().click();
};

export const openTimelineInspectButton = () => {
Expand Down

0 comments on commit a8d3173

Please sign in to comment.