Skip to content

Commit

Permalink
[RAM] flaky alerts table state test (#162805)
Browse files Browse the repository at this point in the history
## Summary

closes #150790
The approach is the same as always when rendering the alerts table in
test, we mock jsdom getComputedStyle function as it has bad performance
and we don't really need that calculations
  • Loading branch information
jcger authored Aug 2, 2023
1 parent a4612c9 commit 490c34c
Showing 1 changed file with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,43 @@ jest.mock('@kbn/kibana-react-plugin/public', () => ({
}),
}));

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

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 columns = [
{
id: AlertsField.name,
Expand Down Expand Up @@ -707,8 +744,7 @@ describe('AlertsTableState', () => {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/150790
describe.skip('field browser', () => {
describe('field browser', () => {
const browserFields: BrowserFields = {
kibana: {
fields: {
Expand Down

0 comments on commit 490c34c

Please sign in to comment.