[RAM] flaky alerts table state test (#162805)

## Summary

closes https://github.com/elastic/kibana/issues/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
This commit is contained in:
Julian Gernun 2023-08-02 10:42:32 +02:00 committed by GitHub
parent a4612c9732
commit 490c34c053
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,
@ -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: {