Skip to content

Commit

Permalink
[8.8] Fix skipped Bulk Actions in Alerts Table tests (elastic#156795) (
Browse files Browse the repository at this point in the history
…elastic#156873)

# Backport

This will backport the following commits from `main` to `8.8`:
- [Fix skipped Bulk Actions in Alerts Table tests
(elastic#156795)](elastic#156795)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Julian
Gernun","email":"17549662+jcger@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-05-05T15:04:20Z","message":"Fix
skipped Bulk Actions in Alerts Table tests (elastic#156795)\n\n##
Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/154970\r\nFixes
https://github.com/elastic/kibana/issues/152176\r\n\r\nRun times
before:\r\n![Screenshot\r\n12](https://user-images.githubusercontent.com/17549662/236402240-5be77baa-c35b-44f2-bbe1-f49d7cd6accc.png)\r\n\r\nRun
times
after:\r\n\r\n![Screenshot](https://user-images.githubusercontent.com/17549662/236402290-0d7377b2-1db3-4c62-8164-ff40358aea63.png)","sha":"8325b0d01451bce2ddbe1418fbb751a744eff96d","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","v8.8.0","v8.9.0"],"number":156795,"url":"https://github.com/elastic/kibana/pull/156795","mergeCommit":{"message":"Fix
skipped Bulk Actions in Alerts Table tests (elastic#156795)\n\n##
Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/154970\r\nFixes
https://github.com/elastic/kibana/issues/152176\r\n\r\nRun times
before:\r\n![Screenshot\r\n12](https://user-images.githubusercontent.com/17549662/236402240-5be77baa-c35b-44f2-bbe1-f49d7cd6accc.png)\r\n\r\nRun
times
after:\r\n\r\n![Screenshot](https://user-images.githubusercontent.com/17549662/236402290-0d7377b2-1db3-4c62-8164-ff40358aea63.png)","sha":"8325b0d01451bce2ddbe1418fbb751a744eff96d"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/156795","number":156795,"mergeCommit":{"message":"Fix
skipped Bulk Actions in Alerts Table tests (elastic#156795)\n\n##
Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/154970\r\nFixes
https://github.com/elastic/kibana/issues/152176\r\n\r\nRun times
before:\r\n![Screenshot\r\n12](https://user-images.githubusercontent.com/17549662/236402240-5be77baa-c35b-44f2-bbe1-f49d7cd6accc.png)\r\n\r\nRun
times
after:\r\n\r\n![Screenshot](https://user-images.githubusercontent.com/17549662/236402290-0d7377b2-1db3-4c62-8164-ff40358aea63.png)","sha":"8325b0d01451bce2ddbe1418fbb751a744eff96d"}}]}]
BACKPORT-->

Co-authored-by: Julian Gernun <17549662+jcger@users.noreply.github.com>
  • Loading branch information
kibanamachine and jcger authored May 5, 2023
1 parent f947b09 commit 0ccbf5a
Showing 1 changed file with 47 additions and 4 deletions.
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

0 comments on commit 0ccbf5a

Please sign in to comment.