Skip to content

Commit

Permalink
Fix skipped Bulk Actions in Alerts Table tests (#156795)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcger committed May 5, 2023
1 parent 467681a commit 8325b0d
Showing 1 changed file with 47 additions and 4 deletions.
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

0 comments on commit 8325b0d

Please sign in to comment.