Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix skipped Bulk Actions in Alerts Table tests #156795

Merged
merged 1 commit into from
May 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,44 @@ jest.mock('@kbn/kibana-react-plugin/public', () => {
};
});

const originalGetComputedStyle = Object.assign({}, window.getComputedStyle);

describe('AlertsTable.BulkActions', () => {
beforeAll(() => {
// The JSDOM implementation is too slow
// Especially for dropdowns that try to position themselves
// perf issue - https://github.com/jsdom/jsdom/issues/3234
Object.defineProperty(window, 'getComputedStyle', {
value: (el: HTMLElement) => {
/**
* This is based on the jsdom implementation of getComputedStyle
* https://github.com/jsdom/jsdom/blob/9dae17bf0ad09042cfccd82e6a9d06d3a615d9f4/lib/jsdom/browser/Window.js#L779-L820
*
* It is missing global style parsing and will only return styles applied directly to an element.
* Will not return styles that are global or from emotion
*/
const declaration = new CSSStyleDeclaration();
const { style } = el;

Array.prototype.forEach.call(style, (property: string) => {
declaration.setProperty(
property,
style.getPropertyValue(property),
style.getPropertyPriority(property)
);
});

return declaration;
},
configurable: true,
writable: true,
});
});

afterAll(() => {
Object.defineProperty(window, 'getComputedStyle', originalGetComputedStyle);
});

const alerts = [
{
[AlertsField.name]: ['one'],
Expand Down Expand Up @@ -691,8 +728,7 @@ describe('AlertsTable.BulkActions', () => {
).toBeTruthy();
});

// FLAKY: https://github.com/elastic/kibana/issues/154970
describe.skip('and clear the selection is clicked', () => {
describe('and clear the selection is clicked', () => {
it('should turn off the toolbar', async () => {
const props = {
...tablePropsWithBulkActions,
Expand Down Expand Up @@ -731,8 +767,7 @@ describe('AlertsTable.BulkActions', () => {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/152176
describe.skip('and executing a bulk action', () => {
describe('and executing a bulk action', () => {
it('should return the are all selected flag set to true', async () => {
const mockedFn = jest.fn();
const props = {
Expand Down Expand Up @@ -781,6 +816,10 @@ describe('AlertsTable.BulkActions', () => {
field: 'kibana.alert.rule.uuid',
value: ['uuidone'],
},
{
field: 'kibana.alert.case_ids',
value: [],
},
],
ecs: {
_id: 'alert0',
Expand All @@ -799,6 +838,10 @@ describe('AlertsTable.BulkActions', () => {
field: 'kibana.alert.rule.uuid',
value: ['uuidtwo'],
},
{
field: 'kibana.alert.case_ids',
value: [],
},
],
ecs: {
_id: 'alert1',
Expand Down