mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[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:
parent
a4612c9732
commit
490c34c053
1 changed files with 38 additions and 2 deletions
|
@ -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: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue